diff options
author | rubiales <arubiales11@gmail.com> | 2021-06-25 19:53:48 +0200 |
---|---|---|
committer | Sebastian Berg <sebastian@sipsolutions.net> | 2021-07-12 15:32:19 -0500 |
commit | 8c67e22bd9b6152d1bddeb5db9ac2ea562581297 (patch) | |
tree | 915cd1a4c993f9464ef646a20f7428da8bbb213e /numpy | |
parent | 963caf0bf1d2b23efb60109b8c909b3078359cf6 (diff) | |
download | numpy-8c67e22bd9b6152d1bddeb5db9ac2ea562581297.tar.gz |
Fix 1 test_umath and npy_math_internal
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/core/src/npymath/npy_math_internal.h.src | 14 | ||||
-rw-r--r-- | numpy/core/tests/test_umath.py | 4 |
2 files changed, 17 insertions, 1 deletions
diff --git a/numpy/core/src/npymath/npy_math_internal.h.src b/numpy/core/src/npymath/npy_math_internal.h.src index c22ac5186..14892562c 100644 --- a/numpy/core/src/npymath/npy_math_internal.h.src +++ b/numpy/core/src/npymath/npy_math_internal.h.src @@ -423,6 +423,13 @@ NPY_INPLACE @type@ npy_@kind@@c@(@type@ x, @type@ y) NPY_INPLACE @type@ npy_@kind@@c@(@type@ x, @type@ y) { + int are_inputs_inf = (npy_isinf(x) && npy_isinf(y)); + + if (are_inputs_inf || !y) { + if (!npy_isnan(x)) { + npy_set_floatstatus_invalid(); + } + } return (@type@) npy_@kind@((double)x, (double) y); } #endif @@ -508,6 +515,13 @@ NPY_INPLACE @type@ npy_@kind@@c@(@type@ x, @type@ y) NPY_INPLACE @type@ npy_@kind@@c@(@type@ x, @type@ y) { + int are_inputs_inf = (npy_isinf(x) && npy_isinf(y)); + + if (are_inputs_inf || !y) { + if (!npy_isnan(x)) { + npy_set_floatstatus_invalid(); + } + } return @kind@@c@(x, y); } #endif diff --git a/numpy/core/tests/test_umath.py b/numpy/core/tests/test_umath.py index 6d97c640f..64357974b 100644 --- a/numpy/core/tests/test_umath.py +++ b/numpy/core/tests/test_umath.py @@ -461,7 +461,8 @@ class TestDivision: with np.errstate(invalid='raise'): assert_no_warnings(FloatingPointError, np.floor_divide, fnan, fone) assert_no_warnings(FloatingPointError, np.floor_divide, fone, fnan) - assert_raises(FloatingPointError, np.floor_divide, fnan, fzer) + assert_no_warnings(FloatingPointError, np.floor_divide, fnan, fzer) + assert_no_warnings(FloatingPointError, np.floor_divide, fzer, fnan) @pytest.mark.parametrize('dtype', np.typecodes['Float']) def test_floor_division_corner_cases(self, dtype): @@ -590,6 +591,7 @@ class TestRemainder: with np.errstate(invalid='raise'): assert_raises(FloatingPointError, fn, fone, fzero) assert_no_warnings(FloatingPointError, fn, fnan, fzero) + assert_no_warnings(FloatingPointError, fn, fzero, fnan) assert_no_warnings(FloatingPointError, fn, fone, fnan) assert_no_warnings(FloatingPointError, fn, fnan, fone) |