Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Should complex number have an ordering at all? (Trac #1406) #2004

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
thouis opened this issue Oct 19, 2012 · 3 comments
Closed

Should complex number have an ordering at all? (Trac #1406) #2004

thouis opened this issue Oct 19, 2012 · 3 comments

Comments

@thouis
Copy link
Contributor

thouis commented Oct 19, 2012

Original ticket http://projects.scipy.org/numpy/ticket/1406 on 2010-02-23 by trac user malev, assigned to unknown.

Hi there!
If you have and array with complex values, and try to execute: numpy.amax(array), amax, brings a result the max number of the array, but it only search in the real part.
I think that there shouldn't be result, like it happens when you call the max methods on a simple list.

In [1]: import numpy as np
In [2]: a_list = [1+2j, 1+3j, 2+2j,1+100j, 5+1j]
In [3]: a_np = np.array([1+2j, 1+3j, 2+2j,1+100j, 5+1j])
In [4]: np.amax(a_np)
Out[4]: (5+1j)

In [5]: max(a_list)

TypeError Traceback (most recent call last)
/home/malev/ in ()
TypeError: no ordering relation is defined for complex numbers

The code here: http://pastebin.com/b8JgMNhm
finally, I'm using:
Python 2.6.4 (r264:75706, Dec 7 2009, 18:45:15)
and numpy: '1.3.0'

Regards
malev

@thouis
Copy link
Contributor Author

thouis commented Oct 19, 2012

@pv wrote on 2010-02-23

Numpy defines an lexicographical ordering (sort by real part first, then by imaginary part) for complex numbers, so the behavior of amax is in line with that.

Changing that at this point requires a heavy reason to do so.

@thouis
Copy link
Contributor Author

thouis commented Oct 19, 2012

Title changed from [amax()] bad behaviour with complex arrays to Should complex number have an ordering at all? by @pv on 2010-02-23

@thouis
Copy link
Contributor Author

thouis commented Oct 19, 2012

@charris wrote on 2010-05-25

Probably not, but since we have one there is no reason to toss it out, just don't use it if it doesn't do what is needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant