Skip to content

Stop using deprecated matplotlib get_cmap (#2499) - #2840

Open
HafizMHussain wants to merge 1 commit into
gee-community:masterfrom
HafizMHussain:fix-deprecated-matplotlib-get-cmap
Open

Stop using deprecated matplotlib get_cmap (#2499)#2840
HafizMHussain wants to merge 1 commit into
gee-community:masterfrom
HafizMHussain:fix-deprecated-matplotlib-get-cmap

Conversation

@HafizMHussain

Copy link
Copy Markdown

Fixes the matplotlib part of #2499.

matplotlib.cm.get_cmap() / 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, those fallback
branches would themselves fail on current matplotlib.

Changes

  • common.py: classify(), get_palette_colors() — drop the deprecated try/except fallbacks
  • toolbar.py: time_slider() (×2) — 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.

Verification: black --check passes 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).

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.
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

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.

1 participant