<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Jan 15, 2015 at 1:52 PM, Neil Girdhar <span dir="ltr"><<a href="mailto:mistersheik@gmail.com" target="_blank">mistersheik@gmail.com</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">The point is that this function is already in Python</div></blockquote><div><br></div><div>I  don't think somethign being in an external package means that we have to do it the same way in teh stdlib -- even a widely used and well regarded package like numpy. And I say this as someone that has "import numpy" in maybe 90% of my python files.</div><div><br></div><div>Maybe we should be careful to give it a very distinct name, however, to avoid confusion.</div><div> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"> and if you want to do something different, you should have a really good reason to do it differently.</div></blockquote><div><br></div><div>I'm not sure I agree, but we do in this case anyway. The truth is, while really smart people wrote numpy, many of the algorithms in there did not go through nearly the level of review currently required for the python standard library</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">  If you were to add a function to math, say math.close, it should work like numpy.allclose in my opinion.<div><br></div><div>For reference, numpy does this:</div><div><br></div><div><span style="color:rgb(51,51,51);font-family:'Open Sans',sans-serif;font-size:13px;line-height:19px">absolute(</span><em style="font-style:italic;color:rgb(51,51,51);font-family:'Open Sans',sans-serif;font-size:13px;line-height:19px">a</em><span style="color:rgb(51,51,51);font-family:'Open Sans',sans-serif;font-size:13px;line-height:19px"> - </span><em style="font-style:italic;color:rgb(51,51,51);font-family:'Open Sans',sans-serif;font-size:13px;line-height:19px">b</em><span style="color:rgb(51,51,51);font-family:'Open Sans',sans-serif;font-size:13px;line-height:19px">) <= (</span><em style="font-style:italic;color:rgb(51,51,51);font-family:'Open Sans',sans-serif;font-size:13px;line-height:19px">atol</em><span style="color:rgb(51,51,51);font-family:'Open Sans',sans-serif;font-size:13px;line-height:19px"> + </span><em style="font-style:italic;color:rgb(51,51,51);font-family:'Open Sans',sans-serif;font-size:13px;line-height:19px">rtol</em><span style="color:rgb(51,51,51);font-family:'Open Sans',sans-serif;font-size:13px;line-height:19px"> * absolute(</span><em style="font-style:italic;color:rgb(51,51,51);font-family:'Open Sans',sans-serif;font-size:13px;line-height:19px">b</em><span style="color:rgb(51,51,51);font-family:'Open Sans',sans-serif;font-size:13px;line-height:19px">))</span><br></div><div><span style="color:rgb(51,51,51);font-family:'Open Sans',sans-serif;font-size:13px;line-height:19px"><br></span></div><div><font color="#333333" face="Open Sans, sans-serif"><span style="line-height:19px">where atol is an absolute tolerance and rtol is a relative tolerance (relative to the actual value b).  This subsumes most of the proposals here.</span></font></div></div></blockquote><div><br></div><div>adding atol  in there "takes care of" the near zero and straddleing zero issue ( I suspect that's why it's done that way), but it is fatally wrong for values much less than 1.0 --  the atol totally overwhelms the rtol.</div><div><br></div><div>See my post earlier today.</div><div><br></div><div>-Chris</div><div><br></div><div><br></div></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></div>