[Numpy-discussion] read-only or immutable masked array

Stéfan van der Walt stefan at sun.ac.za
Fri Jul 12 11:45:30 EDT 2013

On Fri, Jul 12, 2013 at 4:41 PM, Gregorio Bastardo
<gregorio.bastardo at gmail.com> wrote:
> array.flags.writeable = False
> is perfectly fine, but it does not work on ma-s. Moreover, mask
> hardening only protects masked elements, and does not raise error (as
> I'd expect).

You probably have to modify the underlying array and mask:

x = np.ma.array(...)
x.mask.flags.writeable = False
x.data.flags.writeable = False


More information about the NumPy-Discussion mailing list