Fwd: Re: PEP 485: A Function for testing approximate equality
Chris Barker, If `isclose()` function is to be part of the standard library I would ask that the `rel_tol` and `abs_tol` both accept log10 scaled values: Instead of
isclose(a, b, rel_tol=1e9, abs_tol=0.0)
we have
isclose(a, b, rel_tol=9, abs_tol=INF)
`rel_tol` can be understood in terms of number of significant digits. `abs_tol` is understood in terms of fixed decimal digits. Thanks for noticing the ubiquitous need for such function.
On Thursday, February 5, 2015 at 12:14:25 PM UTC5, Chris Barker  NOAA Federal wrote:
Hi folks,
Time for Take 2 (or is that take 200?)
That's trading a teeny tiny bit of convenience for one particular use case for the flexibility to choose any number as the tolerance. If that change were made, I would have no means of specifying any sort of tolerance other than powers of 10. I can easily see myself saying "This number needs to be 1 + .5"
Mark, May you elaborate on your use case? I have not stumbled upon the need for such a high tolerance. I had imagined that the isclose() algorithm's use cases were to compare floating point numbers; which I thought to mean equal up to some number of significant digits (3 or more). Given such small epsilon, logarithmic granularity is good enough. I believe the majority of use cases for isclose() will involve such small tolerances. For larger tolerances, like you suggest, it is probably best be phrased as `0.5 <= x < 1.5`, or `abs(x1) <=0.5`. Furthermore, the version of `isclose()` I advocate need not have integer parameters `isclose(x, 1, abs_tol = log10(0.5))` is a legitimate, albeit ugly. Thank you for you time discussing this. On 20150217 8:37 AM, Mark Young wrote:
That's trading a teeny tiny bit of convenience for one particular use case for the flexibility to choose any number as the tolerance. If that change were made, I would have no means of specifying any sort of tolerance other than powers of 10. I can easily see myself saying "This number needs to be 1 + .5"
I don't have a realworld use case other than that sounds like something I would do with a function called is_close. I don't think we get much of anything (Except saving a few characters wen you want to define your tolerance with respect to significant digits) by forcing the error tolerances to be a power of ten. (And passing tolerance=math.log(X) is awful api design)
The period for bikeshedding is over. On Feb 17, 2015 8:19 AM, "Mark Young" <marky1991@gmail.com> wrote:
I don't have a realworld use case other than that sounds like something I would do with a function called is_close. I don't think we get much of anything (Except saving a few characters wen you want to define your tolerance with respect to significant digits) by forcing the error tolerances to be a power of ten. (And passing tolerance=math.log(X) is awful api design)
_______________________________________________ Pythonideas mailing list Pythonideas@python.org https://mail.python.org/mailman/listinfo/pythonideas Code of Conduct: http://python.org/psf/codeofconduct/
participants (3)

Guido van Rossum

Kyle Lahnakoski

Mark Young