Skip to content

Commit 5833863

Browse files
authored
[FIX] Fix String Warnings (#194)
* update strings * update a few missing cases
1 parent 8952e74 commit 5833863

11 files changed

+44
-44
lines changed

lectures/BCG_complete_mkts.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -1090,8 +1090,8 @@ epsgrid = np.linspace(-1,1,1000)
10901090
10911091
10921092
fig, ax = plt.subplots(1,2,figsize=(14,6))
1093-
ax[0].plot(epsgrid, mdl1.w11(epsgrid), color='black', label='Agent 1\'s endowment')
1094-
ax[0].plot(epsgrid, mdl1.w21(epsgrid), color='blue', label='Agent 2\'s endowment')
1093+
ax[0].plot(epsgrid, mdl1.w11(epsgrid), color='black', label=r'Agent 1\'s endowment')
1094+
ax[0].plot(epsgrid, mdl1.w21(epsgrid), color='blue', label=r'Agent 2\'s endowment')
10951095
ax[0].plot(epsgrid, mdl1.Y(epsgrid,1), color='red', label=r'Production with $k=1$')
10961096
ax[0].set_xlim([-1,1])
10971097
ax[0].set_ylim([0,7])
@@ -1100,8 +1100,8 @@ ax[0].set_title(r'Model with $\chi_1 = 0$, $\chi_2 = 0.9$')
11001100
ax[0].legend()
11011101
ax[0].grid()
11021102
1103-
ax[1].plot(epsgrid, mdl2.w11(epsgrid), color='black', label='Agent 1\'s endowment')
1104-
ax[1].plot(epsgrid, mdl2.w21(epsgrid), color='blue', label='Agent 2\'s endowment')
1103+
ax[1].plot(epsgrid, mdl2.w11(epsgrid), color='black', label=r'Agent 1\'s endowment')
1104+
ax[1].plot(epsgrid, mdl2.w21(epsgrid), color='blue', label=r'Agent 2\'s endowment')
11051105
ax[1].plot(epsgrid, mdl2.Y(epsgrid,1), color='red', label=r'Production with $k=1$')
11061106
ax[1].set_xlim([-1,1])
11071107
ax[1].set_ylim([0,7])

lectures/arma.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ for i, ϕ in enumerate((0.8, -0.8)):
241241
times = list(range(16))
242242
acov = [ϕ**k / (1 - ϕ**2) for k in times]
243243
ax.plot(times, acov, 'bo-', alpha=0.6,
244-
label=f'autocovariance, $\phi = {ϕ:.2}$')
244+
label=fr'autocovariance, $\phi = {ϕ:.2}$')
245245
ax.legend(loc='upper right')
246246
ax.set(xlabel='time', xlim=(0, 15))
247247
ax.hlines(0, 0, 15, linestyle='--', alpha=0.5)
@@ -479,7 +479,7 @@ for i, ϕ in enumerate((0.8, -0.8)):
479479
ax = axes[i]
480480
sd = ar1_sd(ϕ, ωs)
481481
ax.plot(ωs, sd, 'b-', alpha=0.6, lw=2,
482-
label='spectral density, $\phi = {ϕ:.2}$')
482+
label=fr'spectral density, $\phi = {ϕ:.2}$')
483483
ax.legend(loc='upper center')
484484
ax.set(xlabel='frequency', xlim=(0, np.pi))
485485
plt.show()
@@ -525,21 +525,21 @@ plt.subplots_adjust(hspace=0.25)
525525
526526
# Autocovariance when ϕ = -0.8
527527
ax = axes[0]
528-
ax.plot(times, y1, 'bo-', alpha=0.6, label='$\gamma(k)$')
528+
ax.plot(times, y1, 'bo-', alpha=0.6, label=r'$\gamma(k)$')
529529
ax.legend(loc='upper right')
530530
ax.set(xlim=(0, 15), yticks=(-2, 0, 2))
531531
ax.hlines(0, 0, 15, linestyle='--', alpha=0.5)
532532
533533
# Cycles at frequency π
534534
ax = axes[1]
535-
ax.plot(times, y2, 'bo-', alpha=0.6, label='$\cos(\pi k)$')
535+
ax.plot(times, y2, 'bo-', alpha=0.6, label=r'$\cos(\pi k)$')
536536
ax.legend(loc='upper right')
537537
ax.set(xlim=(0, 15), yticks=(-1, 0, 1))
538538
ax.hlines(0, 0, 15, linestyle='--', alpha=0.5)
539539
540540
# Product
541541
ax = axes[2]
542-
ax.stem(times, y3, label='$\gamma(k) \cos(\pi k)$')
542+
ax.stem(times, y3, label=r'$\gamma(k) \cos(\pi k)$')
543543
ax.legend(loc='upper right')
544544
ax.set(xlim=(0, 15), ylim=(-3, 3), yticks=(-1, 0, 1, 2, 3))
545545
ax.hlines(0, 0, 15, linestyle='--', alpha=0.5)
@@ -565,21 +565,21 @@ plt.subplots_adjust(hspace=0.25)
565565
566566
# Autocovariance when phi = -0.8
567567
ax = axes[0]
568-
ax.plot(times, y1, 'bo-', alpha=0.6, label='$\gamma(k)$')
568+
ax.plot(times, y1, 'bo-', alpha=0.6, label=r'$\gamma(k)$')
569569
ax.legend(loc='upper right')
570570
ax.set(xlim=(0, 15), yticks=(-2, 0, 2))
571571
ax.hlines(0, 0, 15, linestyle='--', alpha=0.5)
572572
573573
# Cycles at frequency π
574574
ax = axes[1]
575-
ax.plot(times, y2, 'bo-', alpha=0.6, label='$\cos(\pi k/3)$')
575+
ax.plot(times, y2, 'bo-', alpha=0.6, label=r'$\cos(\pi k/3)$')
576576
ax.legend(loc='upper right')
577577
ax.set(xlim=(0, 15), yticks=(-1, 0, 1))
578578
ax.hlines(0, 0, 15, linestyle='--', alpha=0.5)
579579
580580
# Product
581581
ax = axes[2]
582-
ax.stem(times, y3, label='$\gamma(k) \cos(\pi k/3)$')
582+
ax.stem(times, y3, label=r'$\gamma(k) \cos(\pi k/3)$')
583583
ax.legend(loc='upper right')
584584
ax.set(xlim=(0, 15), ylim=(-3, 3), yticks=(-1, 0, 1, 2, 3))
585585
ax.hlines(0, 0, 15, linestyle='--', alpha=0.5)

