[Python-checkins] peps: Apply Chris Barker's latest PEP 485 changes
chris.angelico
python-checkins at python.org
Fri Jan 23 01:50:48 CET 2015
https://hg.python.org/peps/rev/d234c5ff7ef6
changeset: 5679:d234c5ff7ef6
user: Chris Angelico <rosuav at gmail.com>
date: Fri Jan 23 11:50:29 2015 +1100
summary:
Apply Chris Barker's latest PEP 485 changes
files:
pep-0485.txt | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/pep-0485.txt b/pep-0485.txt
--- a/pep-0485.txt
+++ b/pep-0485.txt
@@ -16,7 +16,7 @@
This PEP proposes the addition of a function to the standard library
that determines whether one value is approximately equal or "close"
-to another value.
+to another value.
Rationale
@@ -82,7 +82,7 @@
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 @@
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 @@
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
===================
--
Repository URL: https://hg.python.org/peps
More information about the Python-checkins
mailing list