Skip to content

complex-valued comparison incorrectly succeeds #17361

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
nschloe opened this issue Sep 21, 2020 · 2 comments
Closed

complex-valued comparison incorrectly succeeds #17361

nschloe opened this issue Sep 21, 2020 · 2 comments

Comments

@nschloe
Copy link
Contributor

nschloe commented Sep 21, 2020

Since there is no ordering in the complex numbers, vanilla Python correctly rejects something like

0 < 1 + 1j

with

TypeError: '<' not supported between instances of 'int' and 'complex'

Numpy incorrectly does something -- no idea what though. In any case, the following should probably fail:

import numpy

z = 1 + 1j
0 < numpy.array(z)  # succeeds?!
@pv
Copy link
Member

pv commented Sep 22, 2020

Complex numbers can be ordered, and Numpy uses the lexicographic order. It's true that no ordering exists that satisfies similar relations vs. both addition and multiplication as for reals. But I don't think the present behavior is really incorrect. One an argue that it is inconsistent both with Python, though, and I suspect there's not that much code that correctly makes use of this.

@seberg
Copy link
Member

seberg commented Sep 23, 2020

There was some discussion previously and we were seriously considering deprecating it in gh-15981, and not long ago Rakesh started working on that in gh-17030.

That said, it is hard to say what fallout might crop up which may lead us to keep the current behaviour. And it indeed is not a bug as such.

I am going to close this in favor of the linked issue, @nschloe if you want to discuss this further, I would suggest commenting either on the issue or PR.

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

No branches or pull requests

3 participants