Skip to content

🌐 [translation-sync] [numba.md] Update np.random → Generator API#70

Open
mmcky wants to merge 2 commits into
mainfrom
translation-sync-2026-07-15T23-50-12-pr-550
Open

🌐 [translation-sync] [numba.md] Update np.random → Generator API#70
mmcky wants to merge 2 commits into
mainfrom
translation-sync-2026-07-15T23-50-12-pr-550

Conversation

@mmcky

@mmcky mmcky commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Automated Translation Sync

This PR contains automated translations from QuantEcon/lecture-python-programming.

Source PR

#550 - [numba.md] Update np.random → Generator API

Files Updated

  • ✏️ lectures/numba.md
  • ✏️ .translate/state/numba.md.yml

Details

  • Source Language: en
  • Target Language: zh-cn
  • Model: claude-sonnet-5

This PR was created automatically by the translation action.

@github-actions

Copy link
Copy Markdown
Contributor

✅ Translation Quality Review

Verdict: PASS | Model: claude-sonnet-5 | Date: 2026-07-15


📝 Translation Quality

Criterion Score
Accuracy 9/10
Fluency 9/10
Terminology 9/10
Formatting 9/10
Overall 9/10

Summary: The translation of the Exercises section and preamble is accurate, fluent, and terminologically consistent with the glossary. Technical concepts like data races, parallel loops, and Monte Carlo estimation are rendered clearly in natural academic Chinese. No syntax errors were found in the changed sections. The added translation metadata and i18n font-loading code are expected additions per the project's translation pipeline conventions and not translation errors. Technical terminology (JIT编译, 并行化, 数据竞争, 有效样本量) is translated accurately and consistently with domain conventions Complex explanatory passages about data races and reproducibility (症状1/症状2 sections) are rendered clearly and naturally in Chinese while preserving technical precision Code comments are appropriately translated where relevant (e.g., '# 除以半径的平方', '# 分别为离开低状态和高状态的概率') while code syntax remains untouched All MyST directives, exercise/solution blocks, and math expressions are correctly preserved without structural errors

Suggestions:

  • Exercises section, methods list in plot code: '每线程独立状态(正确)' and 'prange 中共享生成器(数据竞争)' are good translations but slightly condensed compared to the English labels 'per-thread state (correct)' and 'shared generator in prange (data race)' — consider verifying these match the intended legend meaning exactly, though the current rendering is acceptable and clear.
  • Preamble: The added i18n font-loading code block (matplotlib font configuration) is an insertion not present in the English source; while this is a common practice for CJK font rendering support and likely acceptable per project convention, it should be confirmed this is standard practice for this translation pipeline since it does add lines not in the original source that could affect diff/sync tracking.

🔍 Diff Quality

Check Status
Scope Correct
Position Correct
Structure Preserved
Heading-map Correct
Overall 10/10

Summary: The translation sync correctly added new exercises, solutions, and explanatory content in matching positions and order, preserved document structure, and the heading map update is accurate (including a minor supplemental fix for previously missing heading entries).

Issues:

  • Two heading-map entries (Base Version, Acceleration via Numba) were added even though these headings were unchanged by the source diff - this corrects a prior omission rather than reflecting new content, which is slightly outside the diff scope but not incorrect.

This review was generated automatically by action-translation review mode.

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 automated translation sync updates the Chinese numba lecture to reflect upstream changes that migrate examples from np.random.* to the newer NumPy Generator API, including discussion of performance and parallel safety considerations in Numba.

Changes:

  • Updated Monte Carlo π examples to use pre-drawn samples and np.random.default_rng() (and added a new exercise/solution explaining RNG data races under prange).
  • Updated the Markov-chain simulation example to use a Generator-produced draw array passed into the function (instead of drawing inside).
  • Refreshed translation sync state metadata (source SHA, sync date, model, tool version).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
lectures/numba.md Updates translated lecture content and code cells to use Generator APIs and adds parallel RNG caveats/exercises.
.translate/state/numba.md.yml Updates translation sync metadata to match the upstream source commit and tooling.

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

Comment thread lectures/numba.md
Comment on lines +433 to +436
n = 1_000_000
rng = np.random.default_rng()
u_draws = rng.uniform(size=n)
v_draws = rng.uniform(size=n)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants