Skip to content

Commit d66a492

Browse files
committed
FIX: syntax for strings python>=3.12
1 parent a83e53c commit d66a492

File tree

5 files changed

+36
-36
lines changed

5 files changed

+36
-36
lines changed

lectures/likelihood_bayes.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ for i in range(100):
646646
ax.plot(range(T+1), π_path[i, :])
647647
648648
ax.set_xlabel('$t$')
649-
ax.set_ylabel('$\pi_t$')
649+
ax.set_ylabel(r'$\pi_t$')
650650
plt.show()
651651
```
652652
@@ -672,7 +672,7 @@ for t in [1, 10, T-1]:
672672
ax.hist(π_path[:,t], bins=20, alpha=0.4, label=f'T={t}')
673673
674674
ax.set_ylabel('count')
675-
ax.set_xlabel('$\pi_T$')
675+
ax.set_xlabel(r'$\pi_T$')
676676
ax.legend(loc='lower right')
677677
plt.show()
678678
```
@@ -705,7 +705,7 @@ for t in [1, 10, T-1]:
705705
ax.hist(π_path3[:,t], bins=20, alpha=0.4, label=f'T={t}')
706706
707707
ax.set_ylabel('count')
708-
ax.set_xlabel('$\pi_T$')
708+
ax.set_xlabel(r'$\pi_T$')
709709
ax.legend(loc='upper right')
710710
plt.show()
711711
```
@@ -726,12 +726,12 @@ $F$ more frequently along a sample path, and this pushes $\pi_t$ toward $0$.
726726
```{code-cell} ipython3
727727
fig, ax = plt.subplots()
728728
for i, j in enumerate([10, 100]):
729-
ax.plot(range(T+1), π_path[j,:], color=colors[i], label=f'$\pi$_path, {j}-th simulation')
730-
ax.plot(range(1,T+1), w_path[j,:], color=colors[i], label=f'$w$_path, {j}-th simulation', alpha=0.3)
729+
ax.plot(range(T+1), π_path[j,:], color=colors[i], label=fr'$\pi$_path, {j}-th simulation')
730+
ax.plot(range(1,T+1), w_path[j,:], color=colors[i], label=fr'$w$_path, {j}-th simulation', alpha=0.3)
731731
732732
ax.legend(loc='upper right')
733733
ax.set_xlabel('$t$')
734-
ax.set_ylabel('$\pi_t$')
734+
ax.set_ylabel(r'$\pi_t$')
735735
ax2 = ax.twinx()
736736
ax2.set_ylabel("$w_t$")
737737
plt.show()
@@ -800,8 +800,8 @@ for pi in pi_array:
800800
801801
fig, ax = plt.subplots()
802802
ax.plot(pi_array, cond_var_array)
803-
ax.set_xlabel('$\pi_{t-1}$')
804-
ax.set_ylabel('$\sigma^{2}(\pi_{t}\\vert \pi_{t-1})$')
803+
ax.set_xlabel(r'$\pi_{t-1}$')
804+
ax.set_ylabel(r'$\sigma^{2}(\pi_{t}\\vert \pi_{t-1})$')
805805
plt.show()
806806
```
807807

lectures/mix_model.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ ax.set_xlabel(r'$\alpha$')
630630
# plot KL
631631
ax2 = ax.twinx()
632632
# plot limit point
633-
ax2.scatter(α_arr_x, π_lim_arr, facecolors='none', edgecolors='tab:blue', label='$\pi$ lim')
633+
ax2.scatter(α_arr_x, π_lim_arr, facecolors='none', edgecolors='tab:blue', label=r'$\pi$ lim')
634634
ax2.set_ylabel('π lim')
635635
636636
ax.legend(loc=[0.85, 0.8])
@@ -718,9 +718,9 @@ for i in range(len(sizes)):
718718
data=sample, kde=True, stat='density', alpha=0.2, ax=ax,
719719
color=colors[i], binwidth=0.02, linewidth=0.05, label=f't={sizes[i]}'
720720
)
721-
ax.set_title('$\pi_t(\\alpha)$ as $t$ increases')
721+
ax.set_title(r'$\pi_t(\\alpha)$ as $t$ increases')
722722
ax.legend()
723-
ax.set_xlabel('$\\alpha$')
723+
ax.set_xlabel(r'$\\alpha$')
724724
plt.show()
725725
```
726726

