[Numpy-discussion] Error in allclose with inf values
Matthew Brett
matthew.brett at gmail.com
Sun Aug 19 07:57:50 EDT 2007
Hi again,
> I noticed that allclose does not always behave correctly for arrays with infs.
Sorry, perhaps I should have been more specific; this is the behavior
of allclose that I was referring to (documented in the tests I
attached):
In [6]:N.allclose([N.inf, 1, 2], [10, 10, N.inf])
Out[6]:array([ True], dtype=bool)
In [7]:N.allclose([N.inf, N.inf, N.inf], [10, 10, N.inf])
Warning: invalid value encountered in subtract
Out[7]:True
In [9]:N.allclose([N.inf, N.inf], [10, 10])
---------------------------------------------------------------------------
exceptions.AttributeError Traceback (most
recent call last)
/home/mb312/<ipython console>
/home/mb312/lib/python2.4/site-packages/numpy/core/numeric.py in
allclose(a, b, rtol, atol)
843 d3 = (x[xinf] == y[yinf])
844 d4 = (~xinf & ~yinf)
--> 845 if d3.size < 2:
846 if d3.size==0:
847 return False
AttributeError: 'bool' object has no attribute 'size'
Matthew
More information about the NumPy-Discussion
mailing list