[SciPy-user] allclose friend
lorenzo bolla
lbolla at gmail.com
Fri Jan 11 03:44:07 EST 2008
What do you expect to be handled NaN?
It looks like allclose() gives False with NaN, because NaN==NaN is always
False.
Shouldn't it use numpy.isnan?
Can't you use simply == to obtain a boolean array?
In [21]: x
Out[21]: array([ 1., 2., Inf, NaN])
In [22]: y
Out[22]: array([ 1., 0., Inf, NaN])
In [23]: z
Out[23]: array([ 1., 2., Inf, NaN])
In [24]: x == y
Out[24]: array([ True, False, True, False], dtype=bool)
In [25]: x == z
Out[25]: array([ True, True, True, False], dtype=bool)
In [26]: numpy.allclose(x,y)
Out[26]: False
In [27]: numpy.allclose(x,z)
Out[27]: False
L.
On 1/11/08, Tom Johnson <tjhnson at gmail.com> wrote:
>
> On Jan 10, 2008 6:02 PM, Tom Johnson <tjhnson at gmail.com> wrote:
> > allclose() is neat in that it handles the 'special' cases of inf and
> > nan. Does there exist a similar function close()? That is, I want to
> > do elementwise float comparisons of two arrays (returning an array of
> > booleans)...and I want all the special cases to be handled. It seems
> > like this should be an obvious function. There are enough lines in
> > allclose() that I don't want to have to reimplement it everytime on my
> > own.
> >
>
> I know I can just loop through the arrays calling allclose on
> singlets, but is this the preferred way to do it?
> _______________________________________________
> SciPy-user mailing list
> SciPy-user at scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-user
>
--
Lorenzo Bolla
lbolla at gmail.com
http://lorenzobolla.emurse.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20080111/922e07ae/attachment.html>
More information about the SciPy-User
mailing list