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

Chris Barker chris.barker at noaa.gov
Tue Jan 27 23:14:14 CET 2015

On Tue, Jan 27, 2015 at 2:00 PM, Guido van Rossum <guido at python.org> wrote:

> I really appreciate this API design approach, and in this case I started
>> out with that idea. But I think this is likely to be used where you need to
>> test a bunch of values with single function/set of parameters. In
>> TestCase.assertIsCloseTo, as well as home grown loops and comprehensions.
> I assume you mean assertNotAlmostEqual
> <https://hg.python.org/cpython/file/94d8524086bd/Lib/unittest/case.py#l525>.

Sorry -- I meant a Hypothetical assertIsCLoseTo -- which would wrap the
proposed is_close_to(), but apply it to a entire sequence, like

> This is actually the same misguided two-for-one design. You *must* specify
> exactly one of delta or places, and the code takes a different path. Also,
> it looks like both are actually absolute tolerance.

Yes, both are an absolute tolerance -- which , I think makes it a slightly
less misguided design -- you aren't selecting two different
functionalities, just two ways to spell the tolerance.

So what argument are you making here?

The point was that if the user applies one set of parameters to a sequence
of values that may have some zeros in it, -- we need it in one function.
Nathaniel has found that to be a fairly common use-case for the numpy



Christopher Barker, Ph.D.

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150127/79a85e65/attachment-0001.html>

More information about the Python-ideas mailing list