Stop using deprecated matplotlib get_cmap (#2499) - #2840
Open
HafizMHussain wants to merge 1 commit into
Open
Conversation
matplotlib.cm.get_cmap() (and plt.cm.get_cmap()) were deprecated in matplotlib 3.7 and removed in 3.9. Several call sites used it as a try/except fallback where the try branch already used the supported plt.get_cmap(name, lut); since matplotlib is unpinned, the fallback branch would itself fail on current matplotlib. Replace with the supported API: - common.py: classify(), get_palette_colors() - drop the deprecated try/except fallbacks - toolbar.py: time_slider() - drop the deprecated try/except fallbacks - cartoee.py: build_palette() - use plt.get_cmap in the old-matplotlib branch and drop the now-unused 'from matplotlib import cm' Behavior is preserved on supported matplotlib versions. black and compile checks pass. Note: scoped to the matplotlib part of gee-community#2499; no deprecated traitlets calls were found in a scan, so that can be handled separately.
Contributor
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
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.
Fixes the matplotlib part of #2499.
matplotlib.cm.get_cmap()/plt.cm.get_cmap()were deprecated inmatplotlib 3.7 and removed in 3.9. Several call sites used it as a
try/exceptfallback where thetrybranch already used the supportedplt.get_cmap(name, lut). Since matplotlib is unpinned, those fallbackbranches would themselves fail on current matplotlib.
Changes
common.py:classify(),get_palette_colors()— drop the deprecatedtry/exceptfallbackstoolbar.py:time_slider()(×2) — drop the deprecatedtry/exceptfallbackscartoee.py:build_palette()— useplt.get_cmapin the old-matplotlib branch and drop the now-unusedfrom matplotlib import cmBehavior is preserved on supported matplotlib versions.
Verification:
black --checkpasses and all changed files compile.Scope note: This covers the matplotlib part of #2499. I scanned for
deprecated traitlets calls and didn't find obvious ones, so that part
can be handled separately (happy to follow up if you point me at specifics).