summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--numpy/core/src/umath/loops.c.src2
-rw-r--r--numpy/core/tests/test_ufunc.py18
2 files changed, 20 insertions, 0 deletions
diff --git a/numpy/core/src/umath/loops.c.src b/numpy/core/src/umath/loops.c.src
index 8a2e5bc40..33d10da49 100644
--- a/numpy/core/src/umath/loops.c.src
+++ b/numpy/core/src/umath/loops.c.src
@@ -1824,6 +1824,7 @@ NPY_NO_EXPORT void
*((npy_bool *)op1) = in1 @OP@ in2;
}
}
+ npy_clear_floatstatus_barrier((char*)dimensions);
}
/**end repeat1**/
@@ -2068,6 +2069,7 @@ NPY_NO_EXPORT void
const @type@ in1 = *(@type@ *)ip1;
*((@type@ *)op1) = in1 > 0 ? 1 : (in1 < 0 ? -1 : (in1 == 0 ? 0 : in1));
}
+ npy_clear_floatstatus_barrier((char*)dimensions);
}
NPY_NO_EXPORT void
diff --git a/numpy/core/tests/test_ufunc.py b/numpy/core/tests/test_ufunc.py
index 507ac87b9..679bea96a 100644
--- a/numpy/core/tests/test_ufunc.py
+++ b/numpy/core/tests/test_ufunc.py
@@ -1982,3 +1982,21 @@ def test_ufunc_noncontiguous(ufunc):
assert_allclose(res_c, res_n, atol=tol, rtol=tol)
else:
assert_equal(c_ar, n_ar)
+
+
+@pytest.mark.parametrize('ufunc', [np.sign, np.equal])
+def test_ufunc_warn_with_nan(ufunc):
+ # issue gh-15127
+ # test that calling certain ufuncs with a non-standard `nan` value does not
+ # emit a warning
+ # `b` holds a 64 bit signaling nan: the most significant bit of the
+ # significand is zero.
+ b = np.array([0x7ff0000000000001], 'i8').view('f8')
+ assert np.isnan(b)
+ if ufunc.nin == 1:
+ ufunc(b)
+ elif ufunc.nin == 2:
+ ufunc(b, b.copy())
+ else:
+ raise ValueError('ufunc with more than 2 inputs')
+