Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork8.1k
FIX: Handle uint8 indices properly for colormap lookups#24970
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
| xa[xa==self.N]=self.N-1 | ||
| # Avoid converting large positive values to negative integers. | ||
| np.clip(xa,-1,self.N,out=xa) | ||
| withnp.errstate(invalid="ignore"): |
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.
Is the errstate even still needed? AFAICT casting nan to int doesn't trigger an "invalid" error.
greglucasJan 13, 2023 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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.
I get one with it and get lots of failures in the pytest suite without ignoring.
python -c "import numpy; numpy.array([numpy.nan]).astype(int)"<string>:1: RuntimeWarning: invalid value encountered in cast…970-on-v3.7.xBackport PR#24970 on branch v3.7.x (FIX: Handle uint8 indices properly for colormap lookups)
PR Summary
Since we use subtraction to compute the lookup table indices we need to cast
uints in addition tofloats, so we can move the cast outside of the float block.closes#24865
PR Checklist
Documentation and Tests
pytestpasses)Release Notes
.. versionadded::directive in the docstring and documented indoc/users/next_whats_new/.. versionchanged::directive in the docstring and documented indoc/api/next_api_changes/next_whats_new/README.rstornext_api_changes/README.rst