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 (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/ "19. A language that doesn't affect the way you think about programming, is not worth knowing." --Alan Perlis
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4