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

Ron Adam ron3200 at gmail.com
Wed Feb 11 16:27:11 CET 2015



On 02/10/2015 11:15 PM, Chris Barker wrote:
> Large tolerances
> ----------------
>
> The most common use case is expected to be small tolerances -- on order of the
> default 1e-9. However there may be use cases where a user wants to know if two
> fairly disparate values are within a particular range of each other: "is a
> within 200% (rel_tol = 2.0) of b? In this case, the string test would never

string -> strong     "the strong test would never"

> indicate that two values are within that range of each other if one of them is
> zero. The strong case, however would use the larger (non-zero) value for the

strong -> weak     "The weak case, ..."

> test, and thus return true if one value is zero. For example: is 0 within 200%
> of 10? 200% of ten is 20, so the range within 200% of ten is -10 to +30. Zero
> falls within that range, so it will return True.


-Ron



More information about the Python-ideas mailing list