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

Charles R Harris charlesr.harris at gmail.com
Thu Jan 11 11:51:21 EST 2018


On Wed, Jan 10, 2018 at 5:24 PM, Andrew Nelson <andyfaff at gmail.com> wrote:

> > 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
>

Different compilers/libraries respond differently to nans. If the change in
scipy is recent, probably compiler flags or something similar has changed
in the test environment.

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20180111/141750d9/attachment.html>


More information about the NumPy-Discussion mailing list