lectures/asset_pricing_lph.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ plt.title('mean standard deviation frontier')
384384
plt.xlabel(r"$\sigma(R^i)$")
385385
plt.ylabel(r"$E (R^i) $")
386386
plt.text(.053, 1.015, "(.05,1.015)")
387-
ax.plot(.05, 1.015, 'o', label="$(\sigma(R^j), E R^j)$")
387+
ax.plot(.05, 1.015, 'o', label=r"$(\sigma(R^j), E R^j)$")
388388
# Add a legend and show the plot
389389
ax.legend()
390390
plt.show()

lectures/black_litterman.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -319,8 +319,8 @@ d_m = r_m / σ_m
319319
x = np.arange(N) + 1
320320
fig, ax = plt.subplots(figsize=(8, 5))
321321
ax.set_title(r'Difference between $\hat{\mu}$ (estimate) and $\mu_{BL}$ (market implied)')
322-
ax.plot(x, μ_est, 'o', c='k', label='$\hat{\mu}$')
323-
ax.plot(x, μ_m, 'o', c='r', label='$\mu_{BL}$')
322+
ax.plot(x, μ_est, 'o', c='k', label=r'$\hat{\mu}$')
323+
ax.plot(x, μ_m, 'o', c='r', label=r'$\mu_{BL}$')
324324
ax.vlines(x, μ_m, μ_est, lw=1)
325325
ax.axhline(0, c='k', ls='--')
326326
ax.set_xlabel('Assets')

lectures/calvo_machine_learn.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1230,7 +1230,7 @@ Let's plot the regression line $\mu_t = .0645 + 1.5995 \theta_t$ and the points
12301230
12311231
```{code-cell} ipython3
12321232
plt.scatter(θs, μs, label=r'$\mu_t$')
1233-
plt.plot(θs, results1.predict(X1_θ), 'grey', label='$\hat \mu_t$', linestyle='--')
1233+
plt.plot(θs, results1.predict(X1_θ), 'grey', label=r'$\hat \mu_t$', linestyle='--')
12341234
plt.xlabel(r'$\theta_t$')
12351235
plt.ylabel(r'$\mu_t$')
12361236
plt.legend()
@@ -1271,7 +1271,7 @@ Let's plot $\theta_t$ for $t =0, 1, \ldots, T$ along the line.
12711271
12721272
```{code-cell} ipython3
12731273
plt.scatter(θ_t, θ_t1, label=r'$\theta_{t+1}$')
1274-
plt.plot(θ_t, results2.predict(X2_θ), color='grey', label='$\hat θ_{t+1}$', linestyle='--')
1274+
plt.plot(θ_t, results2.predict(X2_θ), color='grey', label=r'$\hat θ_{t+1}$', linestyle='--')
12751275
plt.xlabel(r'$\theta_t$')
12761276
plt.ylabel(r'$\theta_{t+1}$')
12771277
plt.legend()
@@ -1321,7 +1321,7 @@ X3_grid = np.column_stack((np.ones(len(θ_grid)), θ_grid, θ_grid**2))
13211321
13221322
plt.scatter(θs, v_t)
13231323
plt.plot(θ_grid, results3.predict(X3_grid), color='grey',
1324-
label='$\hat v_t$', linestyle='--')
1324+
label=r'$\hat v_t$', linestyle='--')
13251325
plt.axhline(V_CR, color='C1', alpha=0.5)
13261326
13271327
plt.text(max(θ_grid) - max(θ_grid)*0.025, V_CR, '$V^{CR}$', color='C1',

lectures/coase.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ for i, s in enumerate(pc.grid):
552552
ell_star[i] = e
553553
554554
fig, ax = plt.subplots()
555-
ax.plot(pc.grid, ell_star, label="$\ell^*$")
555+
ax.plot(pc.grid, ell_star, label=r"$\ell^*$")
556556
ax.legend(fontsize=14)
557557
plt.show()
558558
```

lectures/discrete_dp.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -935,7 +935,7 @@ for beta in discount_factors:
935935
res0 = ddp0.solve()
936936
k_path_ind = res0.mc.simulate(init=k_init_ind, ts_length=sample_size)
937937
k_path = grid[k_path_ind]
938-
ax.plot(k_path, 'o-', lw=2, alpha=0.75, label=f'$\\beta = {beta}$')
938+
ax.plot(k_path, 'o-', lw=2, alpha=0.75, label=fr'$\beta = {beta}$')
939939
940940
ax.legend(loc='lower right')
941941
plt.show()

lectures/markov_jump_lq.md

+18-18
Original file line numberDiff line numberDiff line change
@@ -444,8 +444,8 @@ u1_star = - ex1_a.Fs[0, 0, 1] - ex1_a.Fs[0, 0, 0] * k_grid
444444
u2_star = - ex1_a.Fs[1, 0, 1] - ex1_a.Fs[1, 0, 0] * k_grid
445445
446446
fig, ax = plt.subplots()
447-
ax.plot(k_grid, k_grid + u1_star, label="$\overline{s}_1$ (high)")
448-
ax.plot(k_grid, k_grid + u2_star, label="$\overline{s}_2$ (low)")
447+
ax.plot(k_grid, k_grid + u1_star, label=r"$\overline{s}_1$ (high)")
448+
ax.plot(k_grid, k_grid + u2_star, label=r"$\overline{s}_2$ (low)")
449449
450450
# The optimal k*
451451
ax.scatter([0.5, 0.5], [0.5, 0.5], marker="*")
@@ -546,10 +546,10 @@ for i, λ in enumerate(λ_vals):
546546
```{code-cell} python3
547547
for i, state_var in enumerate(state_vec1):
548548
fig, ax = plt.subplots()
549-
ax.plot(λ_vals, F1[:, i], label="$\overline{s}_1$", color="b")
550-
ax.plot(λ_vals, F2[:, i], label="$\overline{s}_2$", color="r")
549+
ax.plot(λ_vals, F1[:, i], label=r"$\overline{s}_1$", color="b")
550+
ax.plot(λ_vals, F2[:, i], label=r"$\overline{s}_2$", color="r")
551551
552-
ax.set_xlabel("$\lambda$")
552+
ax.set_xlabel(r"$\lambda$")
553553
ax.set_ylabel("$F_{s_t}$")
554554
ax.set_title(f"Coefficient on {state_var}")
555555
ax.legend()
@@ -617,8 +617,8 @@ for i, state_var in enumerate(state_vec1):
617617
ax.plot_surface(λ_grid, δ_grid, F1_grid[:, :, i], color="b")
618618
# low adjustment cost, red surface
619619
ax.plot_surface(λ_grid, δ_grid, F2_grid[:, :, i], color="r")
620-
ax.set_xlabel("$\lambda$")
621-
ax.set_ylabel("$\delta$")
620+
ax.set_xlabel(r"$\lambda$")
621+
ax.set_ylabel(r"$\delta$")
622622
ax.set_zlabel("$F_{s_t}$")
623623
ax.set_title(f"coefficient on {state_var}")
624624
plt.show()
@@ -656,11 +656,11 @@ def run(construct_func, vals_dict, state_vec):
656656
for i, state_var in enumerate(state_vec):
657657
fig = plt.figure()
658658
ax = fig.add_subplot(111)
659-
ax.plot(λ_vals, F1[:, i], label="$\overline{s}_1$", color="b")
660-
ax.plot(λ_vals, F2[:, i], label="$\overline{s}_2$", color="r")
659+
ax.plot(λ_vals, F1[:, i], label=r"$\overline{s}_1$", color="b")
660+
ax.plot(λ_vals, F2[:, i], label=r"$\overline{s}_2$", color="r")
661661
662-
ax.set_xlabel("$\lambda$")
663-
ax.set_ylabel("$F(\overline{s}_t)$")
662+
ax.set_xlabel(r"$\lambda$")
663+
ax.set_ylabel(r"$F(\overline{s}_t)$")
664664
ax.set_title(f"coefficient on {state_var}")
665665
ax.legend()
666666
plt.show()
@@ -674,17 +674,17 @@ def run(construct_func, vals_dict, state_vec):
674674
F = [F1, F2][i]
675675
c = ["b", "r"][i]
676676
ax.plot([0, 1], [k_star[i], k_star[i]], "--",
677-
color=c, label="$k^*(\overline{s}_"+str(i+1)+")$")
677+
color=c, label=r"$k^*(\overline{s}_"+str(i+1)+")$")
678678
ax.plot(λ_vals, - F[:, 1] / F[:, 0], color=c,
679-
label="$k^{target}(\overline{s}_"+str(i+1)+")$")
679+
label=r"$k^{target}(\overline{s}_"+str(i+1)+")$")
680680
681681
# Plot a vertical line at λ=0.5
682682
ax.plot([0.5, 0.5], [min(k_star), max(k_star)], "-.")
683683
684-
ax.set_xlabel("$\lambda$")
684+
ax.set_xlabel(r"$\lambda$")
685685
ax.set_ylabel("$k$")
686686
ax.set_title("Optimal k levels and k targets")
687-
ax.text(0.5, min(k_star)+(max(k_star)-min(k_star))/20, "$\lambda=0.5$")
687+
ax.text(0.5, min(k_star)+(max(k_star)-min(k_star))/20, r"$\lambda=0.5$")
688688
ax.legend(bbox_to_anchor=(1., 1.))
689689
plt.show()
690690
@@ -714,9 +714,9 @@ def run(construct_func, vals_dict, state_vec):
714714
ax = fig.add_subplot(111, projection='3d')
715715
ax.plot_surface(λ_grid, δ_grid, F1_grid[:, :, i], color="b")
716716
ax.plot_surface(λ_grid, δ_grid, F2_grid[:, :, i], color="r")
717-
ax.set_xlabel("$\lambda$")
718-
ax.set_ylabel("$\delta$")
719-
ax.set_zlabel("$F(\overline{s}_t)$")
717+
ax.set_xlabel(r"$\lambda$")
718+
ax.set_ylabel(r"$\delta$")
719+
ax.set_zlabel(r"$F(\overline{s}_t)$")
720720
ax.set_title(f"coefficient on {state_var}")
721721
plt.show()
722722
```

lectures/opt_tax_recur.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1242,7 +1242,7 @@ for ax, title, plot in zip(axes, titles, [tax_policy, interest_rate]):
12421242
ax.set(title=title, xlim=(min(gov_debt), max(gov_debt)))
12431243
ax.grid()
12441244
1245-
axes[0].legend(('Time $t=0$', 'Time $t \geq 1$'))
1245+
axes[0].legend(('Time $t=0$', r'Time $t \geq 1$'))
12461246
axes[1].set_xlabel('Initial Government Debt')
12471247
12481248
fig.tight_layout()

lectures/rob_markov_perf.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ The function's code is as follows
469469
def nnash_robust(A, C, B1, B2, R1, R2, Q1, Q2, S1, S2, W1, W2, M1, M2,
470470
θ1, θ2, beta=1.0, tol=1e-8, max_iter=1000):
471471
472-
"""
472+
r"""
473473
Compute the limit of a Nash linear quadratic dynamic game with
474474
robustness concern.
475475

lectures/rosen_schooling_model.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -291,13 +291,13 @@ shock on $N_t$ is larger
291291

292292
```{code-cell} python3
293293
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(12, 4))
294-
ax1.plot(econ1.c_irf,label='$\\alpha_d = 0.1$')
295-
ax1.plot(econ2.c_irf,label='$\\alpha_d = 2$')
294+
ax1.plot(econ1.c_irf,label=r'$\alpha_d = 0.1$')
295+
ax1.plot(econ2.c_irf,label=r'$\alpha_d = 2$')
296296
ax1.legend()
297297
ax1.set_title('Response of $n_t$ to a demand shock')
298298
299-
ax2.plot(econ1.h_irf[:, 0], label='$\\alpha_d = 0.1$')
300-
ax2.plot(econ2.h_irf[:, 0], label='$\\alpha_d = 24$')
299+
ax2.plot(econ1.h_irf[:, 0], label=r'$\alpha_d = 0.1$')
300+
ax2.plot(econ2.h_irf[:, 0], label=r'$\alpha_d = 24$')
301301
ax2.legend()
302302
ax2.set_title('Response of $N_t$ to a demand shock')
303303
plt.show()

0 commit comments

Comments
 (0)