Skip to content

🌐 [translation-sync] [mccall_q.md] Update np.random → Generator API - #229

Open
mmcky wants to merge 2 commits into
mainfrom
translation-sync-2026-07-31T23-29-05-pr-959
Open

🌐 [translation-sync] [mccall_q.md] Update np.random → Generator API#229
mmcky wants to merge 2 commits into
mainfrom
translation-sync-2026-07-31T23-29-05-pr-959

Conversation

@mmcky

@mmcky mmcky commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Automated Translation Sync

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

Source PR

#959 - [mccall_q.md] Update np.random → Generator API

Files Updated

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

Details

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

This PR was created automatically by the translation action.

@mmcky
mmcky requested review from Copilot July 31, 2026 23:29
@mmcky mmcky added action-translation PRs created by QuantEcon/action-translation automated Automated sync PR opened by action-translation labels Jul 31, 2026
@netlify

netlify Bot commented Jul 31, 2026

Copy link
Copy Markdown

Deploy Preview for astonishing-narwhal-a8fc64 ready!

Name Link
🔨 Latest commit 6d9612b
🔍 Latest deploy log https://app.netlify.com/projects/astonishing-narwhal-a8fc64/deploys/6a6d2fc6e3dabf00078314c3
😎 Deploy Preview https://deploy-preview-229--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-31
Routing: editor — 2 minor finding(s) in gating categories (accuracy/terminology/syntax/diff-check/other); terminology 8 below floor 9


📝 Translation Quality

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

Summary: The translation of the Overview and Q-Learning sections is accurate, fluent, and largely faithful to the source, with correct handling of complex mathematical exposition and MyST formatting. Minor issues include a slight terminology conflation between 'gain parameter' and 'learning rate', a small restructuring in the Overview that adds minor interpretive phrasing not in the source, and a somewhat fragmented sentence describing the experimentation mechanism. None of these rise to the level of accuracy-threatening errors, and no syntax errors were found. Technical and mathematical content in the Overview and Q-Learning sections is accurately preserved, including all LaTeX equations and cross-references. Key terminology (Q-函数, Q-表, 时序差分学习, 时序差分误差, ε-贪婪算法) is applied consistently and matches standard usage in the field. Code comments were appropriately translated where relevant (e.g., progress print statements, docstrings) without altering code logic. Long, complex English sentences in the Q-Learning section are competently broken into readable Chinese sentences while preserving technical precision.

Suggestions:

  • [minor · accuracy] lectures/mccall_q.md — ## Overview, '在本讲中,我们将Q学习算法应用到McCall求职模型中...': The English source has two distinct sentences: one stating the lecture applies Q-learning to the McCall worker's situation, and another (separate) sentence noting the lecture also considers the quit option. The translation merges the first sentence with added interpretive content ('探讨劳动者如何通过这种方法做出最优决策') not present in the source, and restructures rather than directly translating both sentences. → 本讲将Q学习算法应用于McCall劳动者所面临的情形。本讲还考虑了McCall劳动者被赋予选择辞去当前工作的情况。
  • [minor · terminology] lectures/mccall_q.md — ## Q-Learning, 'A quality function...gain**参数': The English term 'gain parameter' is translated as '学习率' (learning rate), which conflates it with the separate 'lr'/'learning rate α' parameter used later in the code and text. This creates a terminology inconsistency between the informal 'gain' concept in eq:old106 and the formally named learning rate α introduced afterward. → 使用「增益参数」或保留「gain 参数」而不是「学习率」参数,以避免与后文的学习率 α 混淆
  • [minor · fluency] lectures/mccall_q.md — ## Q-Learning, '来添加这一特征。': The sentence describing random experimentation is split awkwardly across a long passage with two block equations pairs, ending with a short trailing clause '来添加这一特征' that reads as fragmented compared to the more integrated original English sentence structure. → Consider restructuring to make the connection between the experimentation description and the addition to the algorithm clearer, e.g., integrating the introductory clause with the final summary sentence.
  • [nit · terminology] lectures/mccall_q.md — ## Q-Learning, pseudocode step 4-5: Minor inconsistency: 'draw a new state' in step 5 is translated somewhat freely as '抽取新的状态', which is fine, but the parallel construction with step 2 ('从F中抽取初始工资报价w') could be made more consistent by using the same verb phrasing for 'draw'. → No major change needed; this is a very minor stylistic note.

🔍 Diff Quality

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

Summary: The RNG refactor (np.random.seed -> np.random.default_rng passed explicitly) was correctly and completely mirrored in the Chinese translation at all matching locations, with structure and heading metadata unaffected.


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

This automated translation-sync PR updates the Chinese lecture mccall_q.md to match upstream changes that migrate legacy np.random.* usage toward the newer np.random.Generator API, and updates the translation sync state metadata accordingly.

Changes:

  • Replaced global np.random.seed(...) / np.random.random() usage with a rng = np.random.default_rng(...) and rng.random() in the Q-learning section.
  • Threaded the rng object through Q-learning helper methods and the epoch runner.
  • Updated 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 2 comments.

File Description
lectures/mccall_q.md Migrates randomness in the Q-learning example toward the Generator API by introducing and passing an rng.
.translate/state/mccall_q.md.yml Updates translation-sync bookkeeping metadata (source SHA/date/mode/tool version).
Suppressed comments (4)

lectures/mccall_q.md:570

  • run_epochs@jit 编译后,目前把 rng 传入并调用 qlmc.run_one_epoch(qtable, rng),这同样会将 Generator 传入 jitclass 方法。若按上面建议移除 rng,这里也需要同步调整函数签名与调用。
def run_epochs(N, qlmc, qtable, rng):

lectures/mccall_q.md:673

  • 上面若移除了 run_one_epoch(..., rng)rng 参数,这里也需要同步更新调用,否则会出现参数个数不匹配。
        new_qtable = qlmc_new.run_one_epoch(qtable, rng)

lectures/mccall_q.md:596

  • 上面若移除了 run_epochs(..., rng)rng 参数,这里的调用也需要相应更新,否则会出现参数个数不匹配。
qtable = run_epochs(20000, qlmc, qtable0, rng)

lectures/mccall_q.md:533

  • 同上,run_one_epoch 作为 jitclass 方法目前依赖 rng.random() 并把 rng 传给 temp_diff / draw_offer_index。这会把 np.random.Generator 引入 numba 编译域,通常会直接编译失败。建议移除 rng 参数,并在方法内改回 np.random.random()
    def run_one_epoch(self, qtable, rng, max_times=20000):
        """
        运行一个"轮次"。
        """


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

Comment thread lectures/mccall_q.md
plt.rcParams['font.family'] = ['Source Han Serif SC']

np.random.seed(123)
rng = np.random.default_rng(123)
Comment thread lectures/mccall_q.md


def draw_offer_index(self):
def draw_offer_index(self, rng):
@github-actions

github-actions Bot commented Aug 1, 2026

Copy link
Copy Markdown

@github-actions
github-actions Bot temporarily deployed to pull request August 1, 2026 00:10 Inactive
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