GeezerVison is showing github.com — TST: avoid failures for FPE errors/warnings in `abs` on BSDs · numpy/numpy@da44db0
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: numpy/core/tests/test_multiarray.py +6-3Lines changed: 6 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -9698,9 +9698,12 @@ def test_ragged_comparison_fails(op): | 9698 | 9698 | def test_npymath_complex(fun, npfun, x, y, test_dtype): | 9699 | 9699 | # Smoketest npymath functions | 9700 | 9700 | 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) | 9704 | 9707 |
| 9705 | 9708 |
| 9706 | 9709 | def test_npymath_real(): | |
Collapse file Copy file name to clipboardExpand all lines: numpy/core/tests/test_numeric.py +5Lines changed: 5 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -916,6 +916,11 @@ def assert_op_raises_fpe(self, fpeerr, flop, sc1, sc2): | 916 | 916 | @pytest.mark.skipif(IS_WASM, reason="no wasm fp exception support") | 917 | 917 | @pytest.mark.parametrize("typecode", np.typecodes["AllFloat"]) | 918 | 918 | def test_floating_exceptions(self, typecode): | | 919 | + if 'bsd' in sys.platform and typecode in 'gG': | | 920 | + pytest.skip(reason="Fallback implementations for (c)longdouble may " | | 921 | + "not raise FPE errors as expected on BSD OSes, " | | 922 | + "see gh-24876, gh-23379") | | 923 | + | 919 | 924 | # Test basic arithmetic function errors | 920 | 925 | with np.errstate(all='raise'): | 921 | 926 | ftype = obj2sctype(typecode) | |
Collapse file Copy file name to clipboardExpand all lines: numpy/core/tests/test_umath.py +2Lines changed: 2 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1645,6 +1645,8 @@ def test_sinh(self): | 1645 | 1645 | np.array(1200.0, dtype='d')) | 1646 | 1646 |
| 1647 | 1647 | @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") | 1648 | 1650 | def test_cosh(self): | 1649 | 1651 | in_ = [np.nan, -np.nan, np.inf, -np.inf] | 1650 | 1652 | out = [np.nan, np.nan, np.inf, np.inf] | |
Collapse file Copy file name to clipboardExpand all lines: numpy/core/tests/test_umath_complex.py +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -576,8 +576,8 @@ def test_array(self, stride, astype): | 576 | 576 | complex(0., 0.), | 577 | 577 | complex(np.nan, np.nan), | 578 | 578 | complex(np.nan, np.nan)], dtype=astype) | 579 | | - assert_equal(np.abs(arr[::stride]), abs_true[::stride]) | 580 | 579 | with np.errstate(invalid='ignore'): | | 580 | + assert_equal(np.abs(arr[::stride]), abs_true[::stride]) | 581 | 581 | assert_equal(np.square(arr[::stride]), sq_true[::stride]) | 582 | 582 |
| 583 | 583 | class TestComplexAbsoluteAVX: | |
|