Skip to content

🌐 [translation-sync] Minor edits#54

Merged
HumphreyYang merged 10 commits intomainfrom
translation-sync-2026-04-13T00-09-37-pr-528
Apr 14, 2026
Merged

🌐 [translation-sync] Minor edits#54
HumphreyYang merged 10 commits intomainfrom
translation-sync-2026-04-13T00-09-37-pr-528

Conversation

@mmcky
Copy link
Copy Markdown
Contributor

@mmcky mmcky commented Apr 13, 2026

Automated Translation Sync

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

Source PR

#528 - Minor edits

Files Updated

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

⚠️ Sections Pending Earlier Translation PR

The following sections were not modified by this source PR and are missing from the target. They have been omitted from this PR to keep it scoped to the source PR's actual changes. An earlier translation PR should add them. If that PR is abandoned, run /translate-resync to recover.

  • lectures/jax_intro.md: Vectorization with \vmap`, Automatic differentiation: a preview`
  • lectures/numba.md: Sharp Bits
  • lectures/numpy_vs_numba_vs_jax.md: Overall recommendations

Details

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

This PR was created automatically by the translation action.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 13, 2026

✅ Translation Quality Review

Verdict: PASS | Model: claude-sonnet-4-6 | Date: 2026-04-14


📝 Translation Quality

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

Summary: The translation is of high quality across all modified sections. Technical accuracy is excellent, with correct rendering of JAX, Numba, and NumPy concepts. Fluency is natural and the academic register is appropriate throughout. Terminology follows the reference glossary consistently. Formatting is well-preserved with no syntax errors detected. Minor issues include slightly awkward phrasing in a few places (notably the broken English sentence in the JIT Compilation section and a word choice issue with '改善' vs '缩短'), but these do not significantly impact comprehension. Technical terminology is consistently and correctly translated throughout all modified sections, including JIT编译, 向量化, 纯函数, and domain-specific finance terms like 欧式看涨期权 and 随机波动率. The translation of the Exercises section accurately captures all parameters, mathematical notation, and instructions from the English source, including the Monte Carlo option pricing exercise. MyST directives, code blocks, LaTeX math equations, and cross-references are all preserved correctly with no formatting errors in the modified sections. The NumPy vs Numba vs JAX comparison sections (NumPy vectorization, A Comparison with Numba, Parallelized Numba, Vectorized code with JAX, JAX plus vmap, Summary, Numba Version, JAX Version, Summary) are fluently translated and maintain the technical accuracy of the performance comparisons. The preamble/frontmatter translation metadata is correctly structured with appropriate heading mappings, following the established translation sync system conventions.

Suggestions:

  • JIT Compilation section: '我们在 {ref}上文 <jax_speed> 中已经看到了 JAX 的 JIT 编译器结合并行硬件的强大之处,当时我们对一个大数组应用了 cos 函数。' → The English source reads 'We saw the power of JAX's JIT compiler combined with parallel hardware when we {ref}above <jax_speed>, when we applied cos to a large array.' The Chinese translation is accurate but slightly awkward due to the original English being a broken sentence. Consider: '我们在{ref}上文 <jax_speed>中看到了 JAX 的 JIT 编译器结合并行硬件的强大之处——当时我们对一个大数组应用了 cos 函数。'

  • Compiling the Whole Function section: '运行时间再次改善——现在是因为我们融合了所有操作,使编译器能够更积极地进行优化。' → The English 'The runtime has improved again --- now because we fused all the operations, allowing the compiler to optimize more aggressively.' is accurately translated, but '改善' (improve) is slightly softer than needed for a performance context. Consider '运行时间再次缩短' to more precisely convey that runtime decreased.

  • Summary (numpy_numba_jax): '虽然 Numba 令人印象深刻,但 JAX 的优势在于,对于完全向量化的运算,我们可以在配备硬件加速器的机器上运行完全相同的代码,并在无需额外努力的情况下获得所有收益。' → The phrase '并在无需额外努力的情况下获得所有收益' is slightly awkward. The English 'reap all the benefits without extra effort' could be rendered more naturally as '并无需额外工作即可获得所有收益'.

  • JAX Version section: '这段代码不易阅读,但本质上,lax.scan 反复调用 update 并将返回值 x_new 累积到一个数组中。' → The English says 'This code is not easy to read but, in essence, lax.scan repeatedly calls update and accumulates the returns x_new into an array.' The word '返回值' for 'returns' is acceptable but 'returns' here refers to the returned values from each call. '返回值 x_new' is accurate and clear.


🔍 Diff Quality

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