lectures/navy_captain.md

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -394,9 +394,9 @@ def compute_V_fre(L0_arr, L1_arr, π_star, wf):
394394
π_star = 0.5
395395
V_fre_arr, PFA_arr, PD_arr = compute_V_fre(L0_arr, L1_arr, π_star, wf)
396396
397-
plt.plot(range(T), V_fre_arr, label='$\min_{d} \overline{V}_{fre}(t,d)$')
397+
plt.plot(range(T), V_fre_arr, label=r'$\min_{d} \overline{V}_{fre}(t,d)$')
398398
plt.xlabel('t')
399-
plt.title('$\pi^*=0.5$')
399+
plt.title(r'$\pi^*=0.5$')
400400
plt.legend()
401401
plt.show()
402402
```
@@ -434,8 +434,8 @@ for i, π_star in enumerate(π_star_arr):
434434

435435
```{code-cell} python3
436436
plt.plot(π_star_arr, V_fre_bar_arr)
437-
plt.xlabel('$\pi^*$')
438-
plt.title('$\overline{V}_{fre}$')
437+
plt.xlabel(r'$\pi^*$')
438+
plt.title(r'$\overline{V}_{fre}$')
439439
440440
plt.show()
441441
```
@@ -447,12 +447,12 @@ $\left(PFA,PD\right)$ change as $\pi^{*}$ varies.
447447
fig, axs = plt.subplots(1, 2, figsize=(14, 5))
448448
449449
axs[0].plot(π_star_arr, t_optimal_arr)
450-
axs[0].set_xlabel('$\pi^*$')
450+
axs[0].set_xlabel(r'$\pi^*$')
451451
axs[0].set_title('optimal sample size given $\pi^*$')
452452
453453
axs[1].plot(π_star_arr, PFA_optimal_arr, label='$PFA^*(\pi^*)$')
454454
axs[1].plot(π_star_arr, PD_optimal_arr, label='$PD^*(\pi^*)$')
455-
axs[1].set_xlabel('$\pi^*$')
455+
axs[1].set_xlabel(r'$\pi^*$')
456456
axs[1].legend()
457457
axs[1].set_title('optimal PFA and PD given $\pi^*$')
458458
@@ -587,7 +587,7 @@ plt.vlines(β, 0, β * wf.L0, linestyle="--")
587587
plt.vlines(α, 0, (1 - α) * wf.L1, linestyle="--")
588588
589589
ax.set(xlim=(0, 1), ylim=(0, 0.5 * max(wf.L0, wf.L1)), ylabel="cost",
590-
xlabel="$\pi$", title="Value function")
590+
xlabel=r"$\pi$", title="Value function")
591591
592592
plt.legend(borderpad=1.1)
593593
plt.show()
@@ -689,7 +689,7 @@ plt.vlines(β, 0, wf.L0, linestyle='--')
689689
plt.text(β+0.01, wf.L0/2, 'β')
690690
plt.vlines(α, 0, wf.L0, linestyle='--')
691691
plt.text(α+0.01, wf.L0/2, 'α')
692-
plt.xlabel('$\pi$')
692+
plt.xlabel(r'$\pi$')
693693
plt.title('Objective value function $V(\pi)$')
694694
plt.legend()
695695
plt.show()
@@ -734,11 +734,11 @@ for i, π_star in enumerate(π_star_arr):
734734
axs[row_i, col_i].vlines(π_optimal, V_baye_bar, V_baye.max(), linestyle='--')
735735
axs[row_i, col_i].text(π_optimal+0.05, (V_baye_bar + V_baye.max()) / 2,
736736
'${\pi_0^*}=$'+f'{π_optimal:0.2f}')
737-
axs[row_i, col_i].set_xlabel('$\pi$')
738-
axs[row_i, col_i].set_ylabel('$\overline{V}_{baye}(\pi)$')
739-
axs[row_i, col_i].set_title('$\pi^*=$' + f'{π_star}')
737+
axs[row_i, col_i].set_xlabel(r'$\pi$')
738+
axs[row_i, col_i].set_ylabel(r'$\overline{V}_{baye}(\pi)$')
739+
axs[row_i, col_i].set_title(r'$\pi^*=$' + f'{π_star}')
740740
741-
fig.suptitle('$\overline{V}_{baye}(\pi)=\pi^*V^0(\pi) + (1-\pi^*)V^1(\pi)$', fontsize=16)
741+
fig.suptitle(r'$\overline{V}_{baye}(\pi)=\pi^*V^0(\pi) + (1-\pi^*)V^1(\pi)$', fontsize=16)
742742
plt.show()
743743
```
744744

