summaryrefslogtreecommitdiff
path: root/numpy/core/numeric.py
diff options
context:
space:
mode:
authorTravis Oliphant <oliphant@enthought.com>2007-05-22 09:18:38 +0000
committerTravis Oliphant <oliphant@enthought.com>2007-05-22 09:18:38 +0000
commit4de81d32d97a2efb1023ca0c19e36990f1ba64a4 (patch)
tree0b9abe3d70e3e6407dfc18f6c5fc51794a6dd3a8 /numpy/core/numeric.py
parent1a1f2eac015b2370f8d67989bd17ee29c9d5f89e (diff)
downloadnumpy-4de81d32d97a2efb1023ca0c19e36990f1ba64a4.tar.gz
Fix scalar inf comparison in allclose.
Diffstat (limited to 'numpy/core/numeric.py')
-rw-r--r--numpy/core/numeric.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py
index 0a616582a..b4709b392 100644
--- a/numpy/core/numeric.py
+++ b/numpy/core/numeric.py
@@ -818,10 +818,10 @@ def identity(n, dtype=None):
a = array([1]+n*[0],dtype=dtype)
b = empty((n,n),dtype=dtype)
- # Note that this assignment depends on the convention that since the a array
- # is shorter than the flattened b array, then the a array will be repeated
- # until it is the appropriate size. Given a's construction, this nicely sets
- # the diagonal to all ones.
+ # Note that this assignment depends on the convention that since the a
+ # array is shorter than the flattened b array, then the a array will
+ # be repeated until it is the appropriate size. Given a's construction,
+ # this nicely sets the diagonal to all ones.
b.flat = a
return b
@@ -840,11 +840,12 @@ def allclose(a, b, rtol=1.e-5, atol=1.e-8):
yinf = isinf(y)
if (not xinf.any() and not yinf.any()):
return d1.all()
- d2 = (xinf != yinf)
d3 = (x[xinf] == y[yinf])
d4 = (~xinf & ~yinf)
- if d3.size == 0:
- return False
+ if d3.size < 2:
+ if d3.size==0:
+ return False
+ return d3
if d3.all():
return d1[d4].all()
else: