[Python-ideas] PEP 485: A Function for testing approximate equality (original) (raw)
Guido van Rossum guido at python.org
Thu Feb 5 18:56:58 CET 2015
- Previous message: [Python-ideas] PEP 485: A Function for testing approximate equality
- Next message: [Python-ideas] PEP 485: A Function for testing approximate equality
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
I think this looks good and I hope it'll get much approval. Thanks for hanging in there! I did a quick review:
Which module should this go into? (I think math, but I don't think you state it.)
Sometimes the default relative tolerance is described as 1e-8, sometimes as 1e-9.
The formula with "abs(a-b) <= max( ... min(..." is missing an all-important close parenthesis. I presume it goes before the last comma. :-)
What if a tolerance is inf or nan? What if all args are inf or nan?
I'd argue for allowing the tolerances to be floats even if a and b are Decimals. There's not much difference in the outcome. Also, what if exactly one of a and b is Decimal?
Your language about complex confuses me. What is z? I'd expect the following behavior:
- tolerances cannot be complex
- abs(a-b) is the right thing to use Or maybe you meant to say that abs() of the tolerances will be used if they are complex? That makes some sense in case someone just mindlessly passes a real cast to complex (i.e. with a zero imaginary part, or near-zero in case it's the outcome of a very fuzzy computation). But still. Maybe you can just give the formula to be used for complex args, if it is in fact any different from the one for reals?
For unittests are you proposing to replace assertAlmostEquals or deprecate that and add a new assertIsCloseTo? (I hope the latter.)
"there as no benefit" -- as->was
-- --Guido van Rossum (python.org/~guido) -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150205/6de170cb/attachment.html>
- Previous message: [Python-ideas] PEP 485: A Function for testing approximate equality
- Next message: [Python-ideas] PEP 485: A Function for testing approximate equality
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]