[Numpy-discussion] proposal: min, max of complex should give warning

Neal Becker ndbecker2 at gmail.com
Tue Dec 31 10:52:47 EST 2013


Cera, Tim wrote:

> I don't work with complex numbers, but just sampling what others do:
> 
> 
> Python: no ordering, results in TypeError
> 
> Matlab: sorts by magnitude
> http://www.mathworks.com/help/matlab/ref/sort.html
> 
> R: sorts first by real, then by imaginary
> http://stat.ethz.ch/R-manual/R-patched/library/base/html/sort.html
> 
> Numpy: sorts first by real, then by imaginary (the documentation link
> below calls this sort 'lexicographical' which I don't think is
> correct)
> http://docs.scipy.org/doc/numpy/reference/generated/numpy.sort.html
> 
> 
> I would think that the Matlab sort might be more useful, but easy
> enough by using the absolute value.
> 
> I think what Numpy does is normal enough to not justify a warning, but
> leave this to others because as I pointed out in the beginning I don't
> work with complex numbers.
> 
> Kindest regards,
> Tim

But I'm not proposing to change numpy's result, which I'm sure would raise many 
objections.  I'm just asking to give a warning, because I think in most cases
this is actually a mistake on the user's part.  Just like the warning currently
given when complex data are truncated to real part.




More information about the NumPy-Discussion mailing list