[Numpy-discussion] Question about masked arrays
Mon Sep 20 15:23:34 CDT 2010
On Mon, Sep 20, 2010 at 1:05 PM, Robert Kern <firstname.lastname@example.org> wrote:
> Are you asking about when masked arrays are casted to ndarrays (and
> thus losing the mask information)? Most times when a function uses
> asarray() or array() to explicitly cast the inputs to an ndarray. The
> reason that np.mean() gives the same result as np.ma.mean() is that it
> simply defers to the .mean() method on the object, so it works as
> expected on a masked array. Many other functions will not.
> Robert Kern
Right guess. It is important for me to able to preserve masked array
properties of an array. Otherwise losing the mask information yields
unexpected results in some of my calculations. I could see from np.mean??
that mean function is indeed the object method. Also in /numpy/ma there is a
conversion for np.zeros(). I guess in any case it is the user's
responsibility to make sure that the operations are performed on a desired
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion