Skip to content

FIX: lecture cleanup batch from the 2026-08 tracker audit - #595

Open
mmcky wants to merge 1 commit into
mainfrom
lecture-cleanup-2026-08
Open

FIX: lecture cleanup batch from the 2026-08 tracker audit#595
mmcky wants to merge 1 commit into
mainfrom
lecture-cleanup-2026-08

Conversation

@mmcky

@mmcky mmcky commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

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-cn editions pick everything up in one translation sync instead of five.

Closes #589, closes #580, closes #552, closes #529, closes #594.

Changes

Issue File(s) Change
#589 polars.md Exercise 1 solution now guards first()/last() with drop_nulls(), matching Exercise 2 — without it, tickers on different trading calendars produce null pct_change values that flow silently into the bar chart
#580 pandas_panel.md The three github.com/QuantEcon/data-lectures/raw/main/... URLs now point directly at raw.githubusercontent.com, avoiding the 302 redirect
#552 (1) python_by_example.md The white-noise snippet now includes the rng = np.random.default_rng() line and the prose counts four lines, not three (also fixes a "genererate" typo)
#552 (2) functions.md The three generate_data cells define rng locally, so running a cell in isolation no longer raises NameError
#552 (3) scipy.md The linregress example defines rng in its own cell (matching the pattern already used at the Monte Carlo example later in the lecture)
#552 (4) numpy.md DiscreteRV.__init__ docstring now documents the seed parameter and the non-reproducibility of the seed=None default
#552 (5) about_py.md "Pytorch" → "PyTorch" (2 sites)
#552 (6) polars.md, pandas.md The eight legacy np.random.* call sites in polars.md migrated to the Generator API; the mirrored Series cell in pandas.md (np.random.randn(4), the one site the audit had not flagged) is migrated too so the twin lectures stay consistent
#529 autodiff.md The simulated-data cell splits the PRNG key once into three single-use keys instead of consuming key with uniform and then re-splitting it (correlated-draws risk); uses the fix suggested in the issue, with ϵ_key named to match the lecture's unicode convention
#594 numpy.md Exercise text now says qe.Timer() context manager instead of the retired tic/toc wording, matching the solution code

Notes 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 via np.random.default_rng(42) instead of np.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.md define rng in each cell/section that uses it) rather than introducing a shared top-of-lecture definition.

🤖 Generated with Claude Code

- 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>
Copilot AI review requested due to automatic review settings August 3, 2026 23:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 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 rng definitions where needed).
  • Improve correctness/robustness in examples (Polars drop_nulls() guard for first()/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.

@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown

@github-actions
github-actions Bot temporarily deployed to pull request August 3, 2026 23:13 Inactive
@mmcky

mmcky commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

@Chihiro2000GitHub would you have time to cast an eye over these changes. Many of them are rng updates.

@mmcky
mmcky requested a review from Chihiro2000GitHub August 3, 2026 23:15
@Chihiro2000GitHub

Copy link
Copy Markdown
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 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment