-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
BUG: MaskedArray with bytes dtype cannot be compared if fill_value is set #21770
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
Comments
Perhaps we should just back out #21041 for 1.23. It was a bit of a rush to backport it for the Numba folks and that may have been too optimistic. |
Sorry, I had not realized there was so much oddity digging into those failures :(! There are two main things going on:
(may be pretty harmless on its own, but makes this a lot more confusing!)
Now, that fill-value doesn't make sense for ufuncs that return a boolean output probably. There is at least one more change:
My preference is that for the main branch, we aim for fixing the two issues:
For 1.23, I guess revering is the way to go. Fixing this seems like it would require both of the above fixes, and after that is gone there is still a tiny chance of subtleties around |
Actually, maybe the error sanitizing mainly toggles between So it might just be the second one (plus another fixup) on main. |
Now I am wondering if we should just add a special case to (I clearly should sleep on this :)): Lines 453 to 465 in c2db91c
But of course, this becomes an obstacle course. The fill value is:
and the reason for the failure is that:
(just like casting) fails because it wants to interpret it as a number to cast... So in the sense, the very long path to why this failure even occurs, is that our string to bool cast is still arguably broken :). |
I cannot tell if this bug also causes all these other failures at https://github.com/astropy/astropy/runs/6918680788?check_suite_focus=true but the traceback suggests something about ufunc . If some are caused by other bugs, I can open new issues. Please let me know. Thanks! xref astropy/astropy#13332 (comment) p.s. We also see failures downstream of astropy that uses |
Oh wow, I thought I had even run the astropy test-suite, but maybe the I suspect all (or almost all) of them are related to gh-21437. That PR makes sure that we add warnings for all cast operations, that means basically things like: np.array([np.nan]).astype(int) # will give an "invalid value" RuntimeWarnig.
np.array([3e300]).astype(np.float32) # will give an "overflow" RuntimeWarning If the warning is raised, maybe the unit machinery will then think that a conversion is invalid (rather than overflowing?). Lets continue on the astropy issue (don't hesitate to ping me there) or a new issue? |
NOTE: I realize there is a bit of a "double" influx, but this change has of course nothing to do with the upcoming NumPy 1.23. |
Just to confirm that these new bugs are unrelated to 1.23 and to this issue. |
@seberg - nice sleuthing on the issue. Though why is this now triggered and not before? |
@mhvk ah, sorry... because before In [2]: import numpy as np
In [3]: ma = np.ma.MaskedArray(["a", "b"])
In [4]: ma > ma
Out[4]: array([False, False]) |
I suppose the one "fix" short of reverting would be to convert the input arrays to bare NumPy arrays ahead of calling into |
It sounds to me like it is best to hash this out for 1.24... |
This defines the comparison operators (other than `==` and `!=`) explicitly for masked arrays. The mask is ignored for the resuling `res._data` (unlike `==` and `!=` which take the mask into account. Closes numpygh-21770, although the way that masked arrays propagate the fill-value seems generally broken and error prone.
This defines the comparison operators (other than `==` and `!=`) explicitly for masked arrays. The mask is ignored for the resuling `res._data` (unlike `==` and `!=` which take the mask into account. Closes numpygh-21770, although the way that masked arrays propagate the fill-value seems generally broken and error prone.
Describe the issue:
Astropy is having a number of test failures as a result of #21041. Some are just due to the new
FutureWarning
, which are fine. But some are due to something rather strange - thatMaskedArray
comparisons depend on whetherfill_value
is set.Reproduce the code example:
ma._fill_value = None
ma > ma
masked_array(data=[False, False],
mask=False,
fill_value=True)
Error message:
No response
NumPy/Python version information:
1.24.0.dev0+185.g4cb688938 3.10.5 (main, Jun 8 2022, 09:26:22) [GCC 11.3.0]
The text was updated successfully, but these errors were encountered: