Skip to content

Commit 9704767

Browse files
BUG: masked array division should ignore all FPEs in mask calculation (numpy#26135)
* BUG: masked array division broken with np.seterr(under=raise) numpy#25810 * STY: Remove unnecessary brackets Closes numpygh-25810 --------- Co-authored-by: Sebastian Berg <[email protected]>
1 parent e191a5f commit 9704767

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

numpy/ma/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -877,7 +877,7 @@ def __call__(self, a, b):
877877
self.tolerance = np.finfo(float).tiny
878878
# don't call ma ufuncs from __array_wrap__ which would fail for scalars
879879
a, b = np.asarray(a), np.asarray(b)
880-
with np.errstate(invalid='ignore'):
880+
with np.errstate(all='ignore'):
881881
return umath.absolute(a) * self.tolerance >= umath.absolute(b)
882882

883883

numpy/ma/tests/test_core.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2581,6 +2581,13 @@ def test_no_masked_nan_warnings(self):
25812581
# also check that allclose uses ma ufuncs, to avoid warning
25822582
allclose(m, 0.5)
25832583

2584+
def test_masked_array_underflow(self):
2585+
x = np.arange(0, 3, 0.1)
2586+
X = np.ma.array(x)
2587+
with np.errstate(under="raise"):
2588+
X2 = X/2.0
2589+
np.testing.assert_array_equal(X2, x/2)
2590+
25842591
class TestMaskedArrayInPlaceArithmetic:
25852592
# Test MaskedArray Arithmetic
25862593

0 commit comments

Comments
 (0)