[Python-ideas] Way to check for floating point "closeness"?
Neil Girdhar
mistersheik at gmail.com
Thu Jan 15 01:23:50 CET 2015
You might be interested in my question:
http://stackoverflow.com/questions/4028889/floating-point-equality-in-python
On Monday, January 12, 2015 at 2:58:30 PM UTC-5, Chris Barker wrote:
>
> Now that we're talking about floating point conveniences (math.nan,
> linspace):
>
> What about putting an
>
> almost_equal(x,y,tol=1e14)
>
> (or close(), or...) in the math module.
>
> AFAICT, in the standard library, there is only:
>
> unittest.TestCase.assertAlmostEqual
>
> but it:
>
> A) is buried in the unittest.TestCase class
>
> B) is an assertion, so you can't use it as a general test (easily)
>
> C) uses number of decimal digits or an absolute delta, but does not
> provide a significant figures comparison, which is most likely what's
> wanted (and a bit harder to write yourself)
>
> numpy provides allclose() (and isclose() ), which is pretty much what I'm
> suggesting.
>
> Anyone else think this would be a good idea to add to the stdlib?
>
> -Chris
>
>
> --
>
> Christopher Barker, Ph.D.
> Oceanographer
>
> 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.... at noaa.gov <javascript:>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150114/cfa444cb/attachment.html>
More information about the Python-ideas
mailing list