[Numpy-discussion] suggestion: improve text of failing test

josef.pktd at gmail.com josef.pktd at gmail.com
Thu Feb 5 17:16:13 EST 2015


On Thu, Feb 5, 2015 at 3:39 PM, Nathaniel Smith <njs at pobox.com> wrote:

> On 5 Feb 2015 12:15, <josef.pktd at gmail.com> wrote:
> >
> > The assert_allclose text is not precise enough to be helpful to fix a
> test failure that cannot be replicated on every machine, and we cannot just
> quickly grab --pdb-failures.
> >
> > By how much do I have to lower the precision to make it pass on this
> continuous integration machine?
> >
> >
> > assert_allclose(he, hefd, rtol=5e-10)
> >   File "C:\Python27\envs\py3\lib\site-packages\numpy\testing\utils.py",
> line 1297, in assert_allclose
> >     verbose=verbose, header=header)
> >   File "C:\Python27\envs\py3\lib\site-packages\numpy\testing\utils.py",
> line 665, in assert_array_compare
> >     raise AssertionError(msg)
> > AssertionError:
> > Not equal to tolerance rtol=5e-10, atol=0
> >
> > (mismatch 100.0%)
> >  x: array([[ -2.965667e+01,  -1.988865e+02,  -2.370194e+00,
>  -1.003654e+01],
> >        [ -1.988865e+02,  -1.383377e+03,  -1.592292e+01,  -6.800266e+01],
> >        [ -2.370194e+00,  -1.592292e+01,  -8.301699e-01,  -8.301699e-01],
> >        [ -1.003654e+01,  -6.800266e+01,  -8.301699e-01,  -3.449885e+00]])
> >  y: array([[ -2.965667e+01,  -1.988865e+02,  -2.370194e+00,
>  -1.003654e+01],
> >        [ -1.988865e+02,  -1.383377e+03,  -1.592292e+01,  -6.800266e+01],
> >        [ -2.370194e+00,  -1.592292e+01,  -8.301699e-01,  -8.301699e-01],
> >        [ -1.003654e+01,  -6.800266e+01,  -8.301699e-01,  -3.449885e+00]])
> >
> >
> > the suggestion is to add rtol and atol to the mismatch summary, so we
> can see if it's just a precision issue or something serious
> >
> > rtol = np.max(np.abs(x / y - 1)
> > atol = np.max(np.abs(x - y)
> >
> > (mismatch 100.0%  rtol=xxx  atol=xxx)
>
> So basically just printing what rtol and/or atol would have to be to make
> the test pass? Sounds useful to me. (There is a bit of an infelicity in
> that if you're using both atol and rtol in the same test then there's no
> easy way to suggest how to fix both simultaneously, but I'm not sure how to
> fix that. Maybe we should also print max(abs(x[y == 0]))?)
>

I usually check the rtol and atol as above in pdb on failure, Most of the
time it's enough information to figure out how to twist the numbers. There
are only a few cases where I'm fine tuning both rtol and atol at the same
time. I guess there is the sum of the tol from the definition of allclose.

We don't have many cases with y == 0 mixed together with large numbers,
because our reference numbers usually also have numerical noise.

One point is also to just make the test output more informative, to see if
the test machine is just a bit off even if the mismatch=100%.


> Want to submit a pull request?
>

Not really, I'd rather stick to my corner and let someone else get on the
numpy contributor list :)
(header was "suggestion" not "proposal")

Thanks,

Josef


> -n
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20150205/1a1bae13/attachment.html>


More information about the NumPy-Discussion mailing list