Summary: All three files are correctly modified with changes appearing in the right positions, document structure preserved, and heading maps accurately updated to reflect the restructured JIT Compilation section and new Size Experiment subsection.


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

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Automated zh-cn translation sync aligning several JAX/Numba-related lectures with upstream “Minor edits” updates.

Changes:

  • Updates lecture content in jax_intro.md, numba.md, and numpy_vs_numba_vs_jax.md (timing examples, structure, and wording).
  • Adjusts translation metadata (headings/anchors) in updated lecture front-matter.
  • Updates .translate/state/*.yml to reflect new upstream source SHA and sync state.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
lectures/numpy_vs_numba_vs_jax.md Updates vectorized/parallel/JAX/vmap sections and timing snippets; changes some example code.
lectures/numba.md Restructures the “Compiling Functions” section and updates anchors/headings.
lectures/jax_intro.md Restructures JIT compilation section and updates heading metadata; modifies examples.
.translate/state/numpy_vs_numba_vs_jax.md.yml Updates translation sync state (sha/date/mode/tool version/section count).
.translate/state/numba.md.yml Updates translation sync state (sha/date/mode/tool version/section count).
.translate/state/jax_intro.md.yml Updates translation sync state (sha/date/mode/tool version/section count).

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

Comment on lines 224 to +228
for j in range(n):
x = grid[i]
y = grid[j]
z = np.cos(x**2 + y**2) / (1 + x**2 + y**2)
if z > m:
m = z
m = max(m, z)
Copy link

Copilot AI Apr 13, 2026

Choose a reason for hiding this comment

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

compute_max_numba_parallel updates the shared variable m inside a numba.prange loop (m = max(m, z)), which is a data race and can return incorrect results. Use a thread-safe reduction pattern instead (e.g., compute per-i maxima into an array inside the prange loop and take np.max afterward, or use a supported Numba reduction).

Copilot uses AI. Check for mistakes.
Comment thread lectures/jax_intro.md Outdated
Comment on lines +18 to +20
JAX as a NumPy Replacement::Differences::Speed!: 精度
JAX as a NumPy Replacement::Differences::Precision: 不可变性
JAX as a NumPy Replacement::Differences::Immutability: 变通方法
Copy link

Copilot AI Apr 13, 2026

Choose a reason for hiding this comment

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

The translation heading mapping under JAX as a NumPy Replacement::Differences is inconsistent: Speed! is mapped to 精度, Precision to 不可变性, and Immutability to 变通方法, but the document section headings are 精度/不可变性/变通方法 (and there is no Speed! section). This will break navigation/translation alignment; please correct the heading keys/values to match the actual sections.

Suggested change
JAX as a NumPy Replacement::Differences::Speed!: 精度
JAX as a NumPy Replacement::Differences::Precision: 不可变性
JAX as a NumPy Replacement::Differences::Immutability: 变通方法
JAX as a NumPy Replacement::Differences::Precision: 精度
JAX as a NumPy Replacement::Differences::Immutability: 不可变性
JAX as a NumPy Replacement::Differences::Workarounds: 变通方法

Copilot uses AI. Check for mistakes.
Comment thread lectures/jax_intro.md
Comment on lines 499 to 503
```{code-cell}
def f(x):
y = jnp.cos(2 * x**2) + jnp.sqrt(jnp.abs(x)) + 2 * jnp.sin(x**4) - x**2
return y
```

Copy link

Copilot AI Apr 13, 2026

Choose a reason for hiding this comment

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

This code-cell block is missing a closing triple-backtick fence after the function definition, so the rest of the markdown will be parsed as code. Add the closing fence (and, if intended, put x = jnp.linspace(...) in its own subsequent code-cell).

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@copilot apply changes based on this feedback

Also deal with the merge conflict by only incorprate changes that are in QuantEcon/lecture-python-programming#528

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.

Merged main into this branch and resolved all merge conflicts by preserving earlier translation PR content and applying only PR #528 changes. Key fixes in bf85634:

  • Heading mapping: Fixed the shifted key/value alignment (Speed!→精度 is now correct: Precision→精度, Immutability→不可变性, etc.)
  • {ref} target: The (jax_speed)= label now exists from the earlier translation of the Speed! section, so the reference resolves correctly
  • Code cell structure: The function definition and x = jnp.linspace(0, 10, n) are correctly in the same code cell, matching upstream
  • JIT section: Removed the "simple example" subsection (now in Speed! section from earlier PR), restructured to match PR #528
  • Parallel Numba: Simplified to remove incorrect attempt and v2, keeping only the correct version with m = max(m, z)
  • Timer/comments: Updated qe.Timer(precision=8)qe.Timer(), added # First run/# Second run/# Hold interpreter comments throughout

Comment thread lectures/jax_intro.md Outdated
通常,运行时间会先增加然后再减少(这在 GPU 上会更加明显)。

这是因为 JIT 编译器针对数组大小进行专门优化以利用并行化——因此当数组大小改变时会生成新的编译代码。
当我们在 {ref}`上面 <jax_speed>` 对一个大型数组应用 `cos` 时,我们看到了 JAX 的 JIT 编译器结合并行硬件的强大之处。
Copy link

Copilot AI Apr 13, 2026

Choose a reason for hiding this comment

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

This {ref} target (<jax_speed>) is unresolved: there is no (jax_speed)= label in this file or elsewhere in the repo, so the reference will break during documentation build. Either reintroduce the missing label at the intended location (e.g., the earlier speed example) or remove/replace the reference with an existing label/section.

Suggested change
当我们在 {ref}`上面 <jax_speed>` 对一个大型数组应用 `cos` 时,我们看到了 JAX 的 JIT 编译器结合并行硬件的强大之处。
当前面我们对一个大型数组应用 `cos` 时,我们看到了 JAX 的 JIT 编译器结合并行硬件的强大之处。

Copilot uses AI. Check for mistakes.
Copilot AI and others added 2 commits April 14, 2026 00:13
Resolve merge conflicts by preserving earlier translation PR content
and applying only PR #528 specific changes:
- jax_intro.md: Restructure JIT section, add timer comments
- numba.md: Change int(n) to n
- numpy_vs_numba_vs_jax.md: Simplify parallel Numba section, update timers

Co-authored-by: HumphreyYang <39026988+HumphreyYang@users.noreply.github.com>
@HumphreyYang
Copy link
Copy Markdown
Member

@copilot Please handle the merge conflict again by only incorprate changes that are in QuantEcon/lecture-python-programming#528 and keep what's in the main for the rest

Resolve merge conflicts by keeping main's content as base and applying
only the specific changes from upstream PR #528 (Minor edits):

jax_intro.md:
- Update heading map (remove 'Evaluating a more complicated function', capitalize 'Whole', remove 'Summary')
- Restructure JIT section: remove subsection heading, promote sub-headings to ###
- Change 'the *entire* function' to 'the entire function'
- Fix jax_speed undefined label by removing duplicate (jax_speed)= target

numba.md:
- Change int(n) to n in three Timer calls

numpy_vs_numba_vs_jax.md:
- Replace qe.Timer(precision=8) with qe.Timer() throughout
- Change 'if z > m: m = z' to 'm = max(m, z)' in compute_max_numba
- Split code cells and add # First run/# Second run/# Hold interpreter comments
- Remove incorrect parallel attempt and v2 alternative
- Change static_argnums=(1,) to static_argnames=('n',)
- Condense note block text
- Various text tweaks to match upstream

Co-authored-by: HumphreyYang <39026988+HumphreyYang@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 14, 2026

@copilot Please handle the merge conflict again by only incorprate changes that are in QuantEcon/lecture-python-programming#528 and keep what's in the main for the rest

Re-merged main and applied only PR #528 changes in eacc764:

  • jax_intro.md: Updated heading map (removed "Evaluating a more complicated function" subsection, capitalized "Whole", removed "Summary"), restructured JIT section headings (#### → ###), changed *整个*整个. Also fixed jax_speed undefined label warning by removing the duplicate (jax_speed)= target at line 234 (kept the one at line 125).
  • numba.md: int(n)n in 3 places.
  • numpy_vs_numba_vs_jax.md: qe.Timer(precision=8)qe.Timer() throughout, if z > m: m = zm = max(m, z), removed incorrect parallel attempt + v2, split code cells with comments, static_argnumsstatic_argnames, text tweaks.
  • State files: Updated source-sha and synced-at.

Note: The duplicate "速度!" section (lines 126 vs 234) is a pre-existing issue in main from overlapping translation PRs — I left it untouched per your instruction to keep main content.

…ding

- Add #### 大小实验 heading to match English #### Size Experiment structure
- Remove duplicate #### 速度! section (was duplicated from overlapping translation PRs)
- Add Size Experiment entry to heading map in frontmatter

Agent-Logs-Url: https://github.com/QuantEcon/lecture-python-programming.zh-cn/sessions/9216d7c8-4733-4e5e-a1c5-74a4d6018ce1

Co-authored-by: HumphreyYang <39026988+HumphreyYang@users.noreply.github.com>
@HumphreyYang HumphreyYang merged commit 2006d74 into main Apr 14, 2026
2 checks passed
@HumphreyYang HumphreyYang deleted the translation-sync-2026-04-13T00-09-37-pr-528 branch April 14, 2026 01:48
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.

4 participants