[Numpy-discussion] Understanding np.min behaviour with nan

Andrew Nelson andyfaff at gmail.com
Wed Jan 10 19:24:25 EST 2018


> The same warning would have been issued from the same place in each of
the variations you tried.

That's not the case, I tried with np.min([1, 2, 3, np.nan]) in a fresh
interpreter and no warning was raised.

Furthermore on my work computer (conda python3.6.2 with pip installed
numpy) I can't get the problem to show at all:

>>> import numpy as np
>>> np.version.version
'1.14.0'
>>> np.min([1., 2., 3., 4., np.nan])
nan
>>> np.min([1., 2., 3., np.nan, 4.])
nan
>>> np.min([1., 2., np.nan, 3., 4.])
nan
>>> np.min([1., np.nan, 2., 3., 4.])
nan
>>> np.min([np.nan, 1., 2., 3., 4.])
nan
>>> np.min([np.nan, 1.])
nan
>>> np.min([np.nan, 1., np.nan])
nan
>>> np.min([1., np.nan])
nan
>>> np.seterr(all='raise')
{'divide': 'warn', 'over': 'warn', 'under': 'ignore', 'invalid': 'warn'}
>>> np.min([1., np.nan])
nan
>>> np.min([np.nan, 1.])
nan
>>> np.min([np.nan, 1., 2., 3., 4.])
nan
>>> np.min([np.nan, 1., 2., 3., 4.])
nan


The context for these questions is the sudden CI fails I'm observing for
scipy on appveyor -
https://ci.appveyor.com/project/scipy/scipy/build/1.0.1444/job/n05ptntm0xxjklvt
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20180111/115c2e63/attachment-0001.html>


More information about the NumPy-Discussion mailing list