[SciPy-user] nan?

Joshua Petterson joshuafr at gmail.com
Thu Nov 30 09:01:44 CST 2006


About ma, I have sometimes this message from scipy.stats (on the first runs):
/usr/lib/python2.4/site-packages/numpy/core/ma.py:604: UserWarning:
Cannot automatically convert masked array to numeric because data
    is masked in one or more locations.
It not breaks results, but why this warning (I use 1.e-20 as fill_value)?

2006/11/30, Robert Kern <robert.kern at gmail.com>:
> Joshua Petterson wrote:
> > Hi Robert,
> > thanks for these precisions. I don't want to start a troll in this
> > m-l, but why numpy doesn't understand nan and masked_values together?
> > And a mix of them doen't work:
> > |~|[40]>ma.masked_values([1,2,nan],nan).mean()
> > Out [40]:array(nan)
> > |~|[41]>ma.masked_object([1,2,nan],nan).mean()
> > Out [41]:array(nan)
>
> That would be the "nan != nan" feature of the little buggers at work.
>
> > Then, if I have missing values in my datas, what can I do? I cannot
> > compute on nan, and numpy.ma doesn't recognize it. I could use isnan
> > to find them, but what's that?:
> > |~|[48]>a=[1,2,nan]
> > |~|[49]>b=ma.array(a,mask=isnan(a))
> > |~|[50]>b
> > Out [50]:
> > array(data =
> >  [  1.00000000e+00   2.00000000e+00   1.00000000e+20],
> >       mask =
> >  [False False True],
> >       fill_value=1e+20)
> >
> > nan becomes 1e+20!!! Good precision :-)
>
> That's the default fill value. Don't worry about it. Change it back to nan if
> you like using the fill_value keyword argument. It only affects display and any
> users of the .filled() method (which will probably demand some other specific
> fill value depending on the application).
>
> --
> Robert Kern
>
> "I have come to believe that the whole world is an enigma, a harmless enigma
>  that is made terrible by our own mad attempt to interpret it as though it had
>  an underlying truth."
>   -- Umberto Eco
> _______________________________________________
> SciPy-user mailing list
> SciPy-user at scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-user
>


More information about the SciPy-user mailing list