Skip to content
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

FIX: add missing method to ColormapRegistry #24111

Merged
merged 5 commits into from Oct 8, 2022

Conversation

tacaswell
Copy link
Member

PR Summary

After putting pending deprecations on cm.get_cmap we discovered that downstream libraries (pandas) were using the deprecated method to normalize between None (to get the default colormap), strings, and Colormap instances. This adds a method to ColormapRegistry to do this normalization.

This can not replace our internal helper due to variations in what exceptions are raised.

Closes #23981

I opted to edit the existing deprecation message as this seemed like the lest-bad option.

PR Checklist

Tests and Styling

  • Has pytest style unit tests (and pytest passes).
  • Is Flake 8 compliant (install flake8-docstrings and run flake8 --docstring-convention=all).

Documentation

  • New features are documented, with examples if plot related.
  • New features have an entry in doc/users/next_whats_new/ (follow instructions in README.rst there).
  • API changes documented in doc/api/next_api_changes/ (follow instructions in README.rst there).
  • Documentation is sphinx and numpydoc compliant (the docs should build without error).

@tacaswell tacaswell added this to the v3.6.1 milestone Oct 6, 2022
@jklymak jklymak requested a review from timhoffm October 6, 2022 22:21
lib/matplotlib/cm.py Outdated Show resolved Hide resolved
@tacaswell
Copy link
Member Author

I'm working on a fix to the docs build failure 🤦🏻 .

@tacaswell tacaswell force-pushed the add_missing_cmap_registry_method branch from 329983d to a2f2db9 Compare October 6, 2022 22:48
After putting pending deprecations on `cm.get_cmap` we discovered that
downstream libraries (pandas) were using the deprecated method to normalize
between `None` (to get the default colormap), strings, and Colormap instances.
This adds a method to `ColormapRegistry` to do this normalization.

This can not replace our internal helper due to variations in what exceptions
are raised.

Closes matplotlib#23981
@tacaswell tacaswell force-pushed the add_missing_cmap_registry_method branch from a2f2db9 to 3f99c20 Compare October 7, 2022 13:36
@tacaswell tacaswell requested a review from jklymak October 7, 2022 13:36
lib/matplotlib/cm.py Outdated Show resolved Hide resolved
lib/matplotlib/cm.py Outdated Show resolved Hide resolved
lib/matplotlib/cm.py Outdated Show resolved Hide resolved
lib/matplotlib/tests/test_colors.py Outdated Show resolved Hide resolved
tacaswell and others added 2 commits October 7, 2022 15:15
Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com>
Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com>
Copy link
Member

@QuLogic QuLogic left a comment

Choose a reason for hiding this comment

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

LGTM modulo deciding on the exception

lib/matplotlib/tests/test_colors.py Outdated Show resolved Hide resolved
lib/matplotlib/tests/test_colors.py Outdated Show resolved Hide resolved
@tacaswell
Copy link
Member Author

OK, switch to raising ValueError and TypeError.

@tacaswell tacaswell force-pushed the add_missing_cmap_registry_method branch from 2f96205 to a2dc64a Compare October 7, 2022 21:12
@tacaswell tacaswell force-pushed the add_missing_cmap_registry_method branch from a2dc64a to 4f8ece4 Compare October 7, 2022 21:13
@jklymak jklymak requested review from timhoffm and removed request for jklymak October 7, 2022 23:35
@jklymak
Copy link
Member

jklymak commented Oct 8, 2022

@QuLogic I'll leave for you to merge in case you want to squash it, or @tacaswell can squash merge....

@QuLogic QuLogic merged commit 924e210 into matplotlib:main Oct 8, 2022
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request Oct 8, 2022
QuLogic added a commit that referenced this pull request Oct 8, 2022
…111-on-v3.6.x

Backport PR #24111 on branch v3.6.x (FIX: add missing method to ColormapRegistry)
@tacaswell tacaswell deleted the add_missing_cmap_registry_method branch October 8, 2022 13:37
@ksunden ksunden mentioned this pull request Feb 20, 2023
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ENH]: Default matplotlib.colormaps[None] to call matplotlib.colormaps[matplotlib.rcParams['image.cmap']]?
4 participants