[Numpy-discussion] deprecations for 1.6; assert_almost_equal

josef.pktd@gmai... josef.pktd@gmai...
Mon Mar 7 05:39:20 CST 2011


On Mon, Mar 7, 2011 at 4:10 AM, Pauli Virtanen <pav@iki.fi> wrote:
> Mon, 07 Mar 2011 11:03:17 +0800, Ralf Gommers wrote:
> [clip]
>> If anyone has new deprecations they want to put in for 1.6, discussing
>> them now would be good. I found one item in Trac, #1543. The proposal in
>> the ticket is to deprecate assert_almost_equal because it is quite badly
>> behaved. This function is quite widely used however (also in scipy and
>> presumably in third party code), so it will be a real pain if it starts
>> spewing out warnings.
>>
>> I propose instead to just add a note at the top of the
>> assert_almost_equal docstring that assert_array_max_ulp or
>> assert_tol_equal (to be added from scipy.special in 1.6) should be used
>> instead for new code.
>
> Numpy 1.5 has `assert_allclose` which is functionally equivalent to the
> proposed `assert_tol_equal`, so no new functions need to be added. I'm OK
> with documentation-only recommendation.

I also think assert_almost_equal should not be depreciated. Besides
being very heavily used, it is also the most appropriate test for many
statistical tests.

Test statistics like t-tests and p-values have an absolute scale, and
only a few decimals make statistical sense. The tolerance for
calculations (minimization, numerical differentiation and integration)
is often only targeted for this. Changing the signature just to
replicate it with assert_allclose is a pain without any gain.
And going over all the tests to see what the appropriate relative
error is, is a lot of work.
But we have some tickets in scipy stats to improve numerical
precision, beyond some decimals, and relative tolerance would be
useful in those cases.

I didn't know about assert_allclose and more advertising will help to
use it more often for new tests.

Why does assert_allclose have atol=0, while np.allclose has
rtol=1.e-5, atol=1.e-8 ?

What's the status on np.testing.assert_approx_equal, I would have
liked to use it more often, except it doesn't work on arrays.

Josef


>
>        Pauli
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>


More information about the NumPy-Discussion mailing list