You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried to change the mask of a through a subindexed view, but was unable. Using this setup I can reproduce this in the 1.9.1 version of NumPy.
import numpy as np
a = np.arange(6).reshape(2,3)
a = np.ma.masked_array(a, mask=np.ma.getmaskarray(a), shrink=False)
b = a[1:2,1:2]
c = np.zeros(b.shape, b.dtype)
c = np.ma.masked_array(c, mask=np.ma.getmaskarray(c), shrink=False)
c[:] = np.ma.masked
This yields what one would expect for a, b, and c (seen below).
@jakirkham, In your example code, I don't understand why you expect a.mask to be changed. The masks for all three arrays a, b, and c are False everywhere. Is the example missing a line such as c.mask[:] = True?
FWIW, If I insert that line, then I do indeed see the issue reported here. If I assign to a view of a masked array, the data values are updated in both the view and the original array (of course). But the mask is only properly updated in the view, not the original array.
System details:
numpy 1.9.1
python 2.7.9 (installed via Anaconda)
Mac OS 10.7.5
@stuarteberg Yes, sorry. You are correct I was missing such a line.
Generally, the documentation recommends one to assign as so c[:] = np.ma.masked. However, as we have ensured the mask is simply an array, it is also mentioned that you can do c.mask[:] = True as you have.
). I don't understand why only fields of masked record arrays can share masks, but nothing else. Is there something special we want to avoid in record arrays? If so, couldn't we accomplish this without ruining the possibility of editing views on an ordinary masked array?
Activity
lazyflow/stype.py: Added a workaround for copying NumPy masked arrays…
lazyflow/slot.py: Added a workaround for copying NumPy masked arrays …
lazyflow/operators/opArrayCache.py: Workaround issues using masked ar…
lazyflow/stype.py: Added a workaround for copying NumPy masked arrays…
lazyflow/slot.py: Added a workaround for copying NumPy masked arrays …
lazyflow/operators/opArrayCache.py: Workaround issues using masked ar…
stuarteberg commentedon Feb 13, 2015
@jakirkham, In your example code, I don't understand why you expect
a.maskto be changed. The masks for all three arraysa,b, andcareFalseeverywhere. Is the example missing a line such asc.mask[:] = True?FWIW, If I insert that line, then I do indeed see the issue reported here. If I assign to a view of a masked array, the data values are updated in both the view and the original array (of course). But the mask is only properly updated in the view, not the original array.
System details:
numpy 1.9.1
python 2.7.9 (installed via Anaconda)
Mac OS 10.7.5
jakirkham commentedon Feb 13, 2015
@stuarteberg Yes, sorry. You are correct I was missing such a line.
Generally, the documentation recommends one to assign as so
c[:] = np.ma.masked. However, as we have ensured the mask is simply an array, it is also mentioned that you can doc.mask[:] = Trueas you have.jakirkham commentedon Feb 14, 2015
This code seems to stop propagation of the mask and it is not clear to me why this is necessary (
numpy/numpy/ma/core.py
Lines 3129 to 3132 in 4bfcf48
jakirkham commentedon Feb 14, 2015
Same situation here (
numpy/numpy/ma/core.py
Lines 3112 to 3113 in 4bfcf48
lazyflow/stype.py: Added a workaround for copying NumPy masked arrays…
lazyflow/slot.py: Added a workaround for copying NumPy masked arrays …
lazyflow/operators/opArrayCache.py: Workaround issues using masked ar…
lazyflow/stype.py: Added a workaround for copying NumPy masked arrays…
13 remaining items
lazyflow/slot.py: Added a workaround for copying NumPy masked arrays …
lazyflow/operators/opArrayCache.py: Workaround issues using masked ar…
lazyflow/stype.py: Added a workaround for copying NumPy masked arrays…
lazyflow/slot.py: Added a workaround for copying NumPy masked arrays …
lazyflow/operators/opArrayCache.py: Workaround issues using masked ar…
jjhelmus commentedon Oct 21, 2015
This issue was also reported in #1903.
Merge pull request #5580 from jakirkham/fix_masked_array_views
jakirkham commentedon Dec 4, 2017
Should this issue be added to 1.14.0 milestone (as that is where the fix landed)?
charris commentedon Dec 4, 2017
Once it is in it doesn't matter. We don't rely on the milestone tag except to mark something as a potential release blocker.