summaryrefslogtreecommitdiff
path: root/numpy/ma/core.py
diff options
context:
space:
mode:
authorpierregm <pierregm@localhost>2009-01-07 18:14:12 +0000
committerpierregm <pierregm@localhost>2009-01-07 18:14:12 +0000
commit949fe033fac5c6b555fd9b2b8212005cc5bfe1fd (patch)
treeee9dd37a6fef108bf48dd6782edff9710f6706e5 /numpy/ma/core.py
parentc5137ea1a63bd721dd47bb2a5d588d161d0e9b76 (diff)
downloadnumpy-949fe033fac5c6b555fd9b2b8212005cc5bfe1fd.tar.gz
* Fixed iadd/isub/imul when the base array has no mask but the other array does
Diffstat (limited to 'numpy/ma/core.py')
-rw-r--r--numpy/ma/core.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/numpy/ma/core.py b/numpy/ma/core.py
index 4a9a75024..a012b197e 100644
--- a/numpy/ma/core.py
+++ b/numpy/ma/core.py
@@ -2331,7 +2331,9 @@ class MaskedArray(ndarray):
"Add other to self in-place."
m = getmask(other)
if self._mask is nomask:
- self._mask = m
+ if m is not nomask and m.any():
+ self._mask = make_mask_none(self.shape, self.dtype)
+ self._mask += m
else:
if m is not nomask:
self._mask += m
@@ -2342,7 +2344,9 @@ class MaskedArray(ndarray):
"Subtract other from self in-place."
m = getmask(other)
if self._mask is nomask:
- self._mask = m
+ if m is not nomask and m.any():
+ self._mask = make_mask_none(self.shape, self.dtype)
+ self._mask += m
elif m is not nomask:
self._mask += m
ndarray.__isub__(self._data, np.where(self._mask, 0, getdata(other)))
@@ -2352,7 +2356,9 @@ class MaskedArray(ndarray):
"Multiply self by other in-place."
m = getmask(other)
if self._mask is nomask:
- self._mask = m
+ if m is not nomask and m.any():
+ self._mask = make_mask_none(self.shape, self.dtype)
+ self._mask += m
elif m is not nomask:
self._mask += m
ndarray.__imul__(self._data, np.where(self._mask, 1, getdata(other)))
@@ -3701,7 +3707,7 @@ def _mareconstruct(subtype, baseclass, baseshape, basetype,):
"""
_data = ndarray.__new__(baseclass, baseshape, basetype)
- _mask = ndarray.__new__(ndarray, baseshape, 'b1')
+ _mask = ndarray.__new__(ndarray, baseshape, make_mask_descr(basetype))
return subtype.__new__(subtype, _data, mask=_mask, dtype=basetype,)