FIX: install quantecon in networks.md#802
Merged
Merged
Conversation
`lectures/networks.md` imports `quantecon` but its pip cell never installs it. The lecture builds today only because `markov_chains_I`, `markov_chains_II` and `eigen_II` appear earlier in the TOC and install `quantecon` into the same runner environment, so a full cold build satisfies the dependency by accident. That breaks as soon as the lecture executes on its own — the normal case with a warm `jupyter-cache`, where only the edited notebook is re-run. Observed in the Chinese edition, which carries the same gap as a faithful translation. Adds `quantecon` to the lecture's own pip cell and splits the cell to one package per line, matching `input_output.md` and the style guide. Closes #801 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
✅ Deploy Preview for taupe-gaufre-c4e660 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 fixes a latent dependency-order issue in the networks lecture by ensuring quantecon is installed within lectures/networks.md itself, so the notebook can run successfully in isolation (e.g., under warm jupyter-cache) rather than relying on earlier lectures’ pip cells.
Changes:
- Add an explicit
!pip install quantecontolectures/networks.md. - Split the existing combined install line into one-package-per-line installs for consistency with the documented lecture pattern.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
Author
✅ Translation sync completed (zh-cn)Target repo: QuantEcon/lecture-intro.zh-cn
|
mmcky
added a commit
to QuantEcon/lecture-intro.zh-cn
that referenced
this pull request
Jul 24, 2026
Matches the form landed upstream in QuantEcon/lecture-python-intro#802, which follows the code style guide (one package per line, standalone hide-output cell).
mmcky
added a commit
to QuantEcon/lecture-intro.zh-cn
that referenced
this pull request
Jul 24, 2026
…ix one Chinese-in-mathtext label (#276) * Register the CJK font in five lectures with Chinese figure labels These five lectures set Chinese text on matplotlib figures but never registered a CJK font, so matplotlib fell back to DejaVu Sans (which has no CJK coverage) and every Chinese axis label, title and legend entry rendered as blank boxes ("tofu"). Nothing errored and a valid PNG was written each time, so the defect has been shipping silently on the published site. Adds this edition's standard font-configuration block to the first code cell that imports matplotlib in each lecture, so it runs before any figure is drawn: import matplotlib as mpl FONTPATH = "fonts/SourceHanSerifSC-SemiBold.otf" mpl.font_manager.fontManager.addfont(FONTPATH) plt.rcParams['font.family'] = ['Source Han Serif SC'] Affected: cagan_adaptive, equalizing_difference, lp_intro, networks, pv. See #275 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * french_rev: move Chinese out of math mode in the log(real balances) ylabel The English source writes this axis label as '$\log(\mathrm{real\;balances})$', and the translation substituted the Chinese straight into \mathrm{}. Mathtext has no CJK coverage, so all four characters of 实际余额 rendered as blank boxes — matplotlib logs "Font 'rm' does not have a glyph for ... substituting with a dummy symbol" and writes the figure anyway, so the label has been shipping as log(□□□□) on the published site. The lecture's own font configuration is fine and the x-label immediately above it already uses the correct pattern — Chinese as plain text, maths inside $...$. This applies that pattern to the y-label, leaving \log and its parentheses in math mode and the Chinese outside it. Rendered output is unchanged in meaning: log(实际余额). See #275 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Add a DejaVu fallback to font.family, and register the font in cagan_ree Setting font.family to a single entry removes matplotlib's fallback, so any character the CJK font lacks renders as a blank box. Source Han Serif SC follows Adobe-GB1, which omits the symbol Greek forms (U+03D5 phi, U+03F5 epsilon), subscript digits and the vertical ellipsis. Measured on matplotlib 3.11.1 against this repo's own font: font.family = ['Source Han Serif SC'] -> 4 missing-glyph warnings font.family = ['Source Han Serif SC', 'DejaVu Sans'] -> 0 cagan_ree.md already carried the block and was silently losing a character to it: label=f'渐进 ϕ = {ϕ}' at line 783. Fixed by the fallback alone. Deliberately deviates from the single-entry dialect used elsewhere here; the dialect is missing a fallback and adding one is strictly an improvement. * networks: install quantecon in its own pip cell networks.md imports quantecon but its pip cell installed only quantecon-book-networks and pandas-datareader. It has been relying on an earlier lecture in the TOC having installed quantecon into the same runner: markov_chains_I (33), markov_chains_II (34) and eigen_II (38) each do, and networks is at 41. A full cold build therefore works, and the implicit dependency is invisible. It only surfaces when networks.md executes alone -- which is exactly what happens when a change invalidates its cache entry while every other lecture stays cached. That is what broke this branch: the font block edit re-ran the notebook, none of the earlier installs ran, and `import quantecon as qe` raised ModuleNotFoundError at line 5 of the imports cell. Makes the lecture self-sufficient, per the convention that packages outside anaconda are installed at the start of the lecture that needs them. The same gap exists upstream in QuantEcon/lecture-python-intro -- networks.md there imports quantecon at line 56 with the same pip line at 19 -- so it is inherited rather than a translation defect. Reported separately. * networks: one package per pip install line Matches the form landed upstream in QuantEcon/lecture-python-intro#802, which follows the code style guide (one package per line, standalone hide-output cell). --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Closes #801.
lectures/networks.mdimportsquanteconat line 56 but its pip cell only installsquantecon-book-networks==1.6andpandas-datareader. The lecture builds today becausemarkov_chains_I(TOC 35),markov_chains_II(36) andeigen_II(40) each run!pip install quanteconinto the same runner environment beforenetworks(43) executes, and pip installs persist across notebooks within a build. A full cold build therefore satisfies the dependency by accident.That guarantee disappears the moment the lecture executes on its own — which is the normal case, not an edge case. With a warm
jupyter-cache, a one-line edit tonetworks.mdre-executes only that notebook and serves every other lecture from cache, so none of the earlier pip cells fire. This was observed in the Chinese edition (lecture-intro.zh-cn#276), which carries the identical gap because it is a faithful translation of this file:ModuleNotFoundError: No module named 'quantecon'in the imports cell, after months of green builds.Confirmed that
quanteconis not inenvironment.ymleither — it reaches the build environment only via lecture pip cells.The change
One cell, in
lectures/networks.md:!pip install quantecon-book-networks==1.6 pandas-datareader!pip install quantecon!pip install quantecon-book-networks==1.6!pip install pandas-datareaderThis follows the code style guide — packages outside the Anaconda distribution are installed at the top of the lecture that needs them, in their own standalone
hide-outputcell, one package per!pip installline. It also matchesinput_output.md, the sibling lecture that uses the same three packages. No prose changes, so there is nothing new for the translation editions to translate.The wider check
The issue asked whether any other lecture imports a non-Anaconda package it does not itself install. I audited all 45 lectures — cross-referencing every
import/fromstatement against the packages named in that lecture's own!pip installlines, forquantecon,quantecon_book_networks,wbgapi,yfinance,pandas_datareader,plotly,xlrd,graphviz,jaxandinterpolation.networks.mdwas the only lecture affected, and after this change the audit is clean.🤖 Generated with Claude Code