diff options
| author | Charles Harris <charlesr.harris@gmail.com> | 2015-10-21 09:13:57 -0600 |
|---|---|---|
| committer | Charles Harris <charlesr.harris@gmail.com> | 2015-10-21 09:13:57 -0600 |
| commit | ec436fd83e9fb487f095c63dae66eacb66ebc914 (patch) | |
| tree | b3de2495813e8cb7a4d5ed5e649ec29f65e69cbe | |
| parent | 299a31533ffe4d0f63c92d6b1590cc60dc0690fe (diff) | |
| parent | 8da9c711446a5f2dc5b7ec400358ccdd208055fc (diff) | |
| download | numpy-ec436fd83e9fb487f095c63dae66eacb66ebc914.tar.gz | |
Merge pull request #6538 from jjhelmus/ma_fix_shrink
BUG: ma.masked_values does not shrink mask if requested
| -rw-r--r-- | numpy/ma/core.py | 4 | ||||
| -rw-r--r-- | numpy/ma/tests/test_core.py | 5 |
2 files changed, 7 insertions, 2 deletions
diff --git a/numpy/ma/core.py b/numpy/ma/core.py index 698416579..4ea52d0ab 100644 --- a/numpy/ma/core.py +++ b/numpy/ma/core.py @@ -1544,7 +1544,7 @@ def make_mask(m, copy=False, shrink=True, dtype=MaskType): dtype=[('man', '|b1'), ('mouse', '|b1')]) """ - if m is nomask: + if m is nomask and shrink: return nomask elif isinstance(m, ndarray): # We won't return after this point to make sure we can shrink the mask @@ -2247,7 +2247,7 @@ def masked_values(x, value, rtol=1e-5, atol=1e-8, copy=True, shrink=True): else: condition = umath.equal(xnew, value) mask = nomask - mask = mask_or(mask, make_mask(condition, shrink=shrink)) + mask = mask_or(mask, make_mask(condition, shrink=shrink), shrink=shrink) return masked_array(xnew, mask=mask, copy=copy, fill_value=value) diff --git a/numpy/ma/tests/test_core.py b/numpy/ma/tests/test_core.py index f832ee60d..0a9821254 100644 --- a/numpy/ma/tests/test_core.py +++ b/numpy/ma/tests/test_core.py @@ -1145,6 +1145,11 @@ class TestMaskedArrayArithmetic(TestCase): a /= 1. assert_equal(a.mask, [0, 0, 0]) + def test_noshink_on_creation(self): + # Check that the mask is not shrunk on array creation when not wanted + a = np.ma.masked_values([1., 2.5, 3.1], 1.5, shrink=False) + assert_equal(a.mask, [0, 0, 0]) + def test_mod(self): # Tests mod (x, y, a10, m1, m2, xm, ym, z, zm, xf) = self.d |
