Skip to content

🌐 [translation-sync] [inventory_dynamics] Update code to JAX and latest style guide#198

Merged
mmcky merged 2 commits into
mainfrom
translation-sync-2026-07-23T03-48-42-pr-623
Jul 23, 2026
Merged

🌐 [translation-sync] [inventory_dynamics] Update code to JAX and latest style guide#198
mmcky merged 2 commits into
mainfrom
translation-sync-2026-07-23T03-48-42-pr-623

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

#623 - [inventory_dynamics] Update code to JAX and latest style guide

Files Updated

  • ✏️ lectures/inventory_dynamics.md
  • ✏️ .translate/state/inventory_dynamics.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 23, 2026 03:48
@mmcky mmcky added action-translation PRs created by QuantEcon/action-translation automated Automated sync PR opened by action-translation review jax-conversion improve 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 6d8ec79
🔍 Latest deploy log https://app.netlify.com/projects/astonishing-narwhal-a8fc64/deploys/6a618f1fb0e0d40008d63767
😎 Deploy Preview https://deploy-preview-198--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 — 1 minor finding(s) in gating categories (accuracy/terminology/syntax/other); terminology 8 below floor 9


📝 Translation Quality

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

Summary: This is a high-quality translation of the modified sections. Mathematics, code, and MyST directives are fully intact, and the technical content (JAX-related explanations, simulation logic, statistical concepts) is rendered accurately and fluently. Minor issues include a terminology inconsistency with the glossary ('边际分布' vs '边缘分布') and small stylistic deviations that do not affect comprehension. No syntax errors were found in the changed sections. Mathematical notation and code blocks are preserved accurately and completely across all changed sections Technical explanations (e.g., the note on JAX functional updates and XLA compilation) are translated clearly and accurately, preserving nuanced technical meaning Consistent and natural rendering of exercise and solution blocks, maintaining academic register throughout

Suggestions:

  • [minor · formatting] lectures/inventory_dynamics.md — ## Overview code-cell (imports): The translation's import code cell adds extra lines not present in the English source (font configuration via matplotlib, FONTPATH, plt.rcParams settings). While this may be part of a standard template for Chinese lecture rendering, it is an unexplained deviation from the source code cell content that a strict accuracy comparison would flag. → If this is a standard site-wide font-setup addition, consider noting it via a comment so reviewers understand it is intentional; otherwise align the code cell exactly with the English source.
  • [minor · terminology] lectures/inventory_dynamics.md — ## Marginal distributions: The glossary specifies 'Marginal distribution' → '边缘分布', but the translation consistently uses '边际分布' for both the heading and body text. This is a common alternative in economics/finance but is inconsistent with the provided glossary term. → Consider using '边缘分布' per the glossary, or note the deviation if '边际分布' is the established convention for this lecture series.
  • [minor · fluency] lectures/inventory_dynamics.md — ## Sample paths, 'Consider a firm with inventory': '假设有一个公司' translates 'Consider a firm' reasonably but '假设' (suppose/assume) shifts nuance slightly from 'consider'; not an error but a minor tone shift. → Could use '考虑一个拥有库存 $X_t$ 的公司' for closer fidelity.
  • [nit · fluency] lectures/inventory_dynamics.md — ## Overview, second paragraph: The phrase '这些企业遵循以下补货规则:' is added translator phrasing not directly present in the English ('Such firms'), slightly restructuring the sentence flow. This is a minor stylistic addition rather than a strict translation, though it does not change meaning. → Optional: '这些企业' followed directly by the numbered list to more closely mirror the source structure.

🔍 Diff Quality

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

Summary: The translation sync correctly mirrors all source changes (JAX rewrite, font setup, heading case changes, code reordering) in the same relative positions with proper heading-map key updates.


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 inventory_dynamics lecture to match upstream changes that migrate the computational examples from NumPy/Numba to JAX and align formatting with the latest style guide, along with updating the translation state metadata.