@@ -763,14 +763,14 @@ for i, π_star in enumerate(π_star_arr):
763763
fig, axs = plt.subplots(1, 2, figsize=(14, 5))
764764
765765
axs[0].plot(π_star_arr, V_baye_bar_arr)
766-
axs[0].set_xlabel('$\pi^*$')
767-
axs[0].set_title('$\overline{V}_{baye}$')
766+
axs[0].set_xlabel(r'$\pi^*$')
767+
axs[0].set_title(r'$\overline{V}_{baye}$')
768768
769769
axs[1].plot(π_star_arr, π_optimal_arr, label='optimal prior')
770770
axs[1].plot([π_star_arr.min(), π_star_arr.max()],
771771
[π_star_arr.min(), π_star_arr.max()],
772772
c='k', linestyle='--', label='45 degree line')
773-
axs[1].set_xlabel('$\pi^*$')
773+
axs[1].set_xlabel(r'$\pi^*$')
774774
axs[1].set_title('optimal prior given $\pi^*$')
775775
axs[1].legend()
776776
@@ -799,10 +799,10 @@ V_baye_bar = V_baye.min()
799799
```
800800

801801
```{code-cell} python3
802-
plt.plot(range(T), V_fre_arr, label='$\min_{d} \overline{V}_{fre}(t,d)$')
803-
plt.plot([0, T], [V_baye_bar, V_baye_bar], label='$\overline{V}_{baye}$')
802+
plt.plot(range(T), V_fre_arr, label=r'$\min_{d} \overline{V}_{fre}(t,d)$')
803+
plt.plot([0, T], [V_baye_bar, V_baye_bar], label=r'$\overline{V}_{baye}$')
804804
plt.xlabel('t')
805-
plt.title('$\pi^*=0.5$')
805+
plt.title(r'$\pi^*=0.5$')
806806
plt.legend()
807807
plt.show()
808808
```
@@ -816,14 +816,14 @@ rule does better on average for all values of $\pi^{*}$.
816816
```{code-cell} python3
817817
fig, axs = plt.subplots(1, 2, figsize=(14, 5))
818818
819-
axs[0].plot(π_star_arr, V_fre_bar_arr, label='$\overline{V}_{fre}$')
820-
axs[0].plot(π_star_arr, V_baye_bar_arr, label='$\overline{V}_{baye}$')
819+
axs[0].plot(π_star_arr, V_fre_bar_arr, label=r'$\overline{V}_{fre}$')
820+
axs[0].plot(π_star_arr, V_baye_bar_arr, label=r'$\overline{V}_{baye}$')
821821
axs[0].legend()
822-
axs[0].set_xlabel('$\pi^*$')
822+
axs[0].set_xlabel(r'$\pi^*$')
823823
824824
axs[1].plot(π_star_arr, V_fre_bar_arr - V_baye_bar_arr, label='$diff$')
825825
axs[1].legend()
826-
axs[1].set_xlabel('$\pi^*$')
826+
axs[1].set_xlabel(r'$\pi^*$')
827827
828828
plt.show()
829829
```

lectures/wald_friedman.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ axes[0].plot(grid, f1(grid), lw=2, label="$f_1$")
204204
axes[1].set_title("Mixtures")
205205
for π in 0.25, 0.5, 0.75:
206206
y = π * f0(grid) + (1 - π) * f1(grid)
207-
axes[1].plot(y, lw=2, label=f"$\pi_k$ = {π}")
207+
axes[1].plot(y, lw=2, label=rf"$\pi_k$ = {π}")
208208
209209
for ax in axes:
210210
ax.legend()
@@ -606,7 +606,7 @@ plt.vlines(β, 0, β * wf.L0, linestyle="--")
606606
plt.vlines(α, 0, (1 - α) * wf.L1, linestyle="--")
607607
608608
ax.set(xlim=(0, 1), ylim=(0, 0.5 * max(wf.L0, wf.L1)), ylabel="cost",
609-
xlabel="$\pi$", title="Cost function $J(\pi)$")
609+
xlabel=r"$\pi$", title="Cost function $J(\pi)$")
610610
611611
plt.legend(borderpad=1.1)
612612
plt.show()

lectures/wealth_dynamics.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ Now let's check the Gini coefficient.
500500
```{code-cell} ipython3
501501
fig, ax = plt.subplots()
502502
ax.plot(μ_r_vals, gini_vals, label='gini coefficient')
503-
ax.set_xlabel("$\mu_r$")
503+
ax.set_xlabel(r"$\mu_r$")
504504
ax.legend()
505505
plt.show()
506506
```

0 commit comments

Comments
 (0)