summaryrefslogtreecommitdiff
path: root/numpy/ma
diff options
context:
space:
mode:
authorMarten van Kerkwijk <mhvk@astro.utoronto.ca>2018-05-26 21:37:30 -0400
committerGitHub <noreply@github.com>2018-05-26 21:37:30 -0400
commit09e108dc3453cbca17a80e75f5ec2b941e5b8137 (patch)
treebfa8455af77b0a0846f54e9e4efe511f80333b4c /numpy/ma
parent69503ff29819727df6d81847e6646c5fe8dc1a95 (diff)
parent5c1e7ae50d6242ce1f04d1a6482a85f443b6bc1e (diff)
downloadnumpy-09e108dc3453cbca17a80e75f5ec2b941e5b8137.tar.gz
Merge pull request #11120 from eric-wieser/simplify-ma-ctor
MAINT: remove redundant code in MaskedArray.__new__
Diffstat (limited to 'numpy/ma')
-rw-r--r--numpy/ma/core.py15
1 files changed, 4 insertions, 11 deletions
diff --git a/numpy/ma/core.py b/numpy/ma/core.py
index c0dda6f31..17682d13f 100644
--- a/numpy/ma/core.py
+++ b/numpy/ma/core.py
@@ -2799,13 +2799,8 @@ class MaskedArray(ndarray):
# FIXME _sharedmask is never used.
_sharedmask = True
# Process mask.
- # Number of named fields (or zero if none)
- names_ = _data.dtype.names or ()
# Type of the mask
- if names_:
- mdtype = make_mask_descr(_data.dtype)
- else:
- mdtype = MaskType
+ mdtype = make_mask_descr(_data.dtype)
if mask is nomask:
# Case 1. : no mask in input.
@@ -2831,14 +2826,12 @@ class MaskedArray(ndarray):
_data._mask = mask
_data._sharedmask = False
else:
+ _data._sharedmask = not copy
if copy:
_data._mask = _data._mask.copy()
- _data._sharedmask = False
# Reset the shape of the original mask
if getmask(data) is not nomask:
data._mask.shape = data.shape
- else:
- _data._sharedmask = True
else:
# Case 2. : With a mask in input.
# If mask is boolean, create an array of True or False
@@ -2875,7 +2868,7 @@ class MaskedArray(ndarray):
_data._mask = mask
_data._sharedmask = not copy
else:
- if names_:
+ if _data.dtype.names:
def _recursive_or(a, b):
"do a|=b on each field of a, recursively"
for name in a.dtype.names:
@@ -2884,7 +2877,7 @@ class MaskedArray(ndarray):
_recursive_or(af, bf)
else:
af |= bf
- return
+
_recursive_or(_data._mask, mask)
else:
_data._mask = np.logical_or(mask, _data._mask)