-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Deprecate implicit creation of colormaps in register_cmap() #15875
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
timhoffm
merged 1 commit into
matplotlib:master
from
timhoffm:deprecate-register_cmap-data
Dec 9, 2019
Merged
Deprecate implicit creation of colormaps in register_cmap() #15875
timhoffm
merged 1 commit into
matplotlib:master
from
timhoffm:deprecate-register_cmap-data
Dec 9, 2019
Conversation
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
dstansby
reviewed
Dec 8, 2019
7524ced
to
38d7e06
Compare
anntzer
approved these changes
Dec 8, 2019
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.
postci
tacaswell
approved these changes
Dec 8, 2019
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.
Needs a re-base to resolve conflict in deprecation docs.
38d7e06
to
eb61e47
Compare
Rebase done. Taking the liberty to self-merge based on the two positive reviews. |
tacaswell
added a commit
to tacaswell/matplotlib
that referenced
this pull request
Sep 24, 2020
This was deprecated in 3.3 via matplotlib#15875
tacaswell
added a commit
to tacaswell/matplotlib
that referenced
this pull request
Sep 25, 2020
This was deprecated in 3.3 via matplotlib#15875 Enforce type of cmap as Colormap because we may not know that the object registered is of the wrong type until well after it was registered, defensively check here. We could do a duck-type check, but this is much simpler and we can cross the bridge of writing a duck-type checking function when someone has a use case for registering compatible-but-not-derived-from-Colormap instances.
6 tasks
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
register_cmap() could be used either with a Colormap, or by passing data to implicitly create a colormap from.
This PR deprecates the second way in favor of explicitly creating colormaps via
register_cmap(cmap=LinearSementedColormap(name, data lut))
.Having both ways is redundant, makes the function more complicated, and unnecessarily pulls colormap implementation details (like the lut) into the API of
register_cmap()
. Given that colormap registration is only done very rarely, the benefit of a sligtly shorter callregister_cmap(name, data=data, lut=lut)
is negligable. It's even error prone because data has to be passed as kwarg since the second arg is the for this case unused cmap parameter.PR Checklist