<p dir="ltr"><br>
On 12 Aug 2014 04:16, "Terry Reedy" <<a href="mailto:tjreedy@udel.edu">tjreedy@udel.edu</a>> wrote:<br>
><br>
> On 8/11/2014 12:25 PM, Kevin Davies wrote:<br>
>><br>
>> Erik Bray has created a nifty addition to doctest to compare floating<br>
>> point numbers using a `+FLOAT_CMP` flag.<br>
><br>
><br>
> 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<br>
> "a - b < delta" is shorter than "a.almost_equat(b, abs=delta)" and probably easier to understand.</p>
<p dir="ltr">For more formal tests, we already have unittest.TestCase.assertAlmostEqual.</p>
<p dir="ltr">This sounds like a reasonable flag for doctest's original purpose of checking that examples in docs are showing sensible answers.</p>
<p dir="ltr">Cheers,<br>
Nick.<br></p>
<p dir="ltr">><br>
><br>
> > It is implemented within<br>
>><br>
>> Astropy (<a href="http://www.astropy.org/">http://www.astropy.org/</a>) and the related issue is<br>
>> <a href="https://github.com/astropy/astropy/issues/2662">https://github.com/astropy/astropy/issues/2662</a>.<br>
><br>
><br>
> The related issue is applying flags to a block of test with a Sphinx directive.<br>
><br>
><br>
>> According to Erik, it<br>
>> may need some tweaks, but I think it would be a really useful feature to<br>
>> make available in the doctest package itself.<br>
><br>
><br>
> Erik would have to offer his code.<br>
><br>
> -- <br>
> Terry Jan Reedy<br>
><br>
><br>
> _______________________________________________<br>
> Python-ideas mailing list<br>
> <a href="mailto:Python-ideas@python.org">Python-ideas@python.org</a><br>
> <a href="https://mail.python.org/mailman/listinfo/python-ideas">https://mail.python.org/mailman/listinfo/python-ideas</a><br>
> Code of Conduct: <a href="http://python.org/psf/codeofconduct/">http://python.org/psf/codeofconduct/</a><br>
</p>