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
np.floor_divide drops imaginary part silently #13236
Comments
You can't have a floor function for complex numbers. Also , Traceback (most recent call last): Similary it should show TypeError. |
Numpy can't take floor of complex numbers, so instead of giving an error, it simply drops the imaginary part.So I think Numpy is working well |
Ok, I thought it would be worth to throw at least a warning, that the imaginary part is dropped, similar to other functions. |
Normal python throws an error, seems like we should probably follow suit, unless someone can think of a use case? |
Yeah I think we should throw a TypeError. |
Personally i would even prefer a (2+2j)//2 = (1+1j), although it's not perfectly mathematically correct. |
Not sure what is best, remainder is simply not implemented for complex (throws an error). And if we go to error, maybe we should deprecate first. Of course you can work on it, it will require to dive a bit into the how ufuncs work and are generated, so it may not be quite trivial, also there may still be some discussion necessary of where we want to go. That does not need to stop you though. |
"In the face of ambiguity, refuse the temptation to guess." suggests that it should be a @kaivu1999 - to address this, likely best would be to remove the complex types from even being generated in the |
@mhvk yeah, you also have to adjust |
@seberg - it seems the present behaviour should really just be considered a bug, and that for consistency with Whether we might want different behaviour would seem a separate discussion. |
Yeah, I am on it. Traceback (most recent call last): |
@kaivu1999 a pull request would be a good start. Please be sure to put |
Doing floor division on both real and imaginary parts makes some sense if we document that Gaussian integers are the result. That wouldn't be consistent with Python though. |
Reproducing code example:
Is there a special reason for this behavior? I would expect to floor_divide the imaginary and complex part.
Error message:
No error or warning is thrown, not even that imaginary part is getting lost.
Numpy/Python version information:
1.16.1
3.6.7 (default, Oct 22 2018, 11:32:17)
[GCC 8.2.0]
The text was updated successfully, but these errors were encountered: