Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/upcoming_changes/10786.change.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Relax NumPy ``sin``/``cos`` test comparisons on Linux x86_64 with NumPy < 1.25
------------------------------------------------------------------------------

Follow-up to PR #10572, which added a 4-ULP allowance for NumPy < 1.25
``sin``/``cos`` on Linux x86_64. Apply that allowance in the remaining tests
that were missed, and skip tests where the NumPy < 1.25 error cannot be
matched by relative ULP comparison.
4 changes: 3 additions & 1 deletion numba/tests/test_extending.py
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,9 @@ def test_series_ufunc(self):
self.assertIsInstance(ss, Series)
self.assertIsInstance(ss._index, Index)
self.assertIs(ss._index._data, i._data)
self.assertPreciseEqual(ss._values, np.cos(np.sin(s._values)))
ulps = 4 if numpy_sincos_low_precision else 1
self.assertPreciseEqual(ss._values, np.cos(np.sin(s._values)),
prec='double', ulps=ulps)

def test_series_constructor(self):
i = Index(np.int32([42, 8, -5]))
Expand Down
13 changes: 5 additions & 8 deletions numba/tests/test_looplifting.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,9 @@ def foo(x, y):
# Ensure that is really a new overload for the lifted loop
self.assertEqual(len(lifted.signatures), 2)


# Repeated sin/cos in this loop lets NumPy<1.25 error grow past ULP tolerance.
@unittest.skipIf(numpy_sincos_low_precision,
"NumPy<1.25 sincos vs libm")
def test_lift_objectmode_issue_4223(self):
from numba import jit

Expand All @@ -551,13 +553,8 @@ def foo(a, b, c, d, x0, y0, n):
kwargs = dict(a=1.7, b=1.7, c=0.6, d=1.2, x0=0, y0=0, n=200)
got = foo(**kwargs)
expected = foo.py_func(**kwargs)
ulps = 4 if numpy_sincos_low_precision else 1
self.assertPreciseEqual(
got[0], expected[0], prec='double', ulps=ulps,
)
self.assertPreciseEqual(
got[1], expected[1], prec='double', ulps=ulps,
)
self.assertPreciseEqual(got[0], expected[0])
self.assertPreciseEqual(got[1], expected[1])
[lifted] = foo.overloads[foo.signatures[0]].lifted
self.assertEqual(len(lifted.nopython_signatures), 1)

Expand Down
8 changes: 4 additions & 4 deletions numba/tests/test_np_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5732,17 +5732,17 @@ def test_select_exception(self):
np_nbfunc(condlist, choicelist, default)
self.assertIn(expected_text, str(e.exception))

# Near-zero window endpoints differ in sign under NumPy<1.25 sincos.
@unittest.skipIf(numpy_sincos_low_precision,
"NumPy<1.25 sincos vs libm")
def test_windowing(self):
def check_window(func):
np_pyfunc = func
np_nbfunc = njit(func)
ulps = 4 if numpy_sincos_low_precision else 1

for M in [0, 1, 5, 12]:
expected = np_pyfunc(M)
got = np_nbfunc(M)
self.assertPreciseEqual(expected, got, prec='double',
ulps=ulps)
self.assertPreciseEqual(expected, got, prec='double')

for M in ['a', 1.1, 1j]:
with self.assertRaises(TypingError) as raises:
Expand Down
4 changes: 3 additions & 1 deletion numba/tests/test_target_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,9 @@ def define_pipelines(self):
def foo(x):
return np.sin(x), np.cos(x) # np.sin is DPU, np.cos is CPU

self.assertPreciseEqual(foo(5), (314159.0, np.cos(5)))
self.assertPreciseEqual(
foo(5), (314159.0, np.cos(5)), prec='double', ulps=ulps,
)


if __name__ == "__main__":
Expand Down
Loading