-
-
Notifications
You must be signed in to change notification settings - Fork 11k
sign(nan) emits warning #15127
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
Comments
What platform, numpy and Python versions are you using? On my system (Mac OSX), with Python 3.7 and 3.8, and with numpy master branch and 1.17.4, I don't get a warning. |
Aha, very interesting! I'm on Linux,
(master). |
I see it as well on linux, the issue is that the C comparison with 0 sets the flag. In principle the function could simply not check the floating point flags, but not sure how well our machinery is equipped for that currently (you can clear it at the end of each loop, adds a bit of overhead though). alternatively check for NaN. I suppose either of those solution may have a noticeable speed loss. |
I don;t see the warning using gcc 7.4 on ubuntu 18.04, with python 3.6.7 and numpy HEAD. We had a short discussion around
I would hazard a guess that The pattern used in gh-12236 could point the way to a fix here, note that it was tricky to get this to work for all compilers, intrinsics, and optimization levels. |
The current code is |
Had to add a filter for this in astropy (https://github.com/astropy/astropy/pull/9672/files#diff-4fdade973786257690f0716b79a23e94R714), since we now fail tests on warnings. Would be definitely be nice if this didn't warn but just returned |
Yeah, I think we should just go with the quick fix and clear the flag in the ufunc loop probably. We already have a bunch of functions that do that. |
This also emits a warning, since it is a non-standard NAN
xref gh-15189 |
Closed by gh-15230. |
Uh oh!
There was an error while loading. Please reload this page.
You can feed NaNs to almost any numpy function. The result will simply be nan. Except for
sign
: It's the only function I've found that additionally emits a warning.MWE:
The text was updated successfully, but these errors were encountered: