Skip to content

FIX: remove unused get_cmap and to_rgba imports in laffer_adaptive#51

Merged
mmcky merged 1 commit into
mainfrom
fix-laffer-adaptive-get-cmap
Jul 20, 2026
Merged

FIX: remove unused get_cmap and to_rgba imports in laffer_adaptive#51
mmcky merged 1 commit into
mainfrom
fix-laffer-adaptive-get-cmap

Conversation

@mmcky

@mmcky mmcky commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Problem

matplotlib.cm.get_cmap was removed in newer matplotlib releases. laffer_adaptive.md imports it in its first code cell, so once the runtime's matplotlib crosses that version the notebook dies before executing anything:

ImportError: cannot import name 'get_cmap' from 'matplotlib.cm'

Fix

Two dead imports are dropped from that cell:

Import Status Why removed
from matplotlib.cm import get_cmap Fatal on newer matplotlib Never used in the lecture — dropped rather than migrated to matplotlib.colormaps[...]
from matplotlib.colors import to_rgba Harmless but dead Never used; to_rgba still exists in matplotlib, so this is cleanup rather than a fix

Both 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 MaxNLocator and namedtuple, 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.07 validation sweep across the Python lecture family, where 2026.07's matplotlib was the release that finally dropped get_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 matplotlib on the following line also appears unused — there are no matplotlib.<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.

`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>
Copilot AI review requested due to automatic review settings July 20, 2026 02:31
@netlify

netlify Bot commented Jul 20, 2026

Copy link
Copy Markdown

Deploy Preview for beautiful-dodol-cb9543 ready!

Name Link
🔨 Latest commit 19cecc6
🔍 Latest deploy log https://app.netlify.com/projects/beautiful-dodol-cb9543/deploys/6a5d888643b62c000842a9fa
😎 Deploy Preview https://deploy-preview-51--beautiful-dodol-cb9543.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@github-actions

Copy link
Copy Markdown

📖 Netlify Preview Ready!

Preview URL: https://pr-51--beautiful-dodol-cb9543.netlify.app (19cecc6)

✨ Browse the preview at the URL above.

@mmcky
mmcky merged commit a2cc0a0 into main Jul 20, 2026
6 checks passed
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.

2 participants