diff options
author | Eric Wieser <wieser.eric@gmail.com> | 2017-12-28 11:17:52 +0000 |
---|---|---|
committer | Eric Wieser <wieser.eric@gmail.com> | 2019-05-11 15:03:24 -0700 |
commit | 599dbade766ad3fecc82afa308803a2e0082c149 (patch) | |
tree | e8076014281d30c3562834252050f9df5c5f1d26 /numpy/ma/core.py | |
parent | 0f19dae081e6678902826b195e0d3857c5b4c2b3 (diff) | |
download | numpy-599dbade766ad3fecc82afa308803a2e0082c149.tar.gz |
API: Make MaskedArray.mask return a view, rather than the underlying mask
This prevents consumers from reshaping the mask in place, which breaks things
As a result, `x.mask is x.mask` returns `False`, but this was already true of `x.data is x.data`.
May also be related to gh-10270
Diffstat (limited to 'numpy/ma/core.py')
-rw-r--r-- | numpy/ma/core.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/numpy/ma/core.py b/numpy/ma/core.py index 90aff6ec8..69fae3512 100644 --- a/numpy/ma/core.py +++ b/numpy/ma/core.py @@ -3449,7 +3449,9 @@ class MaskedArray(ndarray): # We could try to force a reshape, but that wouldn't work in some # cases. - return self._mask + # Return a view so that the dtype and shape cannot be changed in place + # This still preserves nomask by identity + return self._mask.view() @mask.setter def mask(self, value): |