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

Stéfan van der Walt stefan at sun.ac.za
Mon Aug 11 18:49:06 EDT 2008


2008/8/11 Charles Doutriaux <doutriaux1 at 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