Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: masked array division should ignore all FPEs in mask calculation #26135

Merged
merged 2 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
7 changes: 7 additions & 0 deletions numpy/ma/tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2581,6 +2581,13 @@ 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):
x = np.arange(0, 3, 0.1)
X = np.ma.array(x)
with np.errstate(under="raise"):
X2 = X/2.0
np.testing.assert_array_equal(X2, x/2)

class TestMaskedArrayInPlaceArithmetic:
# Test MaskedArray Arithmetic

Expand Down