Skip to content

MAINT: Cleanup ma.array.__str__ - #9768

Merged
eric-wieser merged 3 commits into
numpy:masterfrom
eric-wieser:ma-str-cleanup
Sep 27, 2017
Merged

eric-wieser merged 3 commits into
numpy:masterfrom
eric-wieser:ma-str-cleanup

Conversation

@eric-wieser

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

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

@eric-wieser

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

@mhvk mhvk left a comment

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.

Look all OK.

@charris

charris commented Sep 26, 2017

Copy link
Copy Markdown
Member

@mhvk Feel free to merge ...

@ahaldane

Copy link
Copy Markdown
Member

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

Comment thread numpy/ma/core.py
for name in names:
(curdata, curmask) = (result[name], mask[name])
if curdata.dtype.names:
if names:

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.

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

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.

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

@ahaldane ahaldane left a comment

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.

All right, looks good.

@eric-wieser

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