[Numpy-discussion] Understanding np.min behaviour with nan
Robert Kern
robert.kern at gmail.com
Wed Jan 10 18:21:27 EST 2018
On Wed, Jan 10, 2018 at 3:03 PM, Andrew Nelson <andyfaff at gmail.com> wrote:
>
> Further to my last message, why is the warning only raised once?
>
> ```
> >>> import numpy as np
> >>> np.min([1, np.nan])
>
/Users/andrew/miniconda3/envs/dev3/lib/python3.6/site-packages/numpy/core/_methods.py:29:
RuntimeWarning: invalid value encountered in reduce
> return umr_minimum(a, axis, None, out, keepdims)
> nan
> >>> np.min([1, np.nan])
> nan
> >>>
> ```
This is default behavior for warnings.
https://docs.python.org/3/library/warnings.html#the-warnings-filter
It also explains the previous results. The same warning would have been
issued from the same place in each of the variations you tried. Since the
warnings mechanism had already seen that RuntimeWarning with the same
message from the same code location, they were not printed.
--
Robert Kern
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20180110/3cc39dc0/attachment.html>
More information about the NumPy-Discussion
mailing list