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

Nathaniel Smith njs at pobox.com
Tue Jan 27 01:42:14 CET 2015


On Tue, Jan 27, 2015 at 12:16 AM, Chris Barker <chris.barker at noaa.gov> wrote:
> On Sun, Jan 25, 2015 at 11:07 PM, Paul Moore <p.f.moore at gmail.com> wrote:
>>
>> I'm not sure what you're saying here - by "not setting defaults" do
>> you mean making it mandatory for the user to supply a tolerance, as I
>> suggested above?
>
> I for one, think making it mandatory to set one would be better than just
> letting the zeros get used.
>
> I've used the numpy version of this a lot for tests, , and my work flow is
> usually:
>
> write a test with the defaults
>
> if it pases, I'm done.
>
> If it fails, then I look and see if my code is broken, or if I can accept a
> larger tolerance.
>
> So I'm quite happy to have a default.
>
>> > I really think that having three tolerances, once of which is nearly
>> > always ignored, is poor API design. The user usually knows when they are
>> > comparing against an expected value of zero and can set an absolute
>> > error tolerance.
>>
>> Agreed.
>
>
> also agreed -- Nathanial -- can you live with this?

I can live with it, but I'd ignore the function and use allclose instead :-).

In your workflow above, I'm guessing that with allclose then it's <1%
of the time that you have a failure due to too-restrictive default
tolerances, where you then have to switch from thinking about your
problem to thinking about floating point details. With no absolute
tolerance, this rises to ~30% (assuming my super quick and dirty
github statistics are typical). That's a lot of workflow disruption.

-n

-- 
Nathaniel J. Smith
Postdoctoral researcher - Informatics - University of Edinburgh
http://vorpus.org


More information about the Python-ideas mailing list