Skip to content

Commit ab7f62f

Browse files
authored
[FIX] Fix SyntaxWarnings from matplotlib raw string (#150)
1 parent 8e75d2d commit ab7f62f

19 files changed

+53
-53
lines changed

lectures/ar1_processes.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ for t in range(sim_length):
173173
mu = a * mu + b
174174
v = a**2 * v + c**2
175175
ax.plot(grid, norm.pdf(grid, loc=mu, scale=np.sqrt(v)),
176-
label=f"$\psi_{t}$",
176+
label=fr"$\psi_{t}$",
177177
alpha=0.7)
178178
179179
ax.legend(bbox_to_anchor=[1.05,1],loc=2,borderaxespad=1)
@@ -255,7 +255,7 @@ plot_density_seq(ax, mu_0=4.0)
255255
mu_star = b / (1 - a)
256256
std_star = np.sqrt(c**2 / (1 - a**2)) # v_star的平方根
257257
psi_star = norm.pdf(grid, loc=mu_star, scale=std_star)
258-
ax.plot(grid, psi_star, 'k-', lw=2, label="$\psi^*$")
258+
ax.plot(grid, psi_star, 'k-', lw=2, label=r"$\psi^*$")
259259
ax.legend()
260260
261261
plt.show()

lectures/cobweb.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ def plot45(model, pmin, pmax, p0, num_arrows=5):
240240
241241
ax.plot(pgrid, g(model, pgrid), 'b-',
242242
lw=2, alpha=0.6, label='g')
243-
ax.plot(pgrid, pgrid, lw=1, alpha=0.7, label='$45\degree$')
243+
ax.plot(pgrid, pgrid, lw=1, alpha=0.7, label=r'$45\degree$')
244244
245245
x = p0
246246
xticks = [pmin]

lectures/eigen_I.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,13 +204,13 @@ def grid_transform(A=np.array([[1, -1], [1, 1]])):
204204
ax[0].scatter(xygrid[0], xygrid[1], s=36, c=colors, edgecolor="none")
205205
# ax[0].grid(True)
206206
# ax[0].axis("equal")
207-
ax[0].set_title("点 $x_1, x_2, \cdots, x_k$")
207+
ax[0].set_title(r"点 $x_1, x_2, \cdots, x_k$")
208208
209209
# 绘制变换的格点
210210
ax[1].scatter(uvgrid[0], uvgrid[1], s=36, c=colors, edgecolor="none")
211211
# ax[1].grid(True)
212212
# ax[1].axis("equal")
213-
ax[1].set_title("点 $Ax_1, Ax_2, \cdots, Ax_k$")
213+
ax[1].set_title(r"点 $Ax_1, Ax_2, \cdots, Ax_k$")
214214
215215
plt.show()
216216
@@ -245,7 +245,7 @@ def circle_transform(A=np.array([[-1, 2], [0, 1]])):
245245
ax[0].plot(x, y, color='black', zorder=1)
246246
ax[0].scatter(a_1, b_1, c=colors, alpha=1, s=60,
247247
edgecolors='black', zorder=2)
248-
ax[0].set_title("在 $\mathbb{R}^2$的单位圆")
248+
ax[0].set_title(r"在 $\mathbb{R}^2$的单位圆")
249249
250250
x1 = x.reshape(1, -1)
251251
y1 = y.reshape(1, -1)

lectures/equalizing_difference.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ from sympy import Symbol, Lambda, symbols
357357
358358
359359
```{code-cell} ipython3
360-
γ_h, γ_c, w_h0, D = symbols('\gamma_h, \gamma_h_c, w_0^h, D', real=True)
360+
γ_h, γ_c, w_h0, D = symbols(r'\gamma_h, \gamma_h_c, w_0^h, D', real=True)
361361
R, T = Symbol('R', real=True), Symbol('T', integer=True)
362362
```
363363

lectures/geom_series.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,7 @@ T_max = 10
686686
T=np.arange(0, T_max+1)
687687
688688
rs, gs = (0.9, 0.5, 0.4001, 0.4), (0.4, 0.4, 0.4, 0.5),
689-
comparisons = ('$\gg$', '$>$', r'$\approx$', '$<$')
689+
comparisons = ('r$\gg$', '$>$', r'$\approx$', '$<$')
690690
for r, g, comp in zip(rs, gs, comparisons):
691691
ax.plot(finite_lease_pv_true(T, g, r, x_0), label=f'r(={r}) {comp} g(={g})')
692692

lectures/greek_square.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ fig, axs = plt.subplots(1, 2, figsize=(12, 6), dpi=500)
666666
axs[0].plot(np.round(ratios_λ1, 6),
667667
label=r'$\frac{y_t}{y_{t-1}}$', linewidth=3)
668668
axs[0].axhline(y=Λ[1], color='red', linestyle='--',
669-
label='$\lambda_2$', alpha=0.5)
669+
label=r'$\lambda_2$', alpha=0.5)
670670
axs[0].set_xlabel('t', size=18)
671671
axs[0].set_ylabel(r'$\frac{y_t}{y_{t-1}}$', size=18)
672672
axs[0].set_title(r'$\frac{y_t}{y_{t-1}}$ 在失活 $\lambda_1$之后',
@@ -677,7 +677,7 @@ axs[0].legend()
677677
axs[1].plot(ratios_λ2, label=r'$\frac{y_t}{y_{t-1}}$',
678678
linewidth=3)
679679
axs[1].axhline(y=Λ[0], color='green', linestyle='--',
680-
label='$\lambda_1$', alpha=0.5)
680+
label=r'$\lambda_1$', alpha=0.5)
681681
axs[1].set_xlabel('t', size=18)
682682
axs[1].set_ylabel(r'$\frac{y_t}{y_{t-1}}$', size=18)
683683
axs[1].set_title(r'$\frac{y_t}{y_{t-1}}$ 在失活 $\lambda_2$之后',

lectures/heavy_tails.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ for ax, s in zip(axes[:2], s_vals):
335335
data = np.random.randn(n) * s
336336
ax.plot(list(range(n)), data, linestyle='', marker='o', alpha=0.5, ms=4)
337337
ax.vlines(list(range(n)), 0, data, lw=0.2)
338-
ax.set_title(f"从 $N(0, \sigma^2)$ 抽取,$\sigma = {s}$", fontsize=11)
338+
ax.set_title(fr"从 $N(0, \sigma^2)$ 抽取,$\sigma = {s}$", fontsize=11)
339339
340340
ax = axes[2]
341341
distribution = cauchy()

lectures/inequality.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ mystnb:
487487
fix, ax = plot_inequality_measures(σ_vals,
488488
ginis,
489489
'模拟数据',
490-
'$\sigma$',
490+
r'$\sigma$',
491491
'基尼系数')
492492
plt.show()
493493
```
@@ -838,7 +838,7 @@ ax.plot(years, df_topshares["topshare_n_wealth"],
838838
ax.plot(years, df_topshares["topshare_t_income"],
839839
marker='o', label="总收入")
840840
ax.set_xlabel("年份")
841-
ax.set_ylabel("前 $10\%$ 比例")
841+
ax.set_ylabel(r"前 $10\%$ 比例")
842842
ax.legend()
843843
plt.show()
844844
```
@@ -908,8 +908,8 @@ mystnb:
908908
fig, ax = plot_inequality_measures(σ_vals,
909909
topshares,
910910
"模拟数据",
911-
"$\sigma$",
912-
"前 $10\%$ 比例")
911+
r"$\sigma$",
912+
r"前 $10\%$ 比例")
913913
plt.show()
914914
```
915915

@@ -942,7 +942,7 @@ mystnb:
942942
fig, ax = plt.subplots()
943943
ax.plot([0,1],[0,1], label=f"平等线")
944944
for i in range(len(f_vals)):
945-
ax.plot(f_vals[i], l_vals[i], label=f"$\sigma$ = {σ_vals[i]}")
945+
ax.plot(f_vals[i], l_vals[i], label=fr"$\sigma$ = {σ_vals[i]}")
946946
plt.legend()
947947
plt.show()
948948
```
@@ -995,7 +995,7 @@ ax.plot(years, df_topshares["topshare_n_wealth"], marker='o', label="净财富
995995
ax.plot(years, top_shares_nw, marker='o', label="净财富-洛伦兹曲线")
996996
997997
ax.set_xlabel("年份")
998-
ax.set_ylabel("前 $10\%$ 比例")
998+
ax.set_ylabel(r"前 $10\%$ 比例")
999999
ax.legend()
10001000
plt.show()
10011001
```

lectures/input_output.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,9 @@ ax.plot(np.linspace(55, 380, 100), (50-0.9*np.linspace(55, 380, 100))/(-1.46), c
201201
ax.plot(np.linspace(-1, 400, 100), (60+0.16*np.linspace(-1, 400, 100))/0.83, color="r")
202202
ax.plot(np.linspace(250, 395, 100), (62-0.04*np.linspace(250, 395, 100))/0.33, color="b")
203203
204-
ax.text(130, 38, "$(1-a_{11})x_1 + a_{12}x_2 \geq d_1$", size=10)
205-
ax.text(10, 105, "$-a_{21}x_1 + (1-a_{22})x_2 \geq d_2$", size=10)
206-
ax.text(150, 150, "$a_{01}x_1 +a_{02}x_2 \leq x_0$", size=10)
204+
ax.text(130, 38, r"$(1-a_{11})x_1 + a_{12}x_2 \geq d_1$", size=10)
205+
ax.text(10, 105, r"$-a_{21}x_1 + (1-a_{22})x_2 \geq d_2$", size=10)
206+
ax.text(150, 150, r"$a_{01}x_1 +a_{02}x_2 \leq x_0$", size=10)
207207
208208
# 绘制可行区域
209209
feasible_set = Polygon(np.array([[301, 151],
@@ -445,8 +445,8 @@ ax.vlines(0, -1, 250)
445445
ax.plot(np.linspace(4.75, 49, 100), (4-0.9*np.linspace(4.75, 49, 100))/(-0.16), color="r")
446446
ax.plot(np.linspace(0, 50, 100), (33+1.46*np.linspace(0, 50, 100))/0.83, color="r")
447447
448-
ax.text(15, 175, "$(1-a_{11})p_1 - a_{21}p_2 \leq a_{01}w$", size=10)
449-
ax.text(30, 85, "$-a_{12}p_1 + (1-a_{22})p_2 \leq a_{02}w$", size=10)
448+
ax.text(15, 175, r"$(1-a_{11})p_1 - a_{21}p_2 \leq a_{01}w$", size=10)
449+
ax.text(30, 85, r"$-a_{12}p_1 + (1-a_{22})p_2 \leq a_{02}w$", size=10)
450450
451451
# 绘制可行区域
452452
feasible_set = Polygon(np.array([[17, 69],

lectures/intro_supply_demand.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ ab_grid = np.linspace(a, b, 400)
330330
fig, ax = plt.subplots()
331331
ax.plot(x_grid, f(x_grid), label="$f$", color="k")
332332
ax.fill_between(ab_grid, [0] * len(ab_grid), f(ab_grid),
333-
label="$\int_a^b f(x) dx$")
333+
label=r"$\int_a^b f(x) dx$")
334334
ax.legend()
335335
plt.show()
336336
```

0 commit comments

Comments
 (0)