A problem that I pointed out with the proposed areclose() function is that it
has within it a fp comparison. If such a function is to have greater utility,
it should allow the user to specify how significant to consider the computed
error. A natural extension of being able to tell if 2 fp
Please, I don't much care about the fine points of the function's
semantics, but PLEASE rename that function to are_close. Every time I
see this subject in my email client I have to think for a few seconds
what the hell 'areclose' means. This time it's not just because of the
new PEP 8,
Smith wrote:
... There is a problem with dividing by 'ave' if the x and y are at
the floating point limits, but the symmetric behaving form (presented
by Scott Daniels) will have the same problem.
Upon reflection, 'max' is probably better than averaging, and avoiding
divide is also a
Raymond Hettinger wrote:
| [Chris Smith]
|| Does it help to spell it like this?
||
|| def areclose(x, y, relative_err = 1.e-5, absolute_err=1.e-8):
|| diff = abs(x - y)
|| ave = (abs(x) + abs(y))/2
|| return diff absolute_err or diff/ave relative_err
|
| There is a certain beauty
On Mon, Feb 06, 2006, Chris or Leslie Smith wrote:
Aahz:
Alex:
|| 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.
Does it help to spell it like this?
def areclose(x, y,
On 2/6/06, Aahz [EMAIL PROTECTED] wrote:
...
def areclose(x, y, relative_err = 1.e-5, absolute_err=1.e-8):
diff = abs(x - y)
ave = (abs(x) + abs(y))/2
return diff absolute_err or diff/ave relative_err
Also, separating the two terms with 'or' rather than '+' makes the
two
[Chris Smith]
Does it help to spell it like this?
def areclose(x, y, relative_err = 1.e-5, absolute_err=1.e-8):
diff = abs(x - y)
ave = (abs(x) + abs(y))/2
return diff absolute_err or diff/ave relative_err
There is a certain beauty and clarity to this presentation; however, it
2006/2/6, Raymond Hettinger [EMAIL PROTECTED]:
The original Numeric definition is likely to be better for people who know
what they're doing; however, I still question whether it is an appropriate
remedy for the beginner issue
of why 1.1 + 1.1 + 1.1 doesn't equal 3.3.
Beginners won't know
Alex Martelli wrote:
On 2/6/06, Aahz [EMAIL PROTECTED] wrote:
...
def areclose(x, y, relative_err = 1.e-5, absolute_err=1.e-8):
diff = abs(x - y)
ave = (abs(x) + abs(y))/2
return diff absolute_err or diff/ave relative_err
Also, separating the two terms with 'or' rather than '+'
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
Alex Martelli wrote:
When teaching some programming to total newbies, a common frustration
is how to explain why a==b is False when a and b are floats computed
by different routes which ``should'' give the same results (if
arithmetic had infinite precision). Decimals can help, but
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.
On Feb 5, 2006, at 10:48 AM, Raymond Hettinger wrote:
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
[Bob Ipppolito]
For those of us that already know what we're doing with floating
point, areclose would be very convenient to have.
Do you agree that the original proposed use (helping newbs ignore floating
point realities) is misguided and error-prone?
Just curious, for your needs, do you
On Sun, 5 Feb 2006 13:48:51 -0500, Raymond Hettinger [EMAIL PROTECTED]
wrote:
[...]
rant
[...]
A language suitable for beginners should be easy to learn, but it should not
leave them permanently crippled. All of the above are sets of training
wheels
that don't come off. To misquote Einstein:
15 matches
Mail list logo