From 01a9081e7791f19d65f73e623a5dfeec52243be3 Mon Sep 17 00:00:00 2001 From: Julian Taylor Date: Sat, 29 Jun 2013 17:02:53 +0200 Subject: 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) --- numpy/core/numeric.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'numpy/core/numeric.py') 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): """ -- cgit v1.2.1