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

Gregorio Bastardo gregorio.bastardo at gmail.com
Fri Jul 12 10:41:04 EDT 2013


Hi,

I use masked arrays to mark missing values in data and found it very
convenient, although sometimes counterintuitive.

I'd like to make a pool of masked arrays (shared between several
processing steps) read-only (both data and mask property) to protect
the arrays from accidental modification (and the array users from
hours of debugging). The regular ndarray trick

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).

Could you recommend an easy way to set an ma read-only?

Thanks,
Gregorio



More information about the NumPy-Discussion mailing list