[Numpy-discussion] Adding "maximum difference" to np.testing.assert_array_equal errors

Stephan Hoyer shoyer at gmail.com
Thu Dec 20 00:53:19 EST 2018


OK, it sounds like a popular change :).

I'll add relative error to the message as well. Please comment on the pull
request if you have strong feelings about exactly what it should look like.

On Wed, Dec 19, 2018 at 4:41 PM Juan Nunez-Iglesias <jni.soma at gmail.com>
wrote:

> Another +1 on printing rtol, and +100 (can I do that?) on the overall
> idea! Thanks Stephan!
>
> On Thu, Dec 20, 2018, at 7:27 AM, Christoph Deil wrote:
> >
> >
> > > On 19. Dec 2018, at 19:50, Stefan van der Walt <stefanv at berkeley.edu>
> wrote:
> > >
> > > On Wed, 19 Dec 2018 09:47:01 -0800, Stephan Hoyer wrote:
> > >> Example behavior:
> > >>
> > >>>>> x = np.array([1, 2, 3])
> > >>>>> y = np.array([1, 2, 3.0001])
> > >>>>> np.testing.assert_allclose(x, y)
> > >> AssertionError:
> > >> Not equal to tolerance rtol=1e-07, atol=0
> > >>
> > >> (mismatch 33.333333333333336%, maximum difference
> > >> 0.00010000000000021103)
> > >
> > > This is a helpful addition; thank you!  I don't have a strong
> preference
> > > around whether to also include rtol.
> > >
> > > Stéfan
> > > _______________________________________________
> > > NumPy-Discussion mailing list
> > > NumPy-Discussion at python.org
> > > https://mail.python.org/mailman/listinfo/numpy-discussion
> >
> > +1 to this addition.
> >
> > And +1 to also print rtol.
> > I frequently use rtol with assert_allclose, and having the value
> > printed helps quickly choose an appropriate value.
> >
> > Christoph
> > _______________________________________________
> > NumPy-Discussion mailing list
> > NumPy-Discussion at python.org
> > https://mail.python.org/mailman/listinfo/numpy-discussion
> >
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at python.org
> https://mail.python.org/mailman/listinfo/numpy-discussion
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20181219/897fe809/attachment.html>


More information about the NumPy-Discussion mailing list