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
BUG: complex special case for clip #15640
Conversation
Maybe you could run |
def test_complex(self): | ||
val = np.array([0+7j, 1+6j, 2+5j, 3+4j]) | ||
result = val.clip(1+5j, 2+6j) | ||
expected = np.array([1+6j, 1+6j, 2+5j, 2+5j]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the clip definition, values outside the interval are clipped to the interval edges, so the value of expected should be np.array([1+5j, 1+6j, 2+5j, 2+6j]) ? But as far as I know, complex cannot be compared, and any operation involving comparison should be disallowed.
Is this change worth it vs just having the user write:
It's not clear to me that what you're proposing is a sensible generalization of |
Honestly, I don't think there is a fully sensible definition of clip for imaginary numbers. Both of the proposals from the linked issue make some sense, but trying to compare values of incomparable values doesn't make much sense to me personally. That said, right now the behavior of clip on complex inputs is just wrong. Would it be preferable to disallow complex inputs? |
fixes: #15630
I'm not convinced that this is what's desired, or that the test added is sufficient and/or in the right place. But, it's hopefully a start.
(If someone sees this early, I'll squash my fixup commits once things look passable)