[Numpy-discussion] RE: default axis for numarray
Paul F Dubois
paul at pfdubois.com
Wed Jun 12 08:45:09 CDT 2002
Using the term "comparison operators" is too loose and is causing a
communication problem here.
There are these comparison operators
== and != (group 1)
<, >, <=, and >= (group 2)
For complex numbers it is easy to define the operators in group 1: x ==
y iff x.real == y.real and x.imag == y.imag. And, x != y iff (not x ==
I hardly think any other definition would be conceivable. The utility of
this definition is questionable, as in most instances one should be
making these comparisons with a tolerance, but there at least are cases
when it makes sense.
For group 2, there are a variety of possible definitions. Just to name
three possible > definitions, the greater magnitude, the greater phase
mod 2pi, or a radix-type order e.g., x > y if x.real > y.real or
(x.real == y.real and x.imag > y.imag).
A person can always define a function my_greater_than (c1, c2) to embody
one of these definitions, and use it as an argument to a sort routine
that takes a function argument to tell it how to sort. What you are
arguing about is whether some particular version of this comparison
should be "blessed" by attaching it to the operator ">". I do not think
one of the definitions is such a clear winner that it should be blessed
-- it would mean a casual reader could not guess what the operator
means, and ">" does not have a doc string. Therefore I oppose doing so.
More information about the Numpy-discussion