Skip to content

MAINT: Cleanup ma.array.__str__ #9768

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 3 commits into from
Sep 27, 2017
Merged

Conversation

eric-wieser
Copy link
Member

Remove hack from gh-7659 for gh-7493

Working with 0d arrays is enough here
This means that large void arrays are now truncated as they are for other types, for speed.
@eric-wieser
Copy link
Member Author

Clumsy mistake first time around on that last commit. All passing now.

@eric-wieser
Copy link
Member Author

Actually, this is a bugfix. Before (1.13):

>>> x = np.ma.array((1, '2006'), dtype=[('a', int), ('b', 'M8[Y]')])
>>> x
masked_array(data = (1, '2006'),
             mask = (False, False),
       fill_value = (999999, 'NaT'),
            dtype = [('a', '<i4'), ('b', '<M8[Y]')])

>>> x['a'] = np.ma.masked
>>> x
masked_array(data = (--, datetime.date(2006, 1, 1)),
             mask = ( True, False),
       fill_value = (999999, 'NaT'),
            dtype = [('a', '<i4'), ('b', '<M8[Y]')])

After

In [1]: x = np.ma.array((1, '2006'), dtype=[('a', int), ('b', 'M8[Y]')])

In [2]: x
Out[2]:
masked_array(data = (1, datetime.date(2006, 1, 1)),
             mask = (False, False),
       fill_value = (999999, 'NaT'),
            dtype = [('a', '<i4'), ('b', '<M8[Y]')])

In [3]: x['a'] = np.ma.masked

In [4]: x
Out[4]:
masked_array(data = (--, datetime.date(2006, 1, 1)),
             mask = ( True, False),
       fill_value = (999999, 'NaT'),
            dtype = [('a', '<i4'), ('b', '<M8[Y]')])

Although part of that is probably the 0d scalar stuff, and that'll likely change again with #9332

Copy link
Contributor

@mhvk mhvk left a comment

Choose a reason for hiding this comment

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

Look all OK.

@charris
Copy link
Member

charris commented Sep 26, 2017

@mhvk Feel free to merge ...

@ahaldane
Copy link
Member

Give me a few minutes to finish looking at this.. I started yesterday but there are updates since then.

for name in names:
(curdata, curmask) = (result[name], mask[name])
if curdata.dtype.names:
if names:
Copy link
Member

Choose a reason for hiding this comment

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

technically not necessary since this function is always called with names (or else the old code would fail). Fine to leave it.

Copy link
Member

Choose a reason for hiding this comment

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

OK, I get that this was intentional based on reorganization below.

Copy link
Member

@ahaldane ahaldane left a comment

Choose a reason for hiding this comment

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

All right, looks good.

@eric-wieser
Copy link
Member Author

Two approvals for a MAINT sounds like a good enough excuse to self-merge to me.

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.

4 participants