[Numpy-discussion] Question about masked arrays

Gökhan Sever gokhansever@gmail....
Mon Sep 20 16:03:10 CDT 2010


On Mon, Sep 20, 2010 at 3:34 PM, Benjamin Root <ben.root@ou.edu> wrote:

> I have been using masked arrays quite extensively.  My take on them is that
> if a masked array makes sense in that operation, then they should still work
> with the regular functions.  However, there have been many cases where a
> developer used np.asarray() instead of np.asanyarray() for their code, which
> causes the masked array object to lose the mask.  If you encounter such
> situations, it is usually a bug and should be reported.
>

Do you think then in my case assigning the masked array to np.zeros and
getting a non-masked return is a bug or I should make sure that I am
providing a masked array equivalent zeros function before I start
doing computation?

And also if the inner execution could be clarified by asanyarray assertion
why there is ma equivalent array operation functions?


>
> Actually, that reminds me... watch out for np.polyfit() with masked
> arrays.  It doesn't behave quite nicely with masked arrays and the results
> are deceptive.  It may appear to be right, but it is not.  Use
> np.ma.polyfit().
>

Hah, you should see my scipy.optimize.leastsq in action. I estimate
geometric mean and standard deviation parameters for log-normal aerosol
population. It runs, with the values masked and unmasked (from above
np.zeros and np.ma.zeros difference) but resulting all kind interesting
estimates.


>
> Ben Root
>
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
>


-- 
Gökhan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20100920/f7fc7cdb/attachment.html 


More information about the NumPy-Discussion mailing list