[Numpy-discussion] atol in allclose

Charles R Harris charlesr.harris at gmail.com
Tue Nov 28 21:36:06 CST 2006


On 11/28/06, Robert Kern <robert.kern at gmail.com> wrote:
>
> Matthew Brett wrote:
> > Hi,
> >
> > Sorry to keep cluttering the list, but I was a bit surprised by this
> > behavior of allclose:
> >
> > In [25]:allclose([1.0], [1.0], rtol=0)
> > Out[25]:True
> >
> > In [26]:allclose([1.0], [1.0], rtol=0, atol=0)
> > Out[26]:False
> >
> > The docstring seems to imply that atol will not be used in this
> > comparison - or did I misunderstand?
>
> The docstring is a somewhat loose interpretation of the actual
> implementation.
> You've exposed a corner case. The long and the short of it is this:
>
>     d = less(absolute(x-y), atol + rtol * absolute(y))
>
> rtol was never intended to be less than the epsilon of your chosen
> floating
> point type much less 0. That's what == is for.
>
> That said, less() should probably be less_equal(), and the docstring can
> be
> clearly describe what is going on.


I think that's right. Do you want to make the change?

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20061128/c985209d/attachment-0001.html 


More information about the Numpy-discussion mailing list