[Numpy-discussion] arrays comparison issue

David Cournapeau cournape@gmail....
Wed Nov 4 09:07:16 CST 2009


On Wed, Nov 4, 2009 at 11:52 PM, Jean-Luc Menut <jeanluc.menut@free.fr> wrote:
> Hello all,
>
>
>
> If if define 2 variables a and b by doing the following :
>
> on [5]: a
> Out[5]: array([ 1.7])
>
> In [6]: b=array([0.8])+array([0.9])
>
> In [7]: b
> Out[7]: array([ 1.7])
>
>
> if I test the equality of a and b, instead to obatin True, I have :

You should never test for strict equality with floating point numbers
except for particular situations. You should instead test whether they
are close in some sense (up to N decimal, for example).

David


More information about the NumPy-Discussion mailing list