[Numpy-svn] r3772 - in trunk/numpy: core lib
numpy-svn at scipy.org
numpy-svn at scipy.org
Thu May 17 06:37:12 EDT 2007
Author: oliphant
Date: 2007-05-17 05:37:08 -0500 (Thu, 17 May 2007)
New Revision: 3772
Modified:
trunk/numpy/core/numeric.py
trunk/numpy/lib/ufunclike.py
Log:
Fix some bugs with isposinf and isneginf as well as with how allclose dealt with infinities. See ticket #519
Modified: trunk/numpy/core/numeric.py
===================================================================
--- trunk/numpy/core/numeric.py 2007-05-17 10:13:39 UTC (rev 3771)
+++ trunk/numpy/core/numeric.py 2007-05-17 10:37:08 UTC (rev 3772)
@@ -835,8 +835,15 @@
"""
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):
Modified: trunk/numpy/lib/ufunclike.py
===================================================================
--- trunk/numpy/lib/ufunclike.py 2007-05-17 10:13:39 UTC (rev 3771)
+++ trunk/numpy/lib/ufunclike.py 2007-05-17 10:37:08 UTC (rev 3772)
@@ -29,6 +29,7 @@
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 @@
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
More information about the Numpy-svn
mailing list