FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

FIX: Handle uint8 indices properly for colormap lookups by greglucas · Pull Request #24970 · matplotlib/matplotlib · GitHub

Repository navigation

FIX: Handle uint8 indices properly for colormap lookups - #24970

Merged
QuLogic merged 1 commit into
matplotlib:mainfrom
greglucas:cmap-cast
Jan 14, 2023
Merged

QuLogic merged 1 commit into
matplotlib:mainfrom
greglucas:cmap-cast

Conversation

Copy link
Copy Markdown
Contributor

PR Summary

Since we use subtraction to compute the lookup table indices we need to cast uints in addition to floats, so we can move the cast outside of the float block.

closes #24865

PR Checklist

Documentation and Tests

  • Has pytest style unit tests (and pytest passes)
  • [N/A] Documentation is sphinx and numpydoc compliant (the docs should build without error).
  • [N/A] New plotting related features are documented with examples.

Release Notes

  • [N/A] New features are marked with a .. versionadded:: directive in the docstring and documented in doc/users/next_whats_new/
  • [N/A] API changes are marked with a .. versionchanged:: directive in the docstring and documented in doc/api/next_api_changes/
  • [N/A] Release notes conform with instructions in next_whats_new/README.rst or next_api_changes/README.rst

Comment thread lib/matplotlib/colors.py
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"):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Is the errstate even still needed? AFAICT casting nan to int doesn't trigger an "invalid" error.

greglucas Jan 13, 2023 •
edited
Loading

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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

QuLogic merged commit 99d39bd into matplotlib:main Jan 14, 2023
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request Jan 14, 2023
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)
greglucas deleted the cmap-cast branch January 31, 2023 17:32
ksunden mentioned this pull request Feb 20, 2023
6 tasks
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: NumPy 1.24 deprecation warnings

4 participants


Back | FazBrowse Home | New Git URL