[Python-ideas] Floating point "closeness" Proposal Outline

Chris Barker - NOAA Federal chris.barker at noaa.gov
Tue Jan 20 01:46:13 CET 2015


> On Jan 19, 2015, at 1:05 PM, Andrew Barnert <abarnert at yahoo.com> wrote:
>
> If you're working with measurement error or mechanical tolerance or something similar, you often have something with a non-unit mantissa. For example, the first resistor in the examples for the standard color code chart is 4.7KOhm +/- 10%, so you've got an error of 4.7e2.

Sure -- I, at least, really wasn't thinking the use-case would be
things like measurement testing. If it were a use-case like that, you
would want to use the method where you specify which value the
relative error is relative to.

But using an absolute error would be easy in that case, too.

So if folks think this a common use-case to support, that's the method to use.

> Also, keep in mind that if you do an error propagation analysis, you're unlikely to get round numbers.

This is very much the case that I am NOT expecting to support. If you
can do error propagation analysis, you can (and probably will want to)
write your own test criteria code.

> The reasons you often only have one significant figure are (a) you're hand-waving the error analysis,

Exactly, this is for the "do I have a big ol' bug?" kind of check, not
the "is this an accurate algorithm?" check.

Clearly time for a PEP

-Chris B.


More information about the Python-ideas mailing list