[Python-ideas] float comparison in doctest
Terry Reedy
tjreedy at udel.edu
Mon Aug 11 20:15:08 CEST 2014
On 8/11/2014 12:25 PM, Kevin Davies wrote:
> Erik Bray has created a nifty addition to doctest to compare floating
> point numbers using a `+FLOAT_CMP` flag.
The problem with a simple flag is that almost_equal should sometimes be
absolute and sometimes relative and in both cases a parameter in needed.
I think there have been vague proposals for a float method, but
"a - b < delta" is shorter than "a.almost_equat(b, abs=delta)" and
probably easier to understand.
> It is implemented within
> Astropy (http://www.astropy.org/) and the related issue is
> https://github.com/astropy/astropy/issues/2662.
The related issue is applying flags to a block of test with a Sphinx
directive.
> According to Erik, it
> may need some tweaks, but I think it would be a really useful feature to
> make available in the doctest package itself.
Erik would have to offer his code.
--
Terry Jan Reedy
More information about the Python-ideas
mailing list