Skip to content

BUG: Make ma.where work with structured types. - #5827

Closed
charris wants to merge 1 commit into
numpy:masterfrom
charris:fix-ma-where-for-structures
Closed

charris wants to merge 1 commit into
numpy:masterfrom
charris:fix-ma-where-for-structures

Conversation

@charris

@charris charris commented May 2, 2015

Copy link
Copy Markdown
Member

Closes #5826.

@charris

charris commented May 2, 2015

Copy link
Copy Markdown
Member Author

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

@charris

charris commented Jan 8, 2016

Copy link
Copy Markdown
Member Author

@mhvk Thoughts?

Comment thread numpy/ma/core.py

Copy link
Copy Markdown
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
Copy Markdown
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

mhvk commented Jan 8, 2016

Copy link
Copy Markdown
Contributor

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

@eric-wieser

eric-wieser commented Feb 19, 2017 •

Copy link
Copy Markdown
Member

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

@mhvk

mhvk commented Mar 11, 2017

Copy link
Copy Markdown
Contributor

@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

charris commented Mar 12, 2017

Copy link
Copy Markdown
Member Author

@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