On Jul 13, 2013, at 13:36 , Gregorio Bastardo <gregorio.bastardo@gmail.com> wrote:
Hi Stéfan,
Thanks for the suggestion, but it does not protect the array:
Thinking about it, it can't: when `x` is a MaskedArray, `x.data` is just a view of the underlying array as a regular ndarray. As far as I understand, changing the `.flags` of a view doesn't affect the original. I'm a bit surprised, though. Here's what I tried
np.version.version <<< 1.7.0 x = np.ma.array([1,2,3], mask=[0,1,0]) x.flags.writeable=False x[0]=-1 <<< ValueError: assignment destination is read-only
What did you mean by
array.flags.writeable = False
is perfectly fine, but it does not work on ma-s.
? Could you post what you did and what you got?
Moreover, mask hardening only protects masked elements, and does not raise error (as I'd expect).
Yes, that's how it supposed to work.