FIX: remove unused get_cmap and to_rgba imports in laffer_adaptive#51
Merged
Conversation
`matplotlib.cm.get_cmap` was removed in newer matplotlib releases, so
importing it raises `ImportError` at import time and kills the whole
notebook on its first cell:
ImportError: cannot import name 'get_cmap' from 'matplotlib.cm'
Neither `get_cmap` nor `to_rgba` is referenced anywhere in the lecture —
the only occurrence of each is its own import line — so both are dropped
rather than migrated to `matplotlib.colormaps[...]`.
This mirrors the fix in QuantEcon/lecture-python-intro#798, where the
same dead imports broke the notebook once anaconda 2026.07 shipped the
matplotlib that drops `get_cmap`. This repo runs under pyodide rather
than the conda env, so it was not covered by that sweep, but it carries
the identical imports and will break on the same matplotlib bump.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
✅ Deploy Preview for beautiful-dodol-cb9543 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Pull request overview
This PR prevents lectures/laffer_adaptive.md from failing on newer Matplotlib versions by removing two unused imports (get_cmap and to_rgba) from the first code cell’s import block.
Changes:
- Removed
from matplotlib.cm import get_cmap(now incompatible with newer Matplotlib and unused here). - Removed
from matplotlib.colors import to_rgba(unused cleanup).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
📖 Netlify Preview Ready! Preview URL: https://pr-51--beautiful-dodol-cb9543.netlify.app (19cecc6) ✨ Browse the preview at the URL above. |
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.
Problem
matplotlib.cm.get_cmapwas removed in newer matplotlib releases.laffer_adaptive.mdimports it in its first code cell, so once the runtime's matplotlib crosses that version the notebook dies before executing anything:Fix
Two dead imports are dropped from that cell:
from matplotlib.cm import get_cmapmatplotlib.colormaps[...]from matplotlib.colors import to_rgbato_rgbastill exists in matplotlib, so this is cleanup rather than a fixBoth were verified unused by checking every occurrence in the file — each symbol appears exactly once, on its own import line, with no reference anywhere else (compare
MaxNLocatorandnamedtuple, which are each imported and used). Two lines deleted, no output changes.Context
This mirrors QuantEcon/lecture-python-intro#798. That fix came out of the
anaconda=2026.06 → 2026.07validation sweep across the Python lecture family, where 2026.07's matplotlib was the release that finally droppedget_cmap— it was the only real regression found across all seven repos.This repo runs under pyodide rather than the conda env, so it was outside that sweep's scope and its
environment.yml-based validation never touched it. But it carries the identical imports and will break the same way whenever its matplotlib crosses that version. Filing it now rather than waiting for it to surface as a broken lecture.Note for reviewers: the bare
import matplotlibon the following line also appears unused — there are nomatplotlib.<attr>references outside the import block. I left it in place to keep this diff aligned with what landed in lecture-python-intro#798, but happy to drop it if preferred.