8000 FIX: ensure type stability for missing cmaps in `set_cmap` by tacaswell · Pull Request #23785 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

FIX: ensure type stability for missing cmaps in set_cmap #23785

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

Merged
merged 2 commits into from
Sep 2, 2022

Conversation

tacaswell
Copy link
Member

PR Summary

Previously this would raise a ValueError, the refactor caused it to raise
KeyError. This inadvertently located a bad test in x-array, but restoring
the old behavior.

https://github.com/pydata/xarray/runs/8104117777?check_suite_focus=true#step:8:673

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).

@tacaswell tacaswell added this to the v3.6.0 milestone Aug 31, 2022
Previously this would raise a `ValueError`, the refactor caused it to raise
`KeyError`.   This inadvertently located a bad test in xarray, but restoring
the old behavior.
@tacaswell tacaswell force-pushed the fix_cmap_missing_typestability branch from f8851ce to 0b6b385 Compare August 31, 2022 19:44
@QuLogic
Copy link
Member
QuLogic commented Aug 31, 2022

Copy link
Contributor
@greglucas greglucas left a comment

Choose a reason for hiding this comment

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

Just a minor nit, feel free to ignore and merge if you are fine with it currently.

cmap if cmap is not None else mpl.rcParams['image.cmap']
]
cmap_name = cmap if cmap is not None else mpl.rcParams["image.cmap"]
_api.check_in_list(sorted(_colormaps), cmap=cmap_name)
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you want to put a comment in saying you added this check for error raising type stability so we don't remove it later? Does it need to be sorted or can it be list(_colormaps)?

Copy link
Member Author

Choose a reason for hiding this comment

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

The input is used in formatting the error to tell the user what the allowed values are. Given the number of color maps I think sorting is a usability win / kindness for the user to discover what the correct spelling of the color map they tried to ask for is.

Copy link
Contributor

Choose a reason for hiding this comment

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

👍 Makes sense. Agreed.

Copy link
Member Author

Choose a reason for hiding this comment

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

I pushed a comment about why we are doing extra work.

@greglucas greglucas merged commit 25b39d4 into matplotlib:main Sep 2, 2022
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request Sep 2, 2022
@tacaswell tacaswell deleted the fix_cmap_missing_typestability branch September 2, 2022 02:51
QuLogic added a commit that referenced this pull request Sep 2, 2022
…785-on-v3.6.x

Backport PR #23785 on branch v3.6.x (FIX: ensure type stability for missing cmaps in `set_cmap`)
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.

3 participants
0