Navigation Menu

Skip to content
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

Regression: np.ma.masked_values(..., shrink=True) no longer works #11112

Closed
lpsinger opened this issue May 17, 2018 · 6 comments
Closed

Regression: np.ma.masked_values(..., shrink=True) no longer works #11112

lpsinger opened this issue May 17, 2018 · 6 comments

Comments

@lpsinger
Copy link
Contributor

The documentation for np.ma.masked_values() explains the role of the shrink option (which defaults to True) as follows:

Whether to collapse a mask full of False to nomask.

In Numpy <= 1.13.3, this works correctly:

$ python -c 'import numpy as np; print(repr(np.ma.masked_values(np.arange(10.0), -1)))'
masked_array(data = [ 0.  1.  2.  3.  4.  5.  6.  7.  8.  9.],
             mask = False,
       fill_value = -1.0)

In Numpy >= 1.14.0 and on master, it is broken:

$ python -c 'import numpy as np; print(repr(np.ma.masked_values(np.arange(10.0), -1)))'
masked_array(data=[0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0],
             mask=[False, False, False, False, False, False, False, False,
                   False, False],
       fill_value=-1.0)
lpsinger added a commit to lpsinger/healpy that referenced this issue May 17, 2018
Numpy's string representation of arrays changed significantly from
1.13 to 1.14. See the [changelog]. We have to set the legacy
representation mode for our doctests to be reproducible across both
old and new versions of Numpy.

There is a lingering issue with the doctest for `hp.reorder` that
is due to a regression in Numpy. See numpy/numpy#11112.

[changelog]: https://docs.scipy.org/doc/numpy-1.14.0/release.html#many-changes-to-array-printing-disableable-with-the-new-legacy-printing-mode
@charris charris added this to the 1.15.0 release milestone May 17, 2018
@charris charris added the 09 - Backport-Candidate PRs tagged should be backported label May 17, 2018
@charris
Copy link
Member

charris commented May 17, 2018

@eric-wieser This looks like yours (and mine :), #10232.

zonca pushed a commit to healpy/healpy that referenced this issue May 17, 2018
Numpy's string representation of arrays changed significantly from
1.13 to 1.14. See the [changelog]. We have to set the legacy
representation mode for our doctests to be reproducible across both
old and new versions of Numpy.

There is a lingering issue with the doctest for `hp.reorder` that
is due to a regression in Numpy. See numpy/numpy#11112.

[changelog]: https://docs.scipy.org/doc/numpy-1.14.0/release.html#many-changes-to-array-printing-disableable-with-the-new-legacy-printing-mode
@eric-wieser
Copy link
Member

This looks like a bug in np.ma.array(..., shrink=True) that was never previously exposed.

@eric-wieser
Copy link
Member

So, the shrink argument to np.ma.array is documented as:

Whether to force compression of an empty mask. Default is True.

This is only used in exactly one case - when shrink=True, keep_mask=False, it means "don't expand nomask to an array of zeros"

This is super-specific, and not a reasonable interpretation of the documentation.

So I think that we can probably add back the shrinking to masked_values, but we should deprecate the argument to MaskedArray.__new__, since it's probably used only ever in error.

@charris
Copy link
Member

charris commented Jun 8, 2018

We need to make a decision here. Just marking for future reference.

@charris
Copy link
Member

charris commented Jun 10, 2018

@eric-wieser Could you make a PR with your suggestion here?

eric-wieser added a commit to eric-wieser/numpy that referenced this issue Jun 10, 2018
@charris
Copy link
Member

charris commented Jun 10, 2018

Looks like this changed because the keepdims default value is True

@charris charris removed the 09 - Backport-Candidate PRs tagged should be backported label Sep 18, 2018
charris pushed a commit to charris/numpy that referenced this issue Sep 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants