Skip to content

🌐 [translation-sync] [perm_income.md] Update np.random → Generator API#199

Merged
mmcky merged 2 commits into
mainfrom
translation-sync-2026-07-23T03-51-16-pr-975
Jul 23, 2026
Merged

🌐 [translation-sync] [perm_income.md] Update np.random → Generator API#199
mmcky merged 2 commits into
mainfrom
translation-sync-2026-07-23T03-51-16-pr-975

Conversation

@mmcky

@mmcky mmcky commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Automated Translation Sync

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

Source PR

#975 - [perm_income.md] Update np.random → Generator API

Files Updated

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

Details

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

This PR was created automatically by the translation action.

Copilot AI review requested due to automatic review settings July 23, 2026 03:51
@mmcky mmcky added action-translation PRs created by QuantEcon/action-translation automated Automated sync PR opened by action-translation labels Jul 23, 2026
@netlify

netlify Bot commented Jul 23, 2026

Copy link
Copy Markdown

Deploy Preview for astonishing-narwhal-a8fc64 ready!

Name Link
🔨 Latest commit efc7b28
🔍 Latest deploy log https://app.netlify.com/projects/astonishing-narwhal-a8fc64/deploys/6a618fb96b170a0008426ddf
😎 Deploy Preview https://deploy-preview-199--astonishing-narwhal-a8fc64.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions

Copy link
Copy Markdown

✅ Translation Quality Review

Verdict: PASS | Model: claude-sonnet-5 | Date: 2026-07-23
Routing: editor — diff check failed: positionCorrect


📝 Translation Quality

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

Summary: The translation of the 'A Simple Example with IID Income' section is accurate, fluent, and terminologically consistent with the glossary. Mathematical content and code blocks are faithfully preserved. Only minor stylistic nitpicks exist (e.g., slightly literal phrasing of 'realization'), and no blocking or major issues were found in this section. The mathematical notation and equations in the 'A Simple Example with IID Income' section are preserved accurately and completely. Technical terms such as '独立同分布', '高斯随机游走', and '非金融收入' are correctly and consistently translated per the glossary. The explanatory prose flows naturally in Chinese and faithfully conveys the logical structure of the original explanation about IID income, debt, and consumption dynamics.

Suggestions:

  • [minor · formatting] lectures/perm_income.md — #### A Simple Example with IID Income code cell: The code cell language tag was changed from python3 to ipython3 in the translated version (also seen in other unrelated cells), which is a formatting deviation from the source, though it may be an intentional project-wide convention unrelated to translation quality. → Confirm whether changing {code-cell} python3 to {code-cell} ipython3 is an intended systematic change; if not, keep it consistent with source.
  • [minor · fluency] lectures/perm_income.md — "因此,收入是独立同分布的,而债务和消费都是高斯随机游走。": Translation is accurate and fluent; no substantive issue, but note comment lines inside the code block ('# w_0, w_1, ..., w_T', '# Generate new time path') remain in English, which is consistent with typical practice of not translating code comments, so this is not an issue but worth confirming policy.
  • [nit · fluency] lectures/perm_income.md — "下图显示了一个典型的实现,其中 $r = 0.05$,$\mu = 1$,且 $\sigma = 0.15$": The phrase '一个典型的实现' is a slightly literal rendering of 'a typical realization' (in the statistical sense of a realization of a stochastic process). It is understandable but could be phrased more naturally. → 下图展示了在 $r = 0.05$,$\mu = 1$,且 $\sigma = 0.15$ 时的一次典型实现路径

🔍 Diff Quality

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

Summary: The translation metadata and prose are correctly preserved, but the actual source code changes (rng refactoring) were not applied to the target document's code cells, despite the file being flagged as modified.

Issues:

  • Source changed def time_path(T): to def time_path(T, rng): and replaced np.random.randn with rng.standard_normal, adding rng = np.random.default_rng() — but the target document's code cells in the 'IID Income' section remain unchanged (still using def time_path(T): and np.random.randn(T+1) with no rng parameter) in both before and after versions.
  • Source changed the second code cell's loop call from time_path(T) to time_path(T, rng) — but the target's corresponding loop call remains time_path(T) unchanged in both before and after.
  • The reported diff stats (+5/-5) do not match any visible content change between the target's before and after markdown, suggesting the actual code edits were not applied to the target file despite metadata indicating a change.

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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Syncs the zh-cn translation of perm_income.md with upstream changes that modernize random number generation to NumPy’s Generator API, keeping the lecture content aligned with the source repository and current NumPy usage.

Changes:

  • Update the lecture code cells to use np.random.default_rng() and rng.standard_normal(...) instead of legacy np.random.randn(...).
  • Thread the RNG object into time_path(...) calls so random draws come from the Generator.
  • Update translation sync state metadata (source SHA, sync date, model, tool version, mode).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
lectures/perm_income.md Switches example simulations from legacy np.random calls to the Generator API.
.translate/state/perm_income.md.yml Updates translation sync metadata to reflect the new upstream source commit and tooling.

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

@mmcky

mmcky commented Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

Reviewer note: the three structure findings above are wrong — this sync is correct

Recording this so nobody re-investigates it. The AI review routed this PR to editor for one reason, diff check failed: positionCorrect, and raised three structure findings asserting that the source's code changes were never applied here — including "the reported diff stats (+5/-5) do not match any visible content change between the target's before and after markdown, suggesting the actual code edits were not applied".

They were applied. Diffing QuantEcon/lecture-python.myst#975 against this PR shows the target carries the identical change:

Source change Present here
def time_path(T)def time_path(T, rng)
np.random.randn(T+1)rng.standard_normal(T+1)
added rng = np.random.default_rng()
both call sites → time_path(T, rng)

Nothing is missing, and the frontmatter state update (source-sha, synced-at, mode: UPDATE, tool-version: 0.22.0) is correct too.

The reviewer was not short of information — it is passed both the before and after of the source and the target, untruncated and with code intact, and the before/after are fetched from the base and head SHAs respectively. It was shown the change and reported its absence. Filed as QuantEcon/action-translation#148, with the note that positionCorrect is specified in prose terms ("do changes appear in the same sections as source") while this diff is entirely code, which may make code-only syncs a systematic weak spot.

What still deserves a human eye, since the structural findings being wrong does not make the review worthless:

  • the formatting finding about the code-cell language tag (python3 vs ipython3) is a real observation about this file, though it predates this PR;
  • the fluency findings are ordinary translation-quality suggestions, worth the usual judgement.

For context: this is the second organic sync PR since translation automation was turned on for this repo (QuantEcon/lecture-python.myst#979, merged today). The first, #198, was routed to editor for a genuinely correct reason — a glossary violation. Both are the first real production data for QuantEcon/action-translation#147.

@github-actions

Copy link
Copy Markdown

@github-actions
github-actions Bot temporarily deployed to pull request July 23, 2026 04:12 Inactive
@mmcky
mmcky merged commit 3869dfa into main Jul 23, 2026
10 of 12 checks passed
@mmcky
mmcky deleted the translation-sync-2026-07-23T03-51-16-pr-975 branch July 23, 2026 04:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action-translation PRs created by QuantEcon/action-translation automated Automated sync PR opened by action-translation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants