Skip to content

BUG: construct ma.array from np.array which contains padding - #7790

Closed
ahaldane wants to merge 1 commit into
numpy:masterfrom
ahaldane:fix_ma_descr
Closed

ahaldane wants to merge 1 commit into
numpy:masterfrom
ahaldane:fix_ma_descr

Conversation

@ahaldane

Copy link
Copy Markdown
Member

Structured dtypes with padding bytes fail in MaskedArrays because of padding bytes in dtype.descr. Fix is to avoid using dtype.descr.

This is a followup/alternate implementation of #7788.

Comment thread numpy/ma/core.py Outdated

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 am curious how you thought to use .base here, rather than the dtype directly. I can imagine why it might be a good idea, just wondering if you had explicit rationale for it.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It is because of subarrays, and I should probably add a comment explaining that. The idea is to drop the subarray part and get just the type, because that is what the old code did:

The old code did currentdescr = descr[1], and remember that descr has the form (name, type, shape), so that would drop the shape. In the same way doing .base drops the shape.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Acutally, using .subdtype will be clearer, I'll do that instead.

@jzwinck

jzwinck commented Jun 30, 2016

Copy link
Copy Markdown
Contributor

Looks good.

@charris charris added this to the 1.11.2 release milestone Jun 30, 2016
@ahaldane
ahaldane force-pushed the fix_ma_descr branch 2 times, most recently from fa48468 to 78b8209 Compare June 30, 2016 18:00
Comment thread numpy/ma/tests/test_core.py Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Line looks too long.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In Tweety Bird voice, "It is, it is too long".

@charris

charris commented Jul 25, 2016

Copy link
Copy Markdown
Member

Using dtype as a argument name is a bit confusing as it shadows the actual type. Looks harmless here and is done elsewhere, but...

@charris

charris commented Jul 25, 2016

Copy link
Copy Markdown
Member

Might also add docstrings to the functions.

Structured dtypes with padding bytes fail in MaskedArrays
because of padding bytes in `dtype.descr`.

Fix is to avoid using dtype.descr.
@ahaldane

Copy link
Copy Markdown
Member Author

Thanks @charris, updated.

@charris

charris commented Jul 28, 2016

Copy link
Copy Markdown
Member

Nitpick: Sentences begin with a capital and end with a period.

@charris

charris commented Aug 3, 2016

Copy link
Copy Markdown
Member

Fixed up the capitalization in #7894, so closing this. Thanks Allan.

@charris charris closed this Aug 3, 2016
@charris charris removed this from the 1.11.2 release milestone Aug 20, 2016
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.

3 participants