Skip to content

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

Merged
mmcky merged 2 commits into
mainfrom
fix-laffer-adaptive-get-cmap
Jul 19, 2026
Merged

FIX: remove unused get_cmap and to_rgba imports in laffer_adaptive#798
mmcky merged 2 commits into
mainfrom
fix-laffer-adaptive-get-cmap

Conversation

@mmcky

@mmcky mmcky commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Problem

anaconda 2026.07 ships a matplotlib that has finally removed the long-deprecated matplotlib.cm.get_cmap. The first code cell of laffer_adaptive.md imports it, so the notebook now fails at import time before executing anything:

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

This surfaced while validating the anaconda 2026.06 → 2026.07 bump (#797): the cache.yml run on that branch (run 29685190525) failed with exactly one broken notebook — this one. Every other lecture built clean under -W --keep-going.

Fix

Two dead imports are dropped from that cell:

Import Status Why removed
from matplotlib.cm import get_cmap Fatal under anaconda 2026.07 Never used in the lecture — dropped rather than migrated to matplotlib.colormaps[...]
from matplotlib.colors import to_rgba Harmless but dead Never used in the lecture; 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, namedtuple and fsolve, which are each imported and used). Two lines deleted, no output changes.

Why this targets main rather than the dependabot branch

The dead import is a latent bug independent of the env bump — it just happens to become fatal under 2026.07. Landing it on main keeps the dependabot PR a clean environment.yml-only diff, matching how the compat fixes were handled during the 2026.06 round (#776, #777). Once this merges I'll rebase #797 and re-dispatch cache.yml to confirm a fully green validation build.

Cross-repo validation status is tracked in QuantEcon/workspace-lectures#21.

Note for reviewers: the bare import matplotlib on the following line also appears to be unused — there are no matplotlib.<attr> references outside the import block. I have left it in place as it is out of scope for this fix, but happy to drop it here if preferred.

anaconda 2026.07 ships a matplotlib that has removed the long-deprecated
`matplotlib.cm.get_cmap`, so the first code cell of `laffer_adaptive.md`
fails at import time with:

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

The symbol is never used anywhere in the lecture, so the import is simply
dropped rather than migrated to `matplotlib.colormaps[...]`.

Found while validating the anaconda 2026.06 -> 2026.07 bump (#797). See
QuantEcon/workspace-lectures#21 for the cross-repo validation status.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 19, 2026 23:16
@netlify

netlify Bot commented Jul 19, 2026

Copy link
Copy Markdown

Deploy Preview for taupe-gaufre-c4e660 ready!

Name Link
🔨 Latest commit cfe12ba
🔍 Latest deploy log https://app.netlify.com/projects/taupe-gaufre-c4e660/deploys/6a5d5bf1a6bb420008fb5b54
😎 Deploy Preview https://deploy-preview-798--taupe-gaufre-c4e660.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

Removes a now-broken, long-deprecated Matplotlib import from laffer_adaptive.md to keep the lecture executing under the newer Anaconda/Matplotlib stack, without changing lecture outputs.

Changes:

  • Drop the unused from matplotlib.cm import get_cmap import that now raises ImportError under newer Matplotlib.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lectures/laffer_adaptive.md Outdated
`to_rgba` is imported but never referenced anywhere in the lecture — the
only occurrence in the file is the import statement itself. Unlike
`get_cmap` this one is not yet fatal (matplotlib still ships `to_rgba`),
but it is dead either way, so it goes with the same cleanup.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@mmcky mmcky changed the title FIX: remove unused get_cmap import in laffer_adaptive FIX: remove unused get_cmap and to_rgba imports in laffer_adaptive Jul 19, 2026
@github-actions

github-actions Bot commented Jul 19, 2026

Copy link
Copy Markdown

@github-actions
github-actions Bot temporarily deployed to pull request July 19, 2026 23:29 Inactive
@mmcky
mmcky merged commit 49f3182 into main Jul 19, 2026
7 checks passed
@mmcky
mmcky deleted the fix-laffer-adaptive-get-cmap branch July 19, 2026 23:33
@mmcky

mmcky commented Jul 19, 2026

Copy link
Copy Markdown
Contributor Author

✅ Translation sync completed (zh-cn)

Target repo: QuantEcon/lecture-intro.zh-cn
Translation PR: QuantEcon/lecture-intro.zh-cn#268
Files synced (1):

  • lectures/laffer_adaptive.md

mmcky added a commit to QuantEcon/lecture-wasm that referenced this pull request Jul 20, 2026
`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>
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