Skip to content

Revert line from #4585 to get mask, data shapes to match in .flat - #4615

Merged
charris merged 1 commit into
numpy:masterfrom
mhvk:ma/matrix-flat-redo-shape
Apr 12, 2014
Merged

charris merged 1 commit into
numpy:masterfrom
mhvk:ma/matrix-flat-redo-shape

Conversation

@mhvk

@mhvk mhvk commented Apr 12, 2014

Copy link
Copy Markdown
Contributor

@charris -- this reverts the shape assignment and adds a test for the problematic matrix masked array example that you gave in #4585. Now, as expected:

n [1]: import numpy as np; from numpy.ma import MaskedArray

In [2]: a = MaskedArray(np.matrix(np.eye(3)), mask=0)

In [3]: a
Out[3]: 
masked_matrix(data =
 [[1.0 0.0 0.0]
 [0.0 1.0 0.0]
 [0.0 0.0 1.0]],
              mask =
 [[False False False]
 [False False False]
 [False False False]],
        fill_value = 1e+20)


In [4]: a.flat[:2]
Out[4]: 
masked_matrix(data =
 [[1.0 0.0]],
              mask =
 [[False False]],
        fill_value = 1e+20)

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.

Should not use docstrings in tests, use comments #... instead. It makes the nose output more readable.

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.

Note that we haven't yet fixed all tests for this, especially the corroded antiquities. Software years are so very short...

@mhvk

mhvk commented Apr 12, 2014

Copy link
Copy Markdown
Contributor Author

@charris -- ok, changed docstring to comment (these are astropy habits coming through -- there, the request is the opposite).

I do still hope to get to changing MaskedArray to use the new __numpy_ufunc__, but best to work in small steps.

@charris

charris commented Apr 12, 2014

Copy link
Copy Markdown
Member

Fast. LGTM pending travis.

charris added a commit that referenced this pull request Apr 12, 2014
Revert line from #4585 to get mask, data shapes to match in .flat
@charris
charris merged commit 61c699e into numpy:master Apr 12, 2014
@charris

charris commented Apr 12, 2014

Copy link
Copy Markdown
Member

Merged, thanks Marten.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants