[action-translation] resync: samuelson.md#150
Conversation
✅ Deploy Preview for astonishing-narwhal-a8fc64 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Pull request overview
This PR forward-resyncs the Chinese lecture lectures/samuelson.md to match the current upstream English source, including updated/refactored example code (unified root analysis + simulation helpers) and refreshed narrative/formatting. It also records the sync state in .translate/state/samuelson.md.yml.
Changes:
- Resynced
samuelson.mdcontent and code cells to the upstream structure (e.g., addedanalyze_roots/simulate_samuelson, refactored stochastic/government-spending examples, updated class implementations). - Updated MyST/JupyterBook cell metadata formatting (
ipython3,:tags:blocks) and refreshed various text/math expressions. - Added translation sync state metadata file for traceability.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| lectures/samuelson.md | Whole-document resync: substantial narrative + code refactor to align with upstream lecture structure. |
| .translate/state/samuelson.md.yml | Records the upstream source SHA, sync date, and tool metadata for the resync. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # 确定根的性质 | ||
| is_complex = all(isinstance(root, complex) for root in roots) | ||
| is_stable = all(abs(root) < 1 for root in roots) | ||
|
|
||
| if verbose: | ||
| print(f"ρ1 = {ρ1:.2f}, ρ2 = {ρ2:.2f}") | ||
| print(f"根为: {[f'{root:.2f}' for root in roots]}") | ||
| print(f"根的类型: {'复数' if is_complex else '实数'}") | ||
| print(f"稳定性: {'稳定' if is_stable else '不稳定'}") | ||
| print(f"解的类型: {solution_type}") |
| print(f"解的类型: {analysis['solution_type']}") | ||
| print(f"根为 {[f'{root:.2f}' for root in analysis['roots']]}") | ||
| print(f"根的类型: {'复数' if analysis['is_complex'] else '实数'}") |
| .. math:: | ||
|
|
||
| Y_t = + (α + β) Y_{t-1} - β Y_{t-2} | ||
| Y_t = \alpha (1 + \beta) Y_{t-1} - \alpha \beta Y_{t-2} | ||
|
|
| # 在图例中显示特征值 | ||
| for i, root in enumerate(self.roots): | ||
| if isinstance(root, complex): | ||
| # 需要为正数填充运算符,因为字符串被分开 | ||
| operator = ['+', ''] | ||
| label = rf'$\lambda_{i+1} = {sam.roots[i].real:.2f} {operator[i]} {sam.roots[i].imag:.2f}i$' | ||
| else: | ||
| label = rf'$\lambda_{i+1} = {sam.roots[i].real:.2f}$' | ||
| ax.scatter(0, 0, 0, label=label) # 虚拟点以添加到图例 | ||
|
|
||
| # 在图中添加ρ对 | ||
| ax.scatter(self.ρ1, self.ρ2, 100, 'red', '+', | ||
| label=r'$(\ \rho_1, \ \rho_2 \ )$', zorder=5) | ||
| # 处理复数显示的符号格式 | ||
| operator = ["+", ""] | ||
| root_real = self.roots[i].real | ||
| root_imag = self.roots[i].imag | ||
| label = ( | ||
| rf"$\lambda_{i+1} = {root_real:.2f}" | ||
| rf"{operator[i]} {root_imag:.2f}i$" | ||
| ) |
| for ax, series, title, color in zip(axes, y, titles, colors): | ||
| ax.plot(series, color=color) | ||
| ax.set(title=title, xlim=(0, n)) | ||
| ax.grid() | ||
|
|
||
| axes[-1].set_xlabel('迭代次数') | ||
| axes[-1].set_xlabel("迭代次数") | ||
| plt.show() |
|
|
||
| return fig | ||
| axes[0].set_title("脉冲响应函数") | ||
| axes[-1].set_xlabel("迭代次数") | ||
| plt.show() |
Re-applies Chinese code comments / print strings / plot labels that the resync reverted to English while the surrounding code is unchanged (action-translation#107 field validation, Track B wave). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Four print statements were carried over from the old class-based Samuelson lecture and reference names (self, module-level roots) that do not exist in the refactored upstream code, raising NameError at runtime. Restored upstream's print lines; also dropped-format-spec repair inside analyze_roots. Adds the missing trailing newline (engine issue tracked in QuantEcon/action-translation#116). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
✅ Translation Quality ReviewVerdict: PASS | Model: claude-sonnet-5 | Date: 2026-07-18 📝 Translation Quality
Summary: This is a high-quality, comprehensive resync translation that accurately preserves the mathematical content, code, and structure of the original document while maintaining natural, fluent Chinese academic prose and consistent terminology per the glossary. Minor issues include a few added inline code comments not present in the source and slightly imprecise wording for 'variance' in one code comment, but these do not affect overall comprehension or accuracy significantly. Mathematical notation, LaTeX equations, and code blocks are preserved accurately throughout the resynced document Technical terminology (特征多项式, 特征值, 稳态, 边际消费倾向, 加速系数, etc.) is applied consistently and matches the glossary The translation reads fluently and naturally in academic Simplified Chinese, with appropriate register for a technical economics lecture Section headings and structure align well with the English source, and the added YAML translation metadata block is correctly formatted per the sync system's requirements Suggestions:
🔍 Diff Quality
Summary: The target document was correctly resynced to match the current source structure, content, and code cells, with an accurate translation metadata block added. This review was generated automatically by action-translation review mode. |
Forward Resync: samuelson.md
Source: QuantEcon/lecture-python.myst — lectures/samuelson.md
Source commit:
089e35cThis PR resyncs the translation to match the current source document.
Reason: The Chinese translation uses an older, significantly different code structure (separate functions like categorize_solution printing directly, y_stochastic_g with inline transition logic, Samuelson class without simulate_samuelson helper) rather than the refactored unified functions (analyze_roots, simulate_samuelson) present in the English source. This means substantial code content differs on both sides: TARGET contains code/logic not in SOURCE (e.g., old-style categorize_solution printing strings, _transition method, old y_stochastic_g implementation, LSS class without μ_0/Σ_0 property aliases), while SOURCE contains newer unified functions and docstrings not reflected in TARGET. Additionally TARGET adds font-setup code (mpl.font_manager, FONTPATH) and grid() calls not in SOURCE. These are substantive code differences beyond mere translation, so TARGET_HAS_ADDITIONS applies alongside content changes.
Changes
Whole-file resync applied. The entire document was resynced in a single pass.
Created by action-translation forward resync