On Sun, Feb 05, 2006, Alex Martelli wrote:
>
> But pulling in the whole of Numeric just to have that one handy  
> function is often overkill.  So I was wondering if module math (and  
> perhaps by symmetry module cmath, too) shouldn't grow a function  
> 'areclose' (calling it just 'close' seems likely to engender  
> confusion, since 'close' is more often used as a verb than as an  
> adjective; maybe some other name would work better, e.g.  
> 'almost_equal') taking two float arguments and optional tolerances  
> and using roughly the same specs as Numeric, e.g.:
> 
> def areclose(x,y,rtol=1.e-5,atol=1.e-8):
>      return abs(x-y)<atol+rtol*abs(y)

Looks interesting.  I don't quite understand what atol/rtol are, though.
You're right that another name would be better; almost_equal is fine.
-- 
Aahz ([EMAIL PROTECTED])           <*>         http://www.pythoncraft.com/

"19. A language that doesn't affect the way you think about programming,
is not worth knowing."  --Alan Perlis
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to