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 /doc/release | |
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 'doc/release')
-rw-r--r-- | doc/release/1.17.0-notes.rst | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/doc/release/1.17.0-notes.rst b/doc/release/1.17.0-notes.rst index 71ad17673..5307da3ba 100644 --- a/doc/release/1.17.0-notes.rst +++ b/doc/release/1.17.0-notes.rst @@ -66,6 +66,16 @@ zero:: >>> np.zeros(10)//1 array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]) +``MaskedArray.mask`` now returns a view of the mask, not the mask itself +------------------------------------------------------------------------ +Returning the mask itself was unsafe, as it could be reshaped in place which +would violate expectations of the masked array code. It's behavior is now +consistent with the ``.data`` attribute, which also returns a view. + +The underlying mask can still be accessed with ``._mask`` if it is needed. +Tests that contain ``assert x.mask is not y.mask`` or similar will need to be +updated. + Do not lookup ``__buffer__`` attribute in `numpy.frombuffer` ------------------------------------------------------------ Looking up ``__buffer__`` attribute in `numpy.frombuffer` was undocumented and |