summaryrefslogtreecommitdiff
path: root/numpy/core/numeric.py
diff options
context:
space:
mode:
authorTravis Oliphant <oliphant@enthought.com>2007-05-17 10:37:08 +0000
committerTravis Oliphant <oliphant@enthought.com>2007-05-17 10:37:08 +0000
commit50894958e9a8f515ed85c27127cd91a784eb8308 (patch)
tree57f89b87c486b367909c5dd069c8e9e3b5a4b0b5 /numpy/core/numeric.py
parent5b4e40b73703617f8d24c6b4162f6777eaa176a1 (diff)
downloadnumpy-50894958e9a8f515ed85c27127cd91a784eb8308.tar.gz
Fix some bugs with isposinf and isneginf as well as with how allclose dealt with infinities. See ticket #519
Diffstat (limited to 'numpy/core/numeric.py')
-rw-r--r--numpy/core/numeric.py11
1 files changed, 9 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):