summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/src/umath/loops.c.src3
-rw-r--r--numpy/core/src/umath/simd.inc.src3
-rw-r--r--numpy/core/tests/test_umath.py7
3 files changed, 10 insertions, 3 deletions
diff --git a/numpy/core/src/umath/loops.c.src b/numpy/core/src/umath/loops.c.src
index 4faa068c8..1ca298b30 100644
--- a/numpy/core/src/umath/loops.c.src
+++ b/numpy/core/src/umath/loops.c.src
@@ -1866,6 +1866,9 @@ NPY_NO_EXPORT void
const @type@ in2 = *(@type@ *)ip2;
io1 = (io1 @OP@ in2 || npy_isnan(io1)) ? io1 : in2;
}
+ if (npy_isnan(io1)) {
+ npy_set_floatstatus_invalid();
+ }
*((@type@ *)iop1) = io1;
}
}
diff --git a/numpy/core/src/umath/simd.inc.src b/numpy/core/src/umath/simd.inc.src
index 2fae072ee..5c0568c12 100644
--- a/numpy/core/src/umath/simd.inc.src
+++ b/numpy/core/src/umath/simd.inc.src
@@ -1051,6 +1051,9 @@ sse2_@kind@_@TYPE@(@type@ * ip, @type@ * op, const npy_intp n)
LOOP_BLOCKED_END {
*op = (*op @OP@ ip[i] || npy_isnan(*op)) ? *op : ip[i];
}
+ if (npy_isnan(*op)) {
+ npy_set_floatstatus_invalid();
+ }
}
/**end repeat1**/
diff --git a/numpy/core/tests/test_umath.py b/numpy/core/tests/test_umath.py
index f12754a33..1464a9e9a 100644
--- a/numpy/core/tests/test_umath.py
+++ b/numpy/core/tests/test_umath.py
@@ -1329,14 +1329,15 @@ class TestMinMax(object):
assert_equal(d.min(), d[0])
def test_reduce_warns(self):
- # gh 10370 Some compilers reorder the call to npy_getfloatstatus and
- # put it before the call to an intrisic function that causes invalid
- # status to be set
+ # gh 10370, 11029 Some compilers reorder the call to npy_getfloatstatus
+ # and put it before the call to an intrisic function that causes
+ # invalid status to be set. Also make sure warnings are emitted
for n in (2, 4, 8, 16, 32):
with suppress_warnings() as sup:
sup.record(RuntimeWarning)
for r in np.diagflat([np.nan] * n):
assert_equal(np.min(r), np.nan)
+ assert_equal(len(sup.log), n)
class TestAbsoluteNegative(object):