ENH: add a copy method to colormaps#19663
Merged
QuLogic merged 2 commits intomatplotlib:masterfrom Mar 9, 2021
Merged
Conversation
e252024 to
2cecc10
Compare
2cecc10 to
9512d32
Compare
timhoffm
approved these changes
Mar 7, 2021
Member
There was a problem hiding this comment.
While I don't want to put a copy() method on every object, it makes sense here. With this method we make copying simpler and thus promote the needed copying at least for the transition period.
Milestoned for 3.4 - this should have been already introduced with the changes in 3.3. If we don't get it in 3.4 a major purpose ( the easier user-copy workaround in the transition period) is gone.
Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com>
Member
Author
|
Agreed, that we definitely don't want a copy method on everything. But most classes aren't primarily coming from global instances, and hence usually can be made from scratch. Whereas colormaps are probably 99% coming from the global list, so I think we should make it easy to move into user scope. |
QuLogic
approved these changes
Mar 9, 2021
meeseeksmachine
pushed a commit
to meeseeksmachine/matplotlib
that referenced
this pull request
Mar 9, 2021
QuLogic
added a commit
that referenced
this pull request
Mar 9, 2021
…663-on-v3.4.x Backport PR #19663 on branch v3.4.x (ENH: add a copy method to colormaps)
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
Right now we are deprecating access to the global colormaps, but users can only avoid it by doing
newcmap = copy.copy(cmap)which is a bit heavy-handed. Here we provide a simplecopymethod toColormapso we can donewcmap = cmap.copy().See discussion in #19609, #16991, #18503
PR Checklist
pytestpasses).flake8on changed files to check).flake8-docstringsand runflake8 --docstring-convention=all).doc/users/next_whats_new/(follow instructions in README.rst there).doc/api/next_api_changes/(follow instructions in README.rst there).