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

Gregorio Bastardo gregorio.bastardo at gmail.com
Mon Jul 15 12:41:17 EDT 2013


> Ouch…
> Quick workaround:  use `x.harden_mask()` *then* `x.mask.flags.writeable=False`

Thanks for the update and the detailed explanation. I'll try this trick.

> This may change in the future, depending on a yet-to-be-achieved consensus on  the definition of 'least-surprising behaviour'. Right now, the *-like functions return an array that shares the mask with the input, as you've noticed. Some people complained about it, what's your take on that?

I already took part in the survey (possibly out of thread):
http://mail.scipy.org/pipermail/numpy-discussion/2013-July/067136.html

> You were not missing anything, np.ma isn't the most straightforward module: plenty of corner cases, and the implementation is pretty naive at times (but hey, it works). My only advice is to never lose hope.

I agree there are plenty of hard-to-define cases, and I came accross a
hot debate on missing data representation in python:
https://github.com/njsmith/numpy/wiki/NA-discussion-status

but still I believe np.ma is very usable when compression is not
strongly needed.



More information about the NumPy-Discussion mailing list