Changes:

  • Update translation metadata headings to match upstream casing (“Sample paths”, “Marginal distributions”).
  • Replace NumPy/Numba simulation code with JAX (jit, vmap, lax.fori_loop) and related refactors in code cells.
  • Refresh 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/inventory_dynamics.md Sync lecture content to upstream JAX-based implementation and style updates.
.translate/state/inventory_dynamics.md.yml Update translation-sync bookkeeping metadata to the new upstream source SHA/date/tooling.

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

sample_dates = 0, 10, 50, 250, 500, 750

first_diffs = np.diff(sample_dates)
first_diffs = jnp.diff(jnp.array(sample_dates))
@github-actions

Copy link
Copy Markdown

@github-actions
github-actions Bot temporarily deployed to pull request July 23, 2026 04:09 Inactive
@mmcky
mmcky merged commit 161fbdd into main Jul 23, 2026
16 of 18 checks passed
@mmcky
mmcky deleted the translation-sync-2026-07-23T03-48-42-pr-623 branch July 23, 2026 04:42
mmcky added a commit that referenced this pull request Jul 23, 2026
The AI review on #198 flagged this and the PR merged before it was fixed, so
the term is currently on main.

The glossary is explicit and context-aware: "Marginal distribution" maps to
边缘分布 tagged `"context": "probability"`, while every economics sense
correctly keeps 边际 — 边际产量, 边际消费倾向, 边际收入, 边际效用. This
lecture uses the probability sense throughout: ψ_T is the distribution of
X_T at a fixed time T, and the later reference is to the sequence {ψ_t}
converging to a limiting distribution. 边缘分布 is the standard mathematical
term for that; 边际 is "marginal" as in marginal cost.

Four occurrences: the H2 heading, its heading-map value, and two body
references. The heading-map value is updated alongside the heading
deliberately — leaving them out of step would make the next sync mis-map the
section.
mmcky added a commit to QuantEcon/action-translation that referenced this pull request Jul 23, 2026
#149) (#150)

`forward` and `init` resolved glossary candidates only against
`process.cwd()`. The built-in glossaries ship inside this package and no
edition repository carries one, so a resync launched from the target repo
— or a bench root, or anywhere a globally installed CLI is naturally
invoked — translated with no glossary at all. Nothing was logged either
way and a bare `catch {}` swallowed parse errors, so a run that dropped
terminology enforcement was indistinguishable from one that applied it.
That unobservability is the worst of it: it made the difference
unauditable after the fact.

The production signature matches exactly. In lecture-python.zh-cn the
`init`-seeded lectures all use the glossary's 边缘分布 for "Marginal
distribution", while the 2026-07-19 `forward` wave took prob_matrix.md
from 12 wrong / 28 correct to 25 wrong / 35 correct — newly generated
text ignoring a glossary entry that exists. See
QuantEcon/lecture-python.zh-cn#198 for the review finding.

Resolution now lives in one testable module shared by both commands, with
the packaged directory resolved relative to the installed CLI and threaded
in as an option — `import.meta.url` cannot be loaded by the Jest CJS
module registry, so the entry point resolves it and the logic stays unit
testable.

- precedence: --glossary → repo-local glossary/<lang>.json → built-in
- every outcome reported: the origin, term count and path on success; a
  warning naming every path tried when a language has no glossary anywhere
- loud on failure: a missing or malformed --glossary is a hard error, not
  a silent fallback to different terminology, and any candidate that
  exists but does not parse is an error rather than a fall-through
- bulk resolves once before the first file, so a bad glossary stops the
  wave instead of surfacing after N files have been resynced against
  nothing
- `forward --glossary <path>` added, matching `init` — the resync path
  previously had no override at all

21 new tests: CWD-independence, precedence, the throw paths, and what the
translator actually receives on the resync path from a working directory
with no glossary.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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 improve jax-conversion review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants