diff options
author | Julian Taylor <jtaylor.debian@googlemail.com> | 2013-06-29 17:02:53 +0200 |
---|---|---|
committer | Julian Taylor <jtaylor.debian@googlemail.com> | 2013-07-08 23:40:17 +0200 |
commit | 01a9081e7791f19d65f73e623a5dfeec52243be3 (patch) | |
tree | 56dccd21a5ab8e433fc251a82c844ba45b0abc3b /numpy/core/numeric.py | |
parent | cfe411b6cccb177003c99fb780917f97f4be38e9 (diff) | |
download | numpy-01a9081e7791f19d65f73e623a5dfeec52243be3.tar.gz |
ENH: vectorize boolean comparisons of floats
the new code will more often propagate the invalid floating point
exception if comparing against nan, so allclose now ignores it (but
still returns False)
Diffstat (limited to 'numpy/core/numeric.py')
-rw-r--r-- | numpy/core/numeric.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py index 12b23cb83..13ee89744 100644 --- a/numpy/core/numeric.py +++ b/numpy/core/numeric.py @@ -2124,7 +2124,12 @@ def allclose(a, b, rtol=1.e-5, atol=1.e-8): x = x[~xinf] y = y[~xinf] - return all(less_equal(abs(x-y), atol + rtol * abs(y))) + # ignore invalid fpe's + with warnings.catch_warnings(): + warnings.simplefilter("ignore") + r = all(less_equal(abs(x-y), atol + rtol * abs(y))) + + return r def isclose(a, b, rtol=1.e-5, atol=1.e-8, equal_nan=False): """ |