[Numpy-discussion] min() of array containing NaN

Stéfan van der Walt stefan@sun.ac...
Mon Aug 11 17:49:06 CDT 2008


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


More information about the Numpy-discussion mailing list