diff options
author | Julian Taylor <juliantaylor108@gmail.com> | 2016-09-19 20:16:04 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-19 20:16:04 +0200 |
commit | e1ad72da79a97b0f2209d47d3f7c514ddcb0e8de (patch) | |
tree | c2b36a3c0c5885422a29bb5a0c662be537a80134 /numpy/core | |
parent | 8dff1ca9dbed87b08390c5697e3f3391a746b43b (diff) | |
parent | 455bfa51510dcf2d03dbc0bbef618c710667910d (diff) | |
download | numpy-e1ad72da79a97b0f2209d47d3f7c514ddcb0e8de.tar.gz |
Merge pull request #8051 from pslacerda/clear_snan
Clear signaling NaN exceptions
Diffstat (limited to 'numpy/core')
-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() |