unittest: Proposal to add failUnlessNear
newsgroups at jhrothjr.com
Wed Jul 21 23:55:00 CEST 2004
"Christopher T King" <squirrel at WPI.EDU> wrote in message
news:Pine.LNX.4.44.0407210901230.9717-100000 at ccc8.wpi.edu...
> On Tue, 20 Jul 2004, John Roth wrote:
> > In addition, you're going to have to do significant
> > type checking if you want to combine floats and
> > complex in the same method call. That's just
> > poor design.
> Why would you have to do that? The Python operators, as well as every
> function in cmath, transparently support both floats and complex numbers
> (as they should). Every operation between floats and complex numbers is
Because the "distance" between two floats is
abs(a - b)
while the "distance" between two complex numbers
is something like
math.sqrt(diff.real ** 2 + diff.imag ** 2)
This requires a type check to differentiate which
formula you need to use.
More information about the Python-list