Skip to content

Commit

Permalink
BUG: masked array division broken with np.seterr(under=raise) #25810
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosilva10260 committed Mar 27, 2024
1 parent c369433 commit e940868
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion numpy/ma/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -877,7 +877,7 @@ def __call__(self, a, b):
self.tolerance = np.finfo(float).tiny
# don't call ma ufuncs from __array_wrap__ which would fail for scalars
a, b = np.asarray(a), np.asarray(b)
with np.errstate(invalid='ignore'):
with np.errstate(all='ignore'):
return umath.absolute(a) * self.tolerance >= umath.absolute(b)


Expand Down
8 changes: 8 additions & 0 deletions numpy/ma/tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2581,6 +2581,14 @@ def test_no_masked_nan_warnings(self):
# also check that allclose uses ma ufuncs, to avoid warning
allclose(m, 0.5)

def test_masked_array_underflow(self):
with(np.errstate(under="raise")):
x = np.arange(0, 3, 0.1)
X = np.ma.array(x)
x2 = x/2.0 # <- works
X2 = X/2.0
assert(X2.all() == X.all() / 2.0)

class TestMaskedArrayInPlaceArithmetic:
# Test MaskedArray Arithmetic

Expand Down

0 comments on commit e940868

Please sign in to comment.