summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/src/umath/loops.c.src8
-rw-r--r--numpy/core/tests/test_umath.py6
2 files changed, 11 insertions, 3 deletions
diff --git a/numpy/core/src/umath/loops.c.src b/numpy/core/src/umath/loops.c.src
index 1ca298b30..0b02031a7 100644
--- a/numpy/core/src/umath/loops.c.src
+++ b/numpy/core/src/umath/loops.c.src
@@ -1874,9 +1874,13 @@ NPY_NO_EXPORT void
}
else {
BINARY_LOOP {
- const @type@ in1 = *(@type@ *)ip1;
+ @type@ in1 = *(@type@ *)ip1;
const @type@ in2 = *(@type@ *)ip2;
- *((@type@ *)op1) = (in1 @OP@ in2 || npy_isnan(in1)) ? in1 : in2;
+ in1 = (in1 @OP@ in2 || npy_isnan(in1)) ? in1 : in2;
+ if (npy_isnan(in1)) {
+ npy_set_floatstatus_invalid();
+ }
+ *((@type@ *)op1) = in1;
}
}
}
diff --git a/numpy/core/tests/test_umath.py b/numpy/core/tests/test_umath.py
index f98367688..85c9a4929 100644
--- a/numpy/core/tests/test_umath.py
+++ b/numpy/core/tests/test_umath.py
@@ -14,7 +14,7 @@ from numpy.testing import (
assert_, assert_equal, assert_raises, assert_raises_regex,
assert_array_equal, assert_almost_equal, assert_array_almost_equal,
assert_allclose, assert_no_warnings, suppress_warnings,
- _gen_alignment_data,
+ _gen_alignment_data, assert_warns
)
@@ -1339,6 +1339,10 @@ class TestMinMax(object):
assert_equal(np.min(r), np.nan)
assert_equal(len(sup.log), n)
+ def test_minimize_warns(self):
+ # gh 11589
+ assert_warns(RuntimeWarning, np.minimum, np.nan, 1)
+
class TestAbsoluteNegative(object):
def test_abs_neg_blocked(self):