|
32 | 32 | assert_raises, |
33 | 33 | assert_raises_regex, |
34 | 34 | ) |
35 | | -from numpy.testing._private.utils import _glibc_older_than |
| 35 | +from numpy.testing._private.utils import _glibc_older_than, _ufunc_has_fma |
36 | 36 |
|
37 | 37 | UFUNCS = [obj for obj in np._core.umath.__dict__.values() |
38 | 38 | if isinstance(obj, np.ufunc)] |
@@ -2097,12 +2097,15 @@ def test_sincos_float32(self): |
2097 | 2097 | # this is known to be problematic on old glibc, so skip it there |
2098 | 2098 | x_f32[index] = np.float32(10E+10 * np.random.rand(M)) |
2099 | 2099 | x_f64 = np.float64(x_f32) |
2100 | | - assert_array_max_ulp(np.sin(x_f32), np.float32(np.sin(x_f64)), maxulp=2) |
2101 | | - assert_array_max_ulp(np.cos(x_f32), np.float32(np.cos(x_f64)), maxulp=2) |
| 2100 | + # numpy-simd-rounding gives ~3 ulp when fma is not available and kLowAccuracy |
| 2101 | + # been set in the precision mode |
| 2102 | + maxulp_f32 = 2 if _ufunc_has_fma(np.sin, np.float32) else 3 |
| 2103 | + assert_array_max_ulp(np.sin(x_f32), np.float32(np.sin(x_f64)), maxulp=maxulp_f32) |
| 2104 | + assert_array_max_ulp(np.cos(x_f32), np.float32(np.cos(x_f64)), maxulp=maxulp_f32) |
2102 | 2105 | # test aliasing(issue #17761) |
2103 | 2106 | tx_f32 = x_f32.copy() |
2104 | | - assert_array_max_ulp(np.sin(x_f32, out=x_f32), np.float32(np.sin(x_f64)), maxulp=2) |
2105 | | - assert_array_max_ulp(np.cos(tx_f32, out=tx_f32), np.float32(np.cos(x_f64)), maxulp=2) |
| 2107 | + assert_array_max_ulp(np.sin(x_f32, out=x_f32), np.float32(np.sin(x_f64)), maxulp=maxulp_f32) |
| 2108 | + assert_array_max_ulp(np.cos(tx_f32, out=tx_f32), np.float32(np.cos(x_f64)), maxulp=maxulp_f32) |
2106 | 2109 |
|
2107 | 2110 | def test_strided_float32(self): |
2108 | 2111 | np.random.seed(42) |
|
0 commit comments