diff options
author | pierregm <pierregm@localhost> | 2008-08-04 18:05:11 +0000 |
---|---|---|
committer | pierregm <pierregm@localhost> | 2008-08-04 18:05:11 +0000 |
commit | 84dbd03a91eac58006fc5d4bd9d10f23c6a78ca0 (patch) | |
tree | 3b9117659e2c2d900668c71e99c2fb961a45f323 /numpy/ma/core.py | |
parent | ce5fc0af6285ca4ed1478c42c48fd1f6a7909f83 (diff) | |
download | numpy-84dbd03a91eac58006fc5d4bd9d10f23c6a78ca0.tar.gz |
core
MaskedArray.__new__: prevents data.mask to change shape and force a copy of _data.mask
Diffstat (limited to 'numpy/ma/core.py')
-rw-r--r-- | numpy/ma/core.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/numpy/ma/core.py b/numpy/ma/core.py index b4f08171a..c8664c754 100644 --- a/numpy/ma/core.py +++ b/numpy/ma/core.py @@ -1229,6 +1229,9 @@ class MaskedArray(ndarray): _data = np.array(data, dtype=dtype, copy=copy, subok=True, ndmin=ndmin) _baseclass = getattr(data, '_baseclass', type(_data)) _optinfo = {} + # Check that we'ew not erasing the mask.......... + if isinstance(data,MaskedArray) and (data.shape != _data.shape): + copy = True # Careful, cls might not always be MaskedArray... if not isinstance(data, cls) or not subok: _data = _data.view(cls) @@ -1267,6 +1270,9 @@ class MaskedArray(ndarray): 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 # Case 2. : With a mask in input ........ |