diff options
author | mattip <matti.picus@gmail.com> | 2018-07-20 08:58:22 -0700 |
---|---|---|
committer | mattip <matti.picus@gmail.com> | 2018-07-23 17:26:11 -0700 |
commit | b63687b0f84902a6e51d78496a3ff13e7963fa97 (patch) | |
tree | bb6a70d66f84ac3c30859f6efcd6d58f8ea98144 /numpy/core | |
parent | 977431a6355dfff2ade73f4ea1543598d26c7154 (diff) | |
download | numpy-b63687b0f84902a6e51d78496a3ff13e7963fa97.tar.gz |
BUG:warn on Nan in minimum,maximum for scalars
Diffstat (limited to 'numpy/core')
-rw-r--r-- | numpy/core/src/umath/loops.c.src | 8 | ||||
-rw-r--r-- | numpy/core/tests/test_umath.py | 6 |
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 95107b538..8afd5a1fa 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): |