You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When working with bfloat16, given how variable the precision is, it would be super useful to be able to make assertions based on the number of ULPs between numbers rather than traditional measures of tolerance like atol/rtol.
However, np.testing.assert_array_max_ulp does not currently work with the bfloat16 type from ml_dtypes:
>>>a=np.array(0.0, dtype=ml_dtypes.bfloat16)
>>>np.testing.assert_array_max_ulp(a, a)
Traceback (mostrecentcalllast):
File"<stdin>", line1, in<module>File"numpy/testing/_private/utils.py", line1638, inassert_array_max_ulpret=nulp_diff(a, b, dtype)
File"numpy/testing/_private/utils.py", line1686, innulp_difft=np.common_type(x, y)
File"<__array_function__ internals>", line180, incommon_typeFile"numpy/lib/type_check.py", line730, incommon_typeraiseTypeError("can't get common type for non-numeric array")
TypeError: can'tgetcommontypefornon-numericarray
Given how ml_dtypes integrates with NumPy/the existence of NumPy's own float16 dtype, I'm not sure whether this is possible - but I'll open this issue on the off chance that it might be :)
Thanks!
The text was updated successfully, but these errors were encountered:
Similar to ml_dtypes.finfo, we could provide a version of this and related functions that would support the dtype extensions here, or we could advocate for numpy to make its code more extensible.
When working with bfloat16, given how variable the precision is, it would be super useful to be able to make assertions based on the number of ULPs between numbers rather than traditional measures of tolerance like
atol
/rtol
.However,
np.testing.assert_array_max_ulp
does not currently work with thebfloat16
type fromml_dtypes
:Given how
ml_dtypes
integrates with NumPy/the existence of NumPy's ownfloat16
dtype, I'm not sure whether this is possible - but I'll open this issue on the off chance that it might be :)Thanks!
The text was updated successfully, but these errors were encountered: