Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent FloatingPointError when comparing NaNs #9382

Closed
al626 opened this issue Jul 7, 2017 · 1 comment
Closed

Inconsistent FloatingPointError when comparing NaNs #9382

al626 opened this issue Jul 7, 2017 · 1 comment

Comments

@al626
Copy link

al626 commented Jul 7, 2017

When doing np.seterr(invalid='raise'), FloatingPointErrors are raised when comparing NaNs of array length greater than 1, but not when comparing NaNs of array length equal to 1. It's easiest to see what's happening by looking at the code example:

import numpy as np
np.seterr(invalid='raise')
# {'over': 'warn', 'under': 'ignore', 'invalid': 'warn', 'divide': 'warn'}
np.array([np.nan]) < 0
# array([False], dtype=bool)
np.array([np.nan, np.nan]) < 0
# Traceback (most recent call last):
#   File "<stdin>", line 1, in <module>
# FloatingPointError: invalid value encountered in less

System info:

$ uname -a
Linux a 4.4.0-78-generic #99~14.04.2-Ubuntu SMP Thu Apr 27 18:49:46 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
$ python -c 'import numpy; print numpy.__version__'
1.13.0
$ python --version
Python 2.7.6
@al626
Copy link
Author

al626 commented Jul 7, 2017

dupe of #7352

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants