8000 TST: avoid failures for FPE errors/warnings in `abs` on BSDs · numpy/numpy@7b423f4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7b423f4

Browse files
committed
TST: avoid failures for FPE errors/warnings in abs on BSDs
1 parent db6c060 commit 7b423f4

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed

numpy/core/tests/test_multiarray.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9698,9 +9698,12 @@ def test_ragged_comparison_fails(op):
96989698
def test_npymath_complex(fun, npfun, x, y, test_dtype):
96999699
# Smoketest npymath functions
97009700
z = test_dtype(complex(x, y))
9701-
got = fun(z)
9702-
expected = npfun(z)
9703-
assert_allclose(got, expected)
9701+
with np.errstate(invalid='ignore'):
9702+
# Fallback implementations may emit a warning for +-inf (see gh-24876):
9703+
# RuntimeWarning: invalid value encountered in absolute
9704+
got = fun(z)
9705+
expected = npfun(z)
9706+
assert_allclose(got, expected)
97049707

97059708

97069709
def test_npymath_real():

numpy/core/tests/test_numeric.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -916,6 +916,11 @@ def assert_op_raises_fpe(self, fpeerr, flop, sc1, sc2):
916916
@pytest.mark.skipif(IS_WASM, reason="no wasm fp exception support")
917917
@pytest.mark.parametrize("typecode", np.typecodes["AllFloat"])
918918
def test_floating_exceptions(self, typecode):
919+
if 'bsd' in sys.platform and typecode in 'gG':
920+
pytest.skip(reason="Fallback impl for (c)longdouble may not raise "
921+
"FPE errors as expected on BSD OSes, "
922+
"see gh-24876, gh-23379")
923+
919924
# Test basic arithmetic function errors
920925
with np.errstate(all='raise'):
921926
ftype = obj2sctype(typecode)

numpy/core/tests/test_umath.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1645,6 +1645,8 @@ def test_sinh(self):
16451645
np.array(1200.0, dtype='d'))
16461646

16471647
@pytest.mark.skipif(IS_WASM, reason="fp errors don't work in wasm")
1648+
@pytest.mark.skipif('bsd' in sys.platform,
1649+
reason="fallback implementation may not raise, see gh-2487")
16481650
def test_cosh(self):
16491651
in_ = [np.nan, -np.nan, np.inf, -np.inf]
16501652
out = [np.nan, np.nan, np.inf, np.inf]

numpy/core/tests/test_umath_complex.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,8 +576,8 @@ def test_array(self, stride, astype):
576576
complex(0., 0.),
577577
complex(np.nan, np.nan),
578578
complex(np.nan, np.nan)], dtype=astype)
579-
assert_equal(np.abs(arr[::stride]), abs_true[::stride])
580579
with np.errstate(invalid='ignore'):
580+
assert_equal(np.abs(arr[::stride]), abs_true[::stride])
581581
assert_equal(np.square(arr[::stride]), sq_true[::stride])
582582

583583
class TestComplexAbsoluteAVX:

0 commit comments

Comments
 (0)
0