diff options
| -rw-r--r-- | numpy/core/tests/test_umath_accuracy.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/numpy/core/tests/test_umath_accuracy.py b/numpy/core/tests/test_umath_accuracy.py index 3d4d5b5aa..6ee4d2fee 100644 --- a/numpy/core/tests/test_umath_accuracy.py +++ b/numpy/core/tests/test_umath_accuracy.py @@ -8,6 +8,11 @@ from numpy.testing import assert_array_max_ulp from numpy.testing._private.utils import _glibc_older_than from numpy.core._multiarray_umath import __cpu_features__ +UNARY_UFUNCS = [obj for obj in np.core.umath.__dict__.values() if + isinstance(obj, np.ufunc)] +UNARY_OBJECT_UFUNCS = [uf for uf in UNARY_UFUNCS if "O->O" in uf.types] +UNARY_OBJECT_UFUNCS.remove(getattr(np, 'invert')) + IS_AVX = __cpu_features__.get('AVX512F', False) or \ (__cpu_features__.get('FMA3', False) and __cpu_features__.get('AVX2', False)) # only run on linux with AVX, also avoid old glibc (numpy/numpy#20448). @@ -59,3 +64,12 @@ class TestAccuracy: outval = outval[perm] maxulperr = data_subset['ulperr'].max() assert_array_max_ulp(npfunc(inval), outval, maxulperr) + + @pytest.mark.parametrize("ufunc", UNARY_OBJECT_UFUNCS) + def test_validate_fp16_transcendentals(self, ufunc): + with np.errstate(all='ignore'): + 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) |
