[SciPy-user] numarray complex comparisons
Prabhu Ramachandran
prabhu at aero.iitm.ernet.in
Wed Dec 11 15:03:16 EST 2002
Hi,
>>>>> "EJ" == eric jones <eric at enthought.com> writes:
EJ> Sigh. I am weary of this topic. I've discussed it on
EJ> multiple occasions with many people -- both by email and
EJ> face-to-face. Some people don't care -- give them a rule and
EJ> they'll adapt. The remainder is about 50% split. I guess
Sure, I agree, folks will get used to whatever assumptions that are
made.
EJ> this mirrors other numeric computing communities. Some
EJ> Fortran compilers use one approach, some use the other.
EJ> Matlab uses one approach, IDL uses the other. Seems like
EJ> people either argue from the "moral high ground" (as Prabhu
EJ> does here) that it just ain't right to compare complex values,
EJ> or they argue pragmatically (as Travis O. and I do) that it
EJ> breaks generic array code that uses comparisons.
Its not really a "moral high ground". I was trying to give an
alternative argument. I've only seen "pragmatic" views this far so
thought a different point of view would be good. Also, I was trying
to make a generic design/philosophy argument.
EJ> I'm happy for others to discuss it, but I doubt I spend any
EJ> more time on it after this. My experience has been that this
EJ> is a "Mac is better than Windows" argument. Everyone has a
EJ> nice argument and then goes home with the same opinion and not
EJ> believing how stupid the other side was not to "get it."
Well, just to get it straight I never said anyone was stupid in my
email and I did not even venture to think that. In fact I said what I
did because we were asked. What I am comfortable with or not does not
make others who disagree stupid and what I am comfortable may well
change in time.
[snip]
EJ> By the way, the choice to use real is useful in many cases.
EJ> There are algorithms that return complex arrays with very
EJ> small imaginary parts do to round-off error. In this case
EJ> ignoring the imaginary part is often what you want to do.
Ok, so this is a democratic decision then and you seem to have
evidence that this is the case. Fine.
[snip]
>> So, I think that you should simply raise an exception if you
>> expected a real number and got a complex number instead. If
>> this is way too painful to have to deal with then make some
>> assumption and print it clearly each time you make that
>> assumption so that the user knows exactly what is going on and
>> where. I think this is the cleanest solution that I'll be
>> confortable with. Anything else makes me uncomfortable. Maybe
>> its because I am not used to this, I dont know.
EJ> Printing it out is an option -- although I'm not sure I like
EJ> it because it might become *very* noisy in some cases. This
EJ> is worth some thought.
OK, then atleast something useful came out of my efforts. :)
EJ> I don't really expect this to convince anyone that comparing
EJ> reals is better. It merely states my rationale and gives the
EJ> precedence for comparing reals. Those fearful of all out
EJ> calamity should take solace in the fact that the most used
EJ> numeric scripting language on the planet uses the same
EJ> approach and has proven to be very useful indeed.
My concern was simple. By making an assumption on how to order
complex numbers will we affect results of someones computations? I
dont know and was thinking of a worst case scenario (which if you ask
me is not a bad thing to do). I cant argue with Matlab's
experience. :)
cheers,
prabhu
More information about the SciPy-User
mailing list