diff options
author | Pedro Lacerda <pslacerda@gmail.com> | 2016-09-14 19:58:28 -0300 |
---|---|---|
committer | Pedro Lacerda <pslacerda@gmail.com> | 2016-09-15 23:48:33 -0300 |
commit | 455bfa51510dcf2d03dbc0bbef618c710667910d (patch) | |
tree | e2276bc94d8180dad37130e79049eb489090c539 | |
parent | c90d7c94fd2077d0beca48fa89a423da2b0bb663 (diff) | |
download | numpy-455bfa51510dcf2d03dbc0bbef618c710667910d.tar.gz |
BUG: Clear signaling NaN exceptions
Closes gh-7838
-rw-r--r-- | numpy/core/src/umath/loops.c.src | 3 | ||||
-rw-r--r-- | numpy/core/src/umath/simd.inc.src | 2 | ||||
-rw-r--r-- | numpy/core/tests/test_umath.py | 6 |
3 files changed, 9 insertions, 2 deletions
diff --git a/numpy/core/src/umath/loops.c.src b/numpy/core/src/umath/loops.c.src index 2720c361f..cc1c4f30e 100644 --- a/numpy/core/src/umath/loops.c.src +++ b/numpy/core/src/umath/loops.c.src @@ -1645,6 +1645,7 @@ NPY_NO_EXPORT void *((npy_bool *)op1) = @func@(in1) != 0; } } + npy_clear_floatstatus(); } /**end repeat1**/ @@ -1982,6 +1983,7 @@ HALF_@kind@(char **args, npy_intp *dimensions, npy_intp *steps, void *NPY_UNUSED const npy_half in1 = *(npy_half *)ip1; *((npy_bool *)op1) = @func@(in1) != 0; } + npy_clear_floatstatus(); } /**end repeat**/ @@ -2464,6 +2466,7 @@ NPY_NO_EXPORT void const @ftype@ in1i = ((@ftype@ *)ip1)[1]; *((npy_bool *)op1) = @func@(in1r) @OP@ @func@(in1i); } + npy_clear_floatstatus(); } /**end repeat1**/ diff --git a/numpy/core/src/umath/simd.inc.src b/numpy/core/src/umath/simd.inc.src index 5da87ef60..8a799fe61 100644 --- a/numpy/core/src/umath/simd.inc.src +++ b/numpy/core/src/umath/simd.inc.src @@ -643,8 +643,6 @@ sse2_@kind@_@TYPE@(npy_bool * op, @type@ * ip1, npy_intp n) LOOP_BLOCKED_END { op[i] = npy_@kind@(ip1[i]) != 0; } - /* silence exceptions from comparisons */ - npy_clear_floatstatus(); } /**end repeat1**/ diff --git a/numpy/core/tests/test_umath.py b/numpy/core/tests/test_umath.py index a800de918..970bf0628 100644 --- a/numpy/core/tests/test_umath.py +++ b/numpy/core/tests/test_umath.py @@ -2156,5 +2156,11 @@ def test_rint_big_int(): assert_equal(val, np.rint(val)) +def test_signaling_nan_exceptions(): + with assert_no_warnings(): + a = np.ndarray(shape=(), dtype='float32', buffer=b'\x00\xe0\xbf\xff') + np.isnan(a) + + if __name__ == "__main__": run_module_suite() |