<div dir="ltr">You might be interested in my question:<div><br></div><div>http://stackoverflow.com/questions/4028889/floating-point-equality-in-python<br><br>On Monday, January 12, 2015 at 2:58:30 PM UTC-5, Chris Barker wrote:<blockquote class="gmail_quote" style="margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir="ltr"><div>Now that we're talking about floating point conveniences (math.nan, linspace):<br></div><div><br></div><div>What about putting an</div><div><br></div><div>almost_equal(x,y,tol=1e14)</div><div><br></div><div>(or close(), or...) in the math module.</div><div><br></div><div>AFAICT, in the standard library, there is only:</div><div><br></div><div>unittest.TestCase.<wbr>assertAlmostEqual<br></div><div><br></div><div>but it:</div><div><br></div><div>A) is buried in the unittest.TestCase class</div><div><br></div><div>B) is an assertion, so you can't use it as a general test (easily)</div><div><br></div><div>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)</div><div><br></div><div>numpy provides allclose() (and isclose() ), which is pretty much what I'm suggesting.</div><div><br></div><div>Anyone else think this would be a good idea to add to the stdlib? </div><div><br></div><div>-Chris</div><div> </div><div><br></div>-- <br><div><br>Christopher Barker, Ph.D.<br>Oceanographer<br><br>Emergency Response Division<br>NOAA/NOS/OR&R            (206) 526-6959   voice<br>7600 Sand Point Way NE   (206) 526-6329   fax<br>Seattle, WA  98115       (206) 526-6317   main reception<br><br><a href="javascript:" target="_blank" gdf-obfuscated-mailto="lp07CTB7BqUJ" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">Chris....@noaa.gov</a></div>
</div>
</blockquote></div></div>