[Numpy-discussion] Question about masked arrays

Gökhan Sever gokhansever@gmail....
Mon Sep 20 15:23:34 CDT 2010

On Mon, Sep 20, 2010 at 1:05 PM, Robert Kern <robert.kern@gmail.com> 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
array type.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20100920/36bc84e0/attachment.html 

More information about the NumPy-Discussion mailing list