🌐 [translation-sync] [python_by_example.md] Update np.random → Generator API#59
🌐 [translation-sync] [python_by_example.md] Update np.random → Generator API#59
Conversation
✅ Translation Quality ReviewVerdict: PASS | Model: claude-sonnet-4-6 | Date: 2026-04-25 📝 Translation Quality
Summary: The translation of the modified sections is of high quality overall. Technical terminology is accurate and consistent with the reference glossary. The Chinese reads naturally with appropriate academic register. All MyST formatting, LaTeX math, and code blocks are preserved correctly. The main minor issue is a slight semantic ambiguity in the While Loops section regarding the loop termination condition phrasing, but it does not constitute a significant error. The exercise translations are faithful and clear. Technical terminology is consistently and accurately translated throughout the modified sections, including '子包' for 'subpackage', '随机抽取' for 'Random Draws', and '独立同分布' for 'IID'. The While Loops section accurately conveys the loop termination semantics and preserves all code blocks and inline code references intact. The Exercises section maintains all mathematical notation, LaTeX equations, and exercise/solution directives correctly. The For Loop section explanation is clear and natural in Chinese, preserving the pedagogical intent of the original with appropriate academic register. Code comments within changed sections (e.g., '# 空列表', '# while 循环的终止条件') are appropriately translated, enhancing readability for Chinese learners. The Version 1 section correctly integrates the i18n font setup code while preserving the original program logic explanation. Suggestions:
🔍 Diff Quality
Summary: The translation target document correctly mirrors all source changes, with code cells updated to use the new RNG API (np.random.default_rng() / rng.standard_normal() / rng.uniform()) in the same positions, while preserving all Chinese translations, document structure, and frontmatter heading-map metadata unchanged. This review was generated automatically by action-translation review mode. |
There was a problem hiding this comment.
Pull request overview
Automated translation sync that updates the zh-cn python_by_example lecture to use NumPy’s Generator API (default_rng() / standard_normal() / uniform()) instead of legacy np.random.* helpers, along with updating the translation state metadata.
Changes:
- Replace
np.random.randn(...)withrng = np.random.default_rng()+rng.standard_normal(...)across examples/solutions. - Replace
np.random.uniform()withrng.uniform()in the Monte Carlo π exercise solution. - Update translation sync state (
source-sha,synced-at,mode,tool-version).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| lectures/python_by_example.md | Updates random-number generation examples to the Generator API and adjusts surrounding explanatory text/formatting. |
| .translate/state/python_by_example.md.yml | Updates translation sync metadata (source SHA, date, mode, tool version). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| 回到我们绘制白噪声的程序,导入语句之后的剩余三行是 | ||
|
|
||
| ```{code-cell} ipython | ||
| ϵ_values = np.random.randn(100) | ||
| ϵ_values = rng.standard_normal(100) | ||
| plt.plot(ϵ_values) |
There was a problem hiding this comment.
This section says “导入语句之后的剩余三行是…”, but the updated program now has an extra required line (rng = np.random.default_rng()) before rng.standard_normal(...). As written, the snippet will also fail if executed on its own because rng isn’t defined in this cell. Consider either (a) updating the text to reflect the correct number of lines and including the rng = ... line in this code cell, or (b) explicitly stating this cell assumes rng was created earlier.
Automated Translation Sync
This PR contains automated translations from QuantEcon/lecture-python-programming.
Source PR
#538 - [python_by_example.md] Update np.random → Generator API
Files Updated
lectures/python_by_example.md.translate/state/python_by_example.md.ymlDetails
This PR was created automatically by the translation action.