[Python-ideas] float comparison in doctes

Terry Reedy tjreedy at udel.edu
Mon Sep 15 23:11:43 CEST 2014


On 9/15/2014 3:02 PM, Kevin Davies wrote:

> Erik Bray (the author of the +FLOAT_CMP extension in Astropy), Bruce Leban, and I had a short off-thread email discussion. Here are the points:
>
> - [Bruce]: ALMOST_EQUAL is the best flag name.

Agreed. I matches assertAlmostEqual.

> - [Erik]: If there's agreement on this, Erik will develop a patch as soon as he can.

I say go ahead.

> - [Erik]: There's no way to adjust the tolerance because there seems to be no easy way to parameterize doctest flags. Ideas are welcome.

After thinking about it more, I think this is OK for the purposes of 
doctests.

> - [Erik]: Still, "This +FLOAT_CMP flag enabled removing tons of ellipses from the test outputs [of Astropy], and restoring the full outputs which certainly read better in the docs... For more complete unit tests of course we use assert_almost_equal type functions.

So I would tune the doctest almost-equal compare algorithm to cover most 
cases, based on your experience, and leave exact tuning and broad domain 
coverage to unittests.

> - [Erik]: This PR is a better link than the one I gave: https://github.com/astropy/astropy/pull/2087
> - [Erik]: Most of the code is from the SymPy project with improvements. Erik had started on a similar feature when he found that their implementation was further developed.

-- 
Terry Jan Reedy



More information about the Python-ideas mailing list