Skip to content

TST: Add tests for FP16 umath functions #21954

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

Merged
merged 2 commits into from
Aug 4, 2022
Merged

Conversation

r-devulap
Copy link
Member

Adding tests for comprehensive coverage of float16 umath functions.

arr = np.arange(65536, dtype=np.int16)
datafp16 = np.frombuffer(arr.tobytes(), dtype=np.float16)
datafp32 = datafp16.astype(np.float32)
assert_array_max_ulp(ufunc(datafp16), ufunc(datafp32), maxulp=1, dtype=np.float16)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

linting

Suggested change
assert_array_max_ulp(ufunc(datafp16), ufunc(datafp32), maxulp=1, dtype=np.float16)
assert_array_max_ulp(
ufunc(datafp16), ufunc(datafp32), maxulp=1, dtype=np.float16)

@mattip
Copy link
Member

mattip commented Jul 9, 2022

There is a failing test in cygwin.

for value in [np.inf, -np.inf]:
for dt in ['e', 'f', 'd']:
assert_raises(FloatingPointError, callable,
np.array([value], dtype=dt))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you refactor this as a parameterized test?

np.log2(arr)
np.log10(arr)
np.arccosh(arr)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you refactor this into a parameterized test

Copy link
Member

@mattip mattip left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. These tests need a good refactoring, this might be a nice task for a sprint. I noted two that it might be nice to fix already in this PR, if you have time.

@mattip mattip merged commit 5028e40 into numpy:main Aug 4, 2022
@mattip
Copy link
Member

mattip commented Aug 4, 2022

Thanks @r-devulap

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

Successfully merging this pull request may close these issues.

2 participants