<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><div><br></div><div>-Chris</div><div> </div><div><br></div>-- <br><div class="gmail_signature"><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="mailto:Chris.Barker@noaa.gov" target="_blank">Chris.Barker@noaa.gov</a></div>
</div>