FIX: lecture cleanup batch from the 2026-08 tracker audit - #595
Open
mmcky wants to merge 1 commit into
Open
Conversation
- polars: guard Exercise 1 first/last with drop_nulls (#589) - polars, pandas: migrate the remaining legacy np.random.* call sites to the Generator API (#552) - pandas_panel: use direct raw.githubusercontent.com data URLs (#580) - python_by_example: include the rng line in the white-noise snippet and correct the line count (#552) - functions, scipy: define rng in the cells that use it (#552) - numpy: document DiscreteRV's seed parameter (#552) and reference qe.Timer() instead of the retired tic/toc wording (#594) - about_py: standardize on PyTorch (#552) - autodiff: split the PRNG key once into three single-use keys (#529) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR applies a batch of small, audit-driven fixes across multiple lecture sources so that all translated editions pick them up in the next sync.
Changes:
- Fix RNG scoping / modernize random draws in several lectures (NumPy Generator API usage and per-cell
rngdefinitions where needed). - Improve correctness/robustness in examples (Polars
drop_nulls()guard forfirst()/last(), JAX single-use PRNG key splitting). - Clean up lecture text and links (raw GitHub CSV URLs, docstring/text consistency, PyTorch capitalization).
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| lectures/scipy.md | Defines rng locally in the linregress example cell to avoid hidden dependencies. |
| lectures/python_by_example.md | Aligns prose and snippet for white-noise example (adds rng line; fixes typo/count). |
| lectures/polars.md | Migrates random draws to Generator API; seeds benchmark via default_rng(42); guards first/last with drop_nulls(). |
| lectures/pandas.md | Keeps the mirrored Series example consistent with polars.md by using Generator API. |
| lectures/pandas_panel.md | Switches dataset URLs to direct raw.githubusercontent.com links (no redirect). |
| lectures/numpy.md | Documents seed in DiscreteRV.__init__ docstring; updates exercise text to reference qe.Timer() instead of tic/toc. |
| lectures/functions.md | Defines rng in each relevant code cell so running cells in isolation won’t raise NameError. |
| lectures/autodiff.md | Fixes JAX key reuse by splitting once into single-use subkeys for independent draws. |
| lectures/about_py.md | Standardizes “PyTorch” capitalization in prose and links. |
Contributor
Author
|
@Chihiro2000GitHub would you have time to cast an eye over these changes. Many of them are |
Collaborator
|
Thanks @mmcky! I've had a quick look through the changes. I'll do a proper review starting this weekend and get back to you with any comments 😊 |
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.
One batch of small, independently verified fixes from the 2026-08 tracker audit. They are grouped into a single PR because every item touches lecture source, so batching means the
.fa/.fr/.zh-cneditions pick everything up in one translation sync instead of five.Closes #589, closes #580, closes #552, closes #529, closes #594.
Changes
polars.mdfirst()/last()withdrop_nulls(), matching Exercise 2 — without it, tickers on different trading calendars produce nullpct_changevalues that flow silently into the bar chartpandas_panel.mdgithub.com/QuantEcon/data-lectures/raw/main/...URLs now point directly atraw.githubusercontent.com, avoiding the 302 redirectpython_by_example.mdrng = np.random.default_rng()line and the prose counts four lines, not three (also fixes a "genererate" typo)functions.mdgenerate_datacells definernglocally, so running a cell in isolation no longer raisesNameErrorscipy.mdlinregressexample definesrngin its own cell (matching the pattern already used at the Monte Carlo example later in the lecture)numpy.mdDiscreteRV.__init__docstring now documents theseedparameter and the non-reproducibility of theseed=Nonedefaultabout_py.mdpolars.md,pandas.mdnp.random.*call sites inpolars.mdmigrated to the Generator API; the mirrored Series cell inpandas.md(np.random.randn(4), the one site the audit had not flagged) is migrated too so the twin lectures stay consistentautodiff.mdkeywithuniformand then re-splitting it (correlated-draws risk); uses the fix suggested in the issue, withϵ_keynamed to match the lecture's unicode conventionnumpy.mdqe.Timer()context manager instead of the retiredtic/tocwording, matching the solution codeNotes for review
Random streams change in the edited cells: the polars/pandas Series and DataFrame demo cells now draw from a fresh
Generator, and the polars benchmark block seeds vianp.random.default_rng(42)instead ofnp.random.seed(42). Displayed numbers in the published output will differ from the current build, but nothing pedagogical depends on the specific draws. This is the same trade accepted throughout the series-wide Generator migration (#538–#549).The
rng-scoping fixes follow the convention already used by the migrated lectures (numba.md,numpy.mddefinerngin each cell/section that uses it) rather than introducing a shared top-of-lecture definition.🤖 Generated with Claude Code