[Python-ideas] PEP 485: A Function for testing approximate equality

Chris Barker - NOAA Federal chris.barker at noaa.gov
Thu Jan 29 17:01:52 CET 2015


> On Jan 29, 2015, at 6:52 AM, Steven D'Aprano
> That's essentially the same as Bruce Dawson recommends:

If anyone's interested in playing with this, I updated my sample
implementation with a flag that let's you select which method it will
use. Four! options. Note that I not suggesting such a flag be there in
an std lib function, but it makes it easy to experiment.

https://github.com/PythonCHB/close_pep/blob/master/is_close_to.py

Note that I found that every single one of my test cases passed with
all four methods, except one designed specifically to demonstrate the
asymmetry of the asymmetric test. Which was my point about it not
mattering much in practice.

I still need to add a bunch more to the PEP by way of explanation,
then I hope to be able to gauge where people are at.

-Chris


More information about the Python-ideas mailing list