-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
BUG: Make ma.where work with structured types. #5827
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
Conversation
Putting this up for comment. It needs tests and can be made more efficient. |
@mhvk Thoughts? |
|
||
if isinstance(mask.dtype.type, np.void): | ||
needmask = np.any(np.ones(1, mask.dtype) == mask) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this would mean that if there is a record in which only one element is masked, needmask would be False
. If so, you'd want
needmask = not np.all(np.zeros(1, mask.dtype) == mask)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at this again afresh, I think this comment is indeed correct: if one does equality for a record mask, all elements are considered for each item, so we only can dispense with the mask if all items have no elements masked.
Note that I think the if-statement can be if mask.dtype.names:
@charris - see my single comment. I do think this is the right way to go. |
@charris - @eric-wieser has an alternative in #8647 which I think has ended up a bit cleaner. If you think so too, then maybe merge that one and close this one? |
@mhvk Best to go with the active PR, so I'll close this. |
Closes #5826.