Skip to content

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