Skip to content

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

Closed
wants to merge 1 commit into from

Conversation

charris
Copy link
Member

@charris charris commented May 2, 2015

Closes #5826.

@charris
Copy link
Member Author

charris commented May 2, 2015

Putting this up for comment. It needs tests and can be made more efficient.

@charris
Copy link
Member Author

charris commented Jan 8, 2016

@mhvk Thoughts?


if isinstance(mask.dtype.type, np.void):
needmask = np.any(np.ones(1, mask.dtype) == mask)
Copy link
Contributor

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)

Copy link
Contributor

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:

@mhvk
Copy link
Contributor

mhvk commented Jan 8, 2016

@charris - see my single comment. I do think this is the right way to go.

@eric-wieser
Copy link
Member

eric-wieser commented Feb 19, 2017

Just realized that this overlaps a bunch with my fixes in #8647 for #8600

@mhvk
Copy link
Contributor

mhvk commented Mar 11, 2017

@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?

@charris
Copy link
Member Author

charris commented Mar 12, 2017

@mhvk Best to go with the active PR, so I'll close this.

@charris charris closed this Mar 12, 2017
@charris charris deleted the fix-ma-where-for-structures branch May 2, 2020 17:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ma.where does not work with structured types.
3 participants