Apply Chris Barker's latest PEP 485 changes
This commit is contained in:
parent
79268209af
commit
9e4c0dd449
10
pep-0485.txt
10
pep-0485.txt
|
@ -82,7 +82,7 @@ comparisons near zero.
|
|||
|
||||
Modulo error checking, etc, the function will return the result of::
|
||||
|
||||
abs(expected-actual) <= max(tol*actual, abs_tol)
|
||||
abs(expected-actual) <= max(tol*expected, abs_tol)
|
||||
|
||||
|
||||
Handling of non-finite numbers
|
||||
|
@ -103,7 +103,7 @@ theory, it should work for any type that supports ``abs()``,
|
|||
comparisons, and subtraction. The code will be written and tested to
|
||||
accommodate these types:
|
||||
|
||||
* ``Decimal``
|
||||
* ``Decimal``: for Decimal, the tolerance must be set to a Decimal type.
|
||||
|
||||
* ``int``
|
||||
|
||||
|
@ -123,12 +123,16 @@ optional parameter, ``abs_tol`` (default 0.0) can be used to set a
|
|||
minimum tolerance to be used in the case of very small relative
|
||||
tolerance. That is, the values will be considered close if::
|
||||
|
||||
abs(a-b) <= abs(tol*actual) or abs(a-b) <= abs_tol
|
||||
abs(a-b) <= abs(tol*expected) or abs(a-b) <= abs_tol
|
||||
|
||||
If the user sets the rel_tol parameter to 0.0, then only the absolute
|
||||
tolerance will effect the result, so this function provides an
|
||||
absolute tolerance check as well.
|
||||
|
||||
A sample implementation is available (as of Jan 22, 2015) on gitHub:
|
||||
|
||||
https://github.com/PythonCHB/close_pep/blob/master/is_close_to.py
|
||||
|
||||
|
||||
Relative Difference
|
||||
===================
|
||||
|
|
Loading…
Reference in New Issue