8000 TST: Do not test for signalling NaNs not raising warnings · seberg/numpy@c23fb5d · GitHub
[go: up one dir, main page]

Skip to content

Commit c23fb5d

Browse files
committed
TST: Do not test for signalling NaNs not raising warnings
This is technically even incorrect in IEEE, signalling NaNs should pretty much always give a warning. But overall, it seems unlikely NumPy should bother about it (we never create them after all). This is split off from numpygh-19476. Mainly, to check whether s390x is broken...
1 parent f353371 commit c23fb5d

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

numpy/core/tests/test_ufunc.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2191,10 +2191,11 @@ def test_ufunc_noncontiguous(ufunc):
21912191

21922192

21932193
@pytest.mark.parametrize('ufunc', [np.sign, np.equal])
2194+
@np.errstate(invalid="ignore")
21942195
def test_ufunc_warn_with_nan(ufunc):
2195-
# issue gh-15127
2196-
# test that calling certain ufuncs with a non-standard `nan` value does not
2197-
# emit a warning
2196+
# For a while we ensured to not give a warning even for signalling NaNs.
2197+
# that is not IEEE standard conform, and an unnecessary hassle. This
2198+
# test checks for the correct result, but ignores the warnings.
21982199
# `b` holds a 64 bit signaling nan: the most significant bit of the
21992200
# significand is zero.
22002201
b = np.array([0x7ff0000000000001], 'i8').view('f8')

numpy/core/tests/test_umath.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3619,9 +3619,11 @@ def test_memoverlap_accumulate(ftype):
36193619
assert_equal(np.minimum.accumulate(arr), out_min)
36203620

36213621
def test_signaling_nan_exceptions():
3622-
with assert_no_warnings():
3622+
# For a while, NumPy ensured the invalid warning was not set. IEEE says it
3623+
# should be set. No need for strong guarantees for signalling NaNs.
3624+
with np.errstate(invalid="ignore"):
36233625
a = np.ndarray(shape=(), dtype='float32', buffer=b'\x00\xe0\xbf\xff')
3624-
np.isnan(a)
3626+
assert np.isnan(a)
36253627

36263628
@pytest.mark.parametrize("arr", [
36273629
np.arange(2),

0 commit comments

Comments
 (0)
0