summaryrefslogtreecommitdiff
path: root/numpy/ma
diff options
context:
space:
mode:
authorEric Wieser <wieser.eric@gmail.com>2018-06-10 11:09:57 -0700
committerEric Wieser <wieser.eric@gmail.com>2018-06-10 11:09:57 -0700
commit51dc6f4064a4eae2bae764de1579e009160b9a84 (patch)
tree6fc525ba4432df01b4bee7ee5f35ad0c8b785b6c /numpy/ma
parent3bb11d6f1758e4d3d6ca812749cc5145f82713b3 (diff)
downloadnumpy-51dc6f4064a4eae2bae764de1579e009160b9a84.tar.gz
BUG: Undo behavior change in ma.masked_values(shrink=True)
This change was introduced as part of #10232 Fixes #11112
Diffstat (limited to 'numpy/ma')
-rw-r--r--numpy/ma/core.py6
-rw-r--r--numpy/ma/tests/test_core.py6
2 files changed, 10 insertions, 2 deletions
diff --git a/numpy/ma/core.py b/numpy/ma/core.py
index 5ed086db3..091ab4e20 100644
--- a/numpy/ma/core.py
+++ b/numpy/ma/core.py
@@ -2319,8 +2319,10 @@ def masked_values(x, value, rtol=1e-5, atol=1e-8, copy=True, shrink=True):
mask = np.isclose(xnew, value, atol=atol, rtol=rtol)
else:
mask = umath.equal(xnew, value)
- return masked_array(
- xnew, mask=mask, copy=copy, fill_value=value, shrink=shrink)
+ ret = masked_array(xnew, mask=mask, copy=copy, fill_value=value)
+ if shrink:
+ ret.shrink_mask()
+ return ret
def masked_invalid(a, copy=True):
diff --git a/numpy/ma/tests/test_core.py b/numpy/ma/tests/test_core.py
index 51616f214..67a9186a8 100644
--- a/numpy/ma/tests/test_core.py
+++ b/numpy/ma/tests/test_core.py
@@ -4904,6 +4904,12 @@ class TestMaskedWhereAliases(object):
res = np.ma.masked_values(np.inf, -np.inf)
assert_equal(res.mask, False)
+ res = np.ma.masked_values([1, 2, 3, 4], 5, shrink=True)
+ assert_(res.mask is np.ma.nomask)
+
+ res = np.ma.masked_values([1, 2, 3, 4], 5, shrink=False)
+ assert_equal(res.mask, [False] * 4)
+
def test_masked_array():
a = np.ma.array([0, 1, 2, 3], mask=[0, 0, 1, 0])