[Numpy-discussion] `allclose` vs `assert_allclose`

Ralf Gommers ralf.gommers at gmail.com
Wed Jul 16 14:47:24 EDT 2014


On Wed, Jul 16, 2014 at 6:37 AM, Tony Yu <tsyu80 at gmail.com> wrote:

> Is there any reason why the defaults for `allclose` and `assert_allclose`
> differ? This makes debugging a broken test much more difficult. More
> importantly, using an absolute tolerance of 0 causes failures for some
> common cases. For example, if two values are very close to zero, a test
> will fail:
>
>     np.testing.assert_allclose(0, 1e-14)
>
> Git blame suggests the change was made in the following commit, but I
> guess that change only reverted to the original behavior.
>
>
> https://github.com/numpy/numpy/commit/f43223479f917e404e724e6a3df27aa701e6d6bf
>

Indeed, was reverting a change that crept into
https://github.com/numpy/numpy/commit/f527b49a


>
> It seems like the defaults for  `allclose` and `assert_allclose` should
> match, and an absolute tolerance of 0 is probably not ideal. I guess this
> is a pretty big behavioral change, but the current default for
> `assert_allclose` doesn't seem ideal.
>

I agree, current behavior quite annoying. It would make sense to change the
atol default to 1e-8, but technically it's a backwards compatibility break.
Would probably have a very minor impact though. Changing the default for
rtol in one of the functions may be much more painful though, I don't think
that should be done.

Ralf
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20140716/cbd274e5/attachment.html>


More information about the NumPy-Discussion mailing list