Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test all Numba decorated functions with care #496

Closed
hakonanes opened this issue Jan 10, 2022 · 1 comment
Closed

Test all Numba decorated functions with care #496

hakonanes opened this issue Jan 10, 2022 · 1 comment

Comments

@hakonanes
Copy link
Member

The lesson from #494 is that all Numba decorated functions must be tested with care, meaning not just via py_func() or physical examples, but "indirectly". I'm not sure how to do this systematically, but I hope this issue can guide us in that direction.

The issue refers to different results on Windows and Linux produced by a Numba decorated function for converting a Euler angle triplet to a quaternion. It was fixed by replacing array creation in two steps

rotation = np.zeros(4)
rotation[0] = c * np.cos(sigma)
rotation[1] = -s * np.cos(delta)
rotation[2] = -s * np.sin(delta)
rotation[3] = -c * np.sin(sigma)

with creation in one step

rotation = np.array(
(c * np.cos(sigma), -s * np.cos(delta), -s * np.sin(delta), -c * np.sin(sigma)),
dtype=np.float64,
)

For some reason, the two-step creation gave garbage results on Windows but not on Linux, while the latter gave same results on both OS. This was not caught in testing, but is now, by testing another function which calls this function.

@hakonanes
Copy link
Member Author

Tips for testing Numba functions have been added to the contributing guide in #499.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant