Skip to content

Commit a717630

Browse files
mmckyclaude
andcommitted
Repair transplanted print lines and restore trailing newline
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>
1 parent fe9c98f commit a717630

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

lectures/samuelson.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ def analyze_roots(α, β, verbose=True):
539539
is_stable = all(abs(root) < 1 for root in roots)
540540
541541
if verbose:
542-
print(f'ρ_1 是 {ρ1}')
542+
print(f"ρ1 = {ρ1:.2f}, ρ2 = {ρ2:.2f}")
543543
print(f"根为: {[f'{root:.2f}' for root in roots]}")
544544
print(f"根的类型: {'复数' if is_complex else '实数'}")
545545
print(f"稳定性: {'稳定' if is_stable else '不稳定'}")
@@ -737,14 +737,14 @@ period = 10 # 时间单位中的周期长度
737737
# 应用反向推导函数
738738
ρ1, ρ2, α, β = f(r, ϕ)
739739
740-
print(f'ρ_2 是 {ρ2}')
741-
print(f'根为 {roots}')
740+
print(f"α, β = {α:.2f}, {β:.2f}")
741+
print(f"ρ1, ρ2 = {ρ1:.2f}, {ρ2:.2f}")
742742
```
743743

744744
根的实部为
745745

746746
```{code-cell} ipython3
747-
print(f'根的类型: {self.root_type()}')
747+
print(f"ρ1 = {ρ1.real:.2f}, ρ2 = {ρ2.real:.2f}")
748748
```
749749

750750
### 使用numpy求根
@@ -757,8 +757,8 @@ r1, r2 = np.roots([1, -ρ1, -ρ2])
757757
p1 = cmath.polar(r1)
758758
p2 = cmath.polar(r2)
759759
760-
print(f'解的类型: {self.solution_type()}')
761-
print(f'根: {str(self.roots)}')
760+
print(f"r, ϕ = {r:.2f}, {ϕ:.2f}")
761+
print(f"p1, p2 = ({p1[0]:.2f}, {p1[1]:.2f}), ({p2[0]:.2f}, {p2[1]:.2f})")
762762
763763
print(f"α, β = {α:.2f}, {β:.2f}")
764764
print(f"ρ1, ρ2 = {ρ1:.2f}, {ρ2:.2f}")
@@ -1351,4 +1351,4 @@ pure_multiplier.plot_irf(100)
13511351

13521352
我们看到不同的参数值会导致不同的输出路径,这些路径可能是平稳的、发散的或振荡的。
13531353

1354-
我们还能够使用[QuantEcon.py](https://quantecon.org/quantecon-py/)[LinearStateSpace](https://github.com/QuantEcon/QuantEcon.py/blob/master/quantecon/lss.py)类来表示该模型。
1354+
我们还能够使用[QuantEcon.py](https://quantecon.org/quantecon-py/)[LinearStateSpace](https://github.com/QuantEcon/QuantEcon.py/blob/master/quantecon/lss.py)类来表示该模型。

0 commit comments

Comments
 (0)