summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
Diffstat (limited to 'numpy')
-rw-r--r--numpy/ma/core.py9
-rw-r--r--numpy/ma/tests/test_core.py11
2 files changed, 16 insertions, 4 deletions
diff --git a/numpy/ma/core.py b/numpy/ma/core.py
index 87082d139..b9f7da092 100644
--- a/numpy/ma/core.py
+++ b/numpy/ma/core.py
@@ -1495,9 +1495,10 @@ def make_mask(m, copy=False, shrink=True, dtype=MaskType):
shrink : bool, optional
Whether to shrink `m` to ``nomask`` if all its values are False.
dtype : dtype, optional
- Data-type of the output mask. By default, the output mask has
- a dtype of MaskType (bool). If the dtype is flexible, each field
- has a boolean dtype.
+ Data-type of the output mask. By default, the output mask has a
+ dtype of MaskType (bool). If the dtype is flexible, each field has
+ a boolean dtype. This is ignored when `m` is ``nomask``, in which
+ case ``nomask`` is always returned.
Returns
-------
@@ -1547,7 +1548,7 @@ def make_mask(m, copy=False, shrink=True, dtype=MaskType):
dtype=[('man', '|b1'), ('mouse', '|b1')])
"""
- if m is nomask and shrink:
+ if m is nomask:
return nomask
elif isinstance(m, ndarray):
# We won't return after this point to make sure we can shrink the mask
diff --git a/numpy/ma/tests/test_core.py b/numpy/ma/tests/test_core.py
index 61fd77bda..e5fdfddb1 100644
--- a/numpy/ma/tests/test_core.py
+++ b/numpy/ma/tests/test_core.py
@@ -11,8 +11,10 @@ __author__ = "Pierre GF Gerard-Marchant"
import warnings
import pickle
import operator
+import itertools
from functools import reduce
+
import numpy as np
import numpy.ma.core
import numpy.core.fromnumeric as fromnumeric
@@ -3816,6 +3818,15 @@ class TestMaskedArrayFunctions(TestCase):
assert_equal(test.dtype, bdtype)
assert_equal(test, np.array([(0, 0), (0, 1)], dtype=bdtype))
+ # test that nomask is returned when m is nomask.
+ bools = [True, False]
+ dtypes = [MaskType, np.float]
+ msgformat = 'copy=%s, shrink=%s, dtype=%s'
+ for cpy, shr, dt in itertools.product(bools, bools, dtypes):
+ res = make_mask(nomask, copy=cpy, shrink=shr, dtype=dt)
+ assert_(res is nomask, msgformat % (cpy, shr, dt))
+
+
def test_mask_or(self):
# Initialize
mtype = [('a', np.bool), ('b', np.bool)]