diff options
-rw-r--r-- | numpy/core/numeric.py | 11 | ||||
-rw-r--r-- | numpy/lib/ufunclike.py | 2 |
2 files changed, 11 insertions, 2 deletions
diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py index e871c17b0..b628a858d 100644 --- a/numpy/core/numeric.py +++ b/numpy/core/numeric.py @@ -835,8 +835,15 @@ def allclose(a, b, rtol=1.e-5, atol=1.e-8): """ x = array(a, copy=False) y = array(b, copy=False) - d = less_equal(absolute(x-y), atol + rtol * absolute(y)) - return d.ravel().all() + d1 = less_equal(absolute(x-y), atol + rtol * absolute(y)) + xinf = isinf(x) + yinf = isinf(y) + xneg = signbit(x) + yneg = signbit(y) + d2 = (xinf == yinf) + d3 = (xneg == yneg) + d4 = logical_not(d2) + return (d1.all() and not d4.any()) or (d2.all() and d3.all()) def array_equal(a1, a2): diff --git a/numpy/lib/ufunclike.py b/numpy/lib/ufunclike.py index cf014e77d..a8c2c1e25 100644 --- a/numpy/lib/ufunclike.py +++ b/numpy/lib/ufunclike.py @@ -29,6 +29,7 @@ def isposinf(x, y=None): If y is an array, the result replaces the contents of y. """ if y is None: + x = asarray(x) y = empty(x.shape, dtype=nx.bool_) umath.logical_and(isinf(x), ~signbit(x), y) return y @@ -39,6 +40,7 @@ def isneginf(x, y=None): If y is an array, the result replaces the contents of y. """ if y is None: + x = asarray(x) y = empty(x.shape, dtype=nx.bool_) umath.logical_and(isinf(x), signbit(x), y) return y |