This came up in pytorch/pytorch#33568. This seems odd:
>>> np.clip([3 + 4.j], -1, 2)
array([2.+0.j])
>>> np.clip([3 + 4.j], -1+1.j, 2+12.j) # imaginary component goes up
array([2.+12.j])
>>> np.clip([1 + 4.j], -1+1.j, 2+12.j) # imaginary component doesn't go up
array([1.+4.j])
The only test for complex input is that it doesn't segfault.
Reasonable behavior could be one of:
- Clip real and imaginary parts separately
- Clip absolute value, not changing the phase
There may be other options. As long as it's documented, I'm not sure it matters much which choice is made.
I don't think this is a very important issue, but it would be nice to at least have the desired behavior documented here.
This came up in pytorch/pytorch#33568. This seems odd:
The only test for complex input is that it doesn't segfault.
Reasonable behavior could be one of:
There may be other options. As long as it's documented, I'm not sure it matters much which choice is made.
I don't think this is a very important issue, but it would be nice to at least have the desired behavior documented here.