[Numpy-discussion] min() of array containing NaN
Pierre GM
pgmdevlist@gmail....
Mon Aug 11 18:41:39 CDT 2008
*cough* MaskedArrays anyone ? *cough*
The ideal would be for min/max to output a NaN when there's a NaN somewhere.
That way, you'd know that there's a potential pb in your data, and that you
should use the nanfunctions or masked arrays.
is there a page on the wiki for that matter ? It seems to show up regularly...
On Monday 11 August 2008 18:49:06 Stéfan van der Walt wrote:
> 2008/8/11 Charles Doutriaux <doutriaux1@llnl.gov>:
> > Seems to me like min should automagically call nanmin if it spots any
> > nan no ?
>
> Nanmin is quite a bit slower:
>
> In [2]: x = np.random.random((5000))
>
> In [3]: timeit np.min(x)
> 10000 loops, best of 3: 24.8 µs per loop
>
> In [4]: timeit np.nanmin(x)
> 10000 loops, best of 3: 136 µs per loop
>
> So, I'm not sure if that will happen. One option is to use `nanmin`
> by default, and to provide `min` for people who need the speed. The
> fact that results with nan's are almost always unexpected is certainly
> a valid concern.
>
> Cheers
> Stéfan
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion@scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
More information about the Numpy-discussion
mailing list