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
np.random.choice returns out of range index on masked array prob. #17088
Comments
The issue also occurs in
|
Earlier I added the "bug" label, but that's a subjective judgement. There are other functions in numpy that don't handle masked arrays correctly (or better, "correctly", since "correctness" can also be a judgement call) where we don't necessarily consider it a bug. Perhaps this is just an example of undefined behavior, and the short answer for the issue is "don't do that!". It would be nicer, however, if we could raise an exception instead of returning nonsensical results. It would be easy enough to add an explicit check for a masked array, and raise an error if any of the values are actually masked, but that feels like a very specific, ad hoc fix. |
Does If it does, then I think we just throw this in with all the other "maskedarray decays because we haven't implemented |
I think if it doesn't handle it correctly, it shouldn't allow passing masked array (should raise an exception) but works correct mostly (it works well except some cases). it may cause potential issues for production environment. |
There is no use of |
If you add |
It shouldn't returns an index > 3, but when the last element of masked array is true, it may return index = 4
The text was updated successfully, but these errors were encountered: