[Numpy-discussion] A reimplementation of MaskedArray

Michael Sorich michael.sorich at gmail.com
Wed Nov 22 23:01:44 CST 2006


> > Unfortunately if the value is changed to masked, this is not updated
> > in the parent array. This seems very inconsistent. I don't view masked
> > values any different than any other value.
>
> Inconsistent, maybe, useful definitely:
> Masking a view and getting the original masked accordingly could be useful,
> but I strongly feel that unmasking a view and getting an unmasked orginal is
> dangerous.

The use of nan in float ndarrays has behaviour I would consider
expected (at least coming from a numpy perspective). I think that the
closer the maskedarrays mimic the behavior of ndarrays the easier it
will be to remember how to use them and what to expect.

from numpy import *
a = array([[1,2,3,4,5],[1,2,3,4,5],[1,2,3,4,5]], dtype='f')
suba = a[2]
suba[1] = nan
print a
>[[ 1.      2.      3.      4.      5.    ]
> [ 1.      2.      3.      4.      5.    ]
> [ 1.     -1.#IND  3.      4.      5.    ]]
print suba
>[ 1.     -1.#IND  3.      4.      5.    ]

a[2,2] = nan
print a
>[[ 1.      2.      3.      4.      5.    ]
> [ 1.      2.      3.      4.      5.    ]
> [ 1.     -1.#IND -1.#IND  4.      5.    ]]
print suba
>[ 1.     -1.#IND -1.#IND  4.      5.    ]


More information about the Numpy-discussion mailing list