Skip to content

BUG/TST: Fix #6760 by correctly describing mask on nested subdtypes #6761

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

Conversation

gerritholl
Copy link
Contributor

Fix #6760. In ma.core._recursive_make_descr, consider the case where a
subdtype does itself have named fields. This ensures the correct mask for
an array like ma.zeros(2, dtype([("A", "(2,2)i1,(2,2)i1", (2,2))])).

@gerritholl gerritholl force-pushed the structured_nested_masked_array_maskfill branch from 8d82fe9 to 8c1e3e0 Compare December 3, 2015 16:43
Fix numpy#6760.  In ma.core._recursive_make_descr, consider the case where a
subdtype does itself have named fields.  This ensures the correct mask for
an array like `ma.zeros(2, dtype([("A", "(2,2)i1,(2,2)i1", (2,2))]))`.
@gerritholl gerritholl force-pushed the structured_nested_masked_array_maskfill branch from 8c1e3e0 to c8a0982 Compare December 3, 2015 16:53
@@ -1248,7 +1248,7 @@ def _recursive_make_descr(datatype, newtype=bool_):
# Is this some kind of composite a la (np.float,2)
elif datatype.subdtype:
mdescr = list(datatype.subdtype)
mdescr[0] = newtype
mdescr[0] = _recursive_make_descr(datatype.subdtype[0], newtype)
Copy link
Member

Choose a reason for hiding this comment

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

Out of curiosity, why always the 0 index?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@charris Because a subdtype is a tuple (item_dtype, shape). The shape does not change, but the item_dtype does.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the explanation.

charris added a commit that referenced this pull request Dec 3, 2015
…ay_maskfill

BUG/TST: Fix #6760 by correctly describing mask on nested subdtypes
@charris charris merged commit d69d51c into numpy:master Dec 3, 2015
@charris
Copy link
Member

charris commented Dec 3, 2015

LGTM, thanks @gerritholl .

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