diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2018-08-01 13:22:34 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-01 13:22:34 -0500 |
commit | 76d74c3834868c60338fd7e2c24ed21ff0006806 (patch) | |
tree | 46b2391c20e26f28ef045335c3e515e8c3a15883 /numpy/core | |
parent | b72d52a464661a224d6672789a85e8965eae19ca (diff) | |
parent | b63687b0f84902a6e51d78496a3ff13e7963fa97 (diff) | |
download | numpy-76d74c3834868c60338fd7e2c24ed21ff0006806.tar.gz |
Merge pull request #11595 from mattip/warn-scalar-minimum
BUG:warn on Nan in minimum,maximum for scalars, float16
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 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): |