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
Inconsistent numpy.angle behavior #3046
Comments
Internally angle calls numpy.arctan2, which really just is the atan2 function from libm. This wrapping to pi for -0+0j is a special value of atan2 as defined in the C standard, (c.f. www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf, section F.9.1.4.) I'll note that python's cmath.phase, which is the python equivalent to numpy.angle, also returns, pi. I don't think this is really an error. |
[I added A simpler example showing what's going on here is:
prints:
I don't think np.angle(0) can really return NaN, because that breaks the equivalence |
Let's close this. It's not an error. |
Closing, the current behavior is correct. |
print(np.angle((-0-0j))) This is returning output : 0.0. |
@Yadunandanaacharya, your issue is that
This is because only python |
I opened https://bugs.python.org/issue41485 about this, the builtin |
Following up on a Stackoverflow question of mine:
http://stackoverflow.com/questions/15137003/strange-complex-phase-displayed
I am bringing this here. The issue is that angle called on a zero-matrix causes inconsistent values of the phase of a complex number. I understand the underlying float implementation is the cause, but I think it is important to understand e.g. Matlab does not have this problem, and instead does the more sensible thing and returns 0.
For completeness, the numpy script:
And the corresponding Matlab code:
I agree the phase of a zero isn't strictly defined (and GNU Octave... yuck, handles it even worse than numpy), but when showing these types of images, this is a hindrance and having to code around this seems artificial (and adds an extra line of code ;-)). If it has to be undefined, make it at least numerically handy undefined.
The text was updated successfully, but these errors were encountered: