Permalink
Browse files

When accessing MaskedArray rows, always return an mvoid object

  • Loading branch information...
1 parent fe6f42c commit 7caac2efd9b2c9ccf4b886fc6273c9ebbcd6c9da @astrofrog committed Oct 11, 2012
Showing with 4 additions and 6 deletions.
  1. +4 −6 numpy/ma/core.py
View
@@ -2948,12 +2948,10 @@ def __getitem__(self, indx):
# A record ................
if isinstance(dout, np.void):
mask = _mask[indx]
-# If we can make mvoid a subclass of np.void, that'd be what we'd need
-# return mvoid(dout, mask=mask)
- if flatten_mask(mask).any():
- dout = mvoid(dout, mask=mask)
- else:
- return dout
+ # We should always re-cast to mvoid, otherwise users can
+ # change masks on rows that already have masked values, but not
+ # on rows that have no masked values, which is inconsistent.
+ dout = mvoid(dout, mask=mask)
# Just a scalar............
elif _mask is not nomask and _mask[indx]:
return masked

0 comments on commit 7caac2e

Please sign in to comment.