<div dir="ltr">So is 1e-100 close to 1e-50 with the default tolerance? What about 1e+100 and (1e+100 plus one ulp)?<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jan 12, 2015 at 9:02 AM, Chris Barker <span dir="ltr"><<a href="mailto:chris.barker@noaa.gov" target="_blank">chris.barker@noaa.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 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.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><span class="HOEnZb"><font color="#888888"><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            <a href="tel:%28206%29%20526-6959" value="+12065266959" target="_blank">(206) 526-6959</a>   voice<br>7600 Sand Point Way NE   <a href="tel:%28206%29%20526-6329" value="+12065266329" target="_blank">(206) 526-6329</a>   fax<br>Seattle, WA  98115       <a href="tel:%28206%29%20526-6317" value="+12065266317" target="_blank">(206) 526-6317</a>   main reception<br><br><a href="mailto:Chris.Barker@noaa.gov" target="_blank">Chris.Barker@noaa.gov</a></div>
</font></span></div>
<br>_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" target="_blank">https://mail.python.org/mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" target="_blank">http://python.org/psf/codeofconduct/</a><br></blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature">--Guido van Rossum (<a href="http://python.org/~guido">python.org/~guido</a>)</div>
</div>