Hi Stéfan, Thanks for the suggestion, but it does not protect the array:
x = np.ma.masked_array(xrange(4), [0,1,0,1]) x masked_array(data = [0 -- 2 --], mask = [False True False True], fill_value = 999999) x.mask.flags.writeable = False x.data.flags.writeable = False x.data.flags.writeable True x.mask.flags.writeable False x[0] = -1 x masked_array(data = [-1 -- 2 --], mask = [False True False True], fill_value = 999999)
Is there a working solution for this problem? Thanks, Gregorio 2013/7/12 Stéfan van der Walt <stefan@sun.ac.za>:
On Fri, Jul 12, 2013 at 4:41 PM, Gregorio Bastardo <gregorio.bastardo@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
Stéfan _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion