FIX: Handle uint8 indices properly for colormap lookups#24970
Merged
QuLogic merged 1 commit intomatplotlib:mainfrom Jan 14, 2023
Merged
FIX: Handle uint8 indices properly for colormap lookups#24970QuLogic merged 1 commit intomatplotlib:mainfrom
QuLogic merged 1 commit intomatplotlib:mainfrom
Conversation
anntzer
reviewed
Jan 13, 2023
| xa[xa == self.N] = self.N - 1 | ||
| # Avoid converting large positive values to negative integers. | ||
| np.clip(xa, -1, self.N, out=xa) | ||
| with np.errstate(invalid="ignore"): |
Contributor
There was a problem hiding this comment.
Is the errstate even still needed? AFAICT casting nan to int doesn't trigger an "invalid" error.
Contributor
Author
There was a problem hiding this comment.
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
tacaswell
approved these changes
Jan 13, 2023
QuLogic
approved these changes
Jan 14, 2023
meeseeksmachine
pushed a commit
to meeseeksmachine/matplotlib
that referenced
this pull request
Jan 14, 2023
…colormap lookups
rcomer
added a commit
that referenced
this pull request
Jan 14, 2023
…970-on-v3.7.x Backport PR #24970 on branch v3.7.x (FIX: Handle uint8 indices properly for colormap lookups)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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