8000 BUG: np.ma.astype fails on structured types by eric-wieser · Pull Request #9322 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

BUG: np.ma.astype fails on structured types #9322

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

Merged
merged 1 commit into from
Jun 28, 2017

Conversation

eric-wieser
Copy link
Member
@eric-wieser eric-wieser commented Jun 27, 2017
>>> x = array(([1, 2, 3], (1.0,)), dtype=descr)
>>> x
masked_array(data = ([1, 2, 3], (1.0,)),
             mask = ([False, False, False], (False,)),
       fill_value = ([999999, 999999, 999999], (  1.00000000e+20,)),
            dtype = [('v', '<i4', (3,)), ('x', [('y', '<f8')])])

>>> x.astype(x.dtype)
masked_array(data = (array([1, 2, 3]), --),
             mask = (False,  True),
       fill_value = (999999, (  1.00000000e+20,)),
            dtype = [('v', '<i4', (3,)), ('x', [('y', '<f8')])])

Note the mask is the wrong type.

The fill value is also wrong, but that's a different problem (#9303)

if self._mask is nomask:
output._mask = nomask
else:
output._mask = self._mask.astype([(n, bool) for n in names])
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Iterating over names without recursion should always raise alarm bells

@ahaldane
Copy link
Member

Yes, this one also LGTM. Will merge next time I look at it.

@ahaldane
Copy link
Member

Merging, Thanks Eric.

@ahaldane ahaldane merged commit 0767d38 into numpy:master Jun 28, 2017
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.

2 participants
0