BUG: masked array division should ignore all FPEs in mask calculation#26135
BUG: masked array division should ignore all FPEs in mask calculation#26135seberg merged 2 commits intonumpy:mainfrom
Conversation
fc2111f to
c30dd94
Compare
numpy/ma/tests/test_core.py
Outdated
| allclose(m, 0.5) | ||
|
|
||
| def test_masked_array_underflow(self): | ||
| np.seterr(under="raise") |
There was a problem hiding this comment.
Please make sure to use with np.errstate(), this will otherwise affect later tests randomly. Otherwise, LGTM, no need to insert those newlines, but they seem fine.
There was a problem hiding this comment.
Thanks for the feedback, I'll send right away the new PR
c30dd94 to
e940868
Compare
|
Hi @seberg , I've fixed the test as you requested and also removed the extra spaces that I forgot to remove before. |
numpy/ma/tests/test_core.py
Outdated
| X = np.ma.array(x) | ||
| x2 = x/2.0 # <- works | ||
| X2 = X/2.0 | ||
| assert(X2.all() == X.all() / 2.0) |
There was a problem hiding this comment.
What does this assert test?
There was a problem hiding this comment.
The purpose is to make sure that the division occured fine without the multiply underflow error
numpy/ma/tests/test_core.py
Outdated
|
|
||
| def test_masked_array_underflow(self): | ||
| with(np.errstate(under="raise")): | ||
| x = np.arange(0, 3, 0.1) |
There was a problem hiding this comment.
Maybe move this line and the next two or of the with context, as the test is about the masked array.
There was a problem hiding this comment.
Ok i'll do so
e940868 to
3d47b3f
Compare
numpy/ma/tests/test_core.py
Outdated
| X = np.ma.array(x) | ||
| with(np.errstate(under="raise")): | ||
| X2 = X/2.0 | ||
| assert(X2.all() == X.all() / 2.0) |
There was a problem hiding this comment.
| assert(X2.all() == X.all() / 2.0) | |
| np.testing.assert_array_equal(X2, x/2) |
The X.all() and X2.all() are both False. Perhaps you wanted to write assert np.all(X2==x/2.0)?
There was a problem hiding this comment.
Thank you for the correction, at the time I wasn't 100% sure how I would test the value of the array but I'll change to that as it makes more sense.
3d47b3f to
3b252c5
Compare
|
Hi @seberg @eendebakpt, is everything correct now in the new PR? |
This PR fixes the bug #25810 where an internal multiplication underflow occured with np.seterr(under="raise")