Skip to content

Commit

Permalink
[FIX] Fix string warnings (#566)
Browse files Browse the repository at this point in the history
* fix string syntax warnings

* update one missing case
  • Loading branch information
HumphreyYang authored Jan 21, 2025
1 parent ea4253a commit 6cc6c4b
Show file tree
Hide file tree
Showing 18 changed files with 36 additions and 36 deletions.
4 changes: 2 additions & 2 deletions lectures/ar1_processes.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ for t in range(sim_length):
mu = a * mu + b
v = a**2 * v + c**2
ax.plot(grid, norm.pdf(grid, loc=mu, scale=np.sqrt(v)),
label=f"$\psi_{t}$",
label=fr"$\psi_{t}$",
alpha=0.7)
ax.legend(bbox_to_anchor=[1.05,1],loc=2,borderaxespad=1)
Expand Down Expand Up @@ -267,7 +267,7 @@ plot_density_seq(ax, mu_0=4.0)
mu_star = b / (1 - a)
std_star = np.sqrt(c**2 / (1 - a**2)) # square root of v_star
psi_star = norm.pdf(grid, loc=mu_star, scale=std_star)
ax.plot(grid, psi_star, 'k-', lw=2, label="$\psi^*$")
ax.plot(grid, psi_star, 'k-', lw=2, label=r"$\psi^*$")
ax.legend()
plt.show()
Expand Down
2 changes: 1 addition & 1 deletion lectures/cobweb.md
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ def plot45(model, pmin, pmax, p0, num_arrows=5):
ax.plot(pgrid, g(model, pgrid), 'b-',
lw=2, alpha=0.6, label='g')
ax.plot(pgrid, pgrid, lw=1, alpha=0.7, label='$45\degree$')
ax.plot(pgrid, pgrid, lw=1, alpha=0.7, label=r'$45\degree$')
x = p0
xticks = [pmin]
Expand Down
8 changes: 4 additions & 4 deletions lectures/eigen_I.md
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ def circle_transform(A=np.array([[-1, 2], [0, 1]])):
ax[0].plot(x, y, color='black', zorder=1)
ax[0].scatter(a_1, b_1, c=colors, alpha=1, s=60,
edgecolors='black', zorder=2)
ax[0].set_title("unit circle in $\mathbb{R}^2$")
ax[0].set_title(r"unit circle in $\mathbb{R}^2$")
x1 = x.reshape(1, -1)
y1 = y.reshape(1, -1)
Expand Down Expand Up @@ -542,15 +542,15 @@ def grid_composition_transform(A=np.array([[1, -1], [1, 1]]),
# Plot grid points
ax[0].scatter(xygrid[0], xygrid[1], s=36, c=colors, edgecolor="none")
ax[0].set_title("points $x_1, x_2, \cdots, x_k$")
ax[0].set_title(r"points $x_1, x_2, \cdots, x_k$")
# Plot intermediate grid points
ax[1].scatter(uvgrid[0], uvgrid[1], s=36, c=colors, edgecolor="none")
ax[1].set_title("points $Bx_1, Bx_2, \cdots, Bx_k$")
ax[1].set_title(r"points $Bx_1, Bx_2, \cdots, Bx_k$")
# Plot transformed grid points
ax[2].scatter(abgrid[0], abgrid[1], s=36, c=colors, edgecolor="none")
ax[2].set_title("points $ABx_1, ABx_2, \cdots, ABx_k$")
ax[2].set_title(r"points $ABx_1, ABx_2, \cdots, ABx_k$")
plt.show()
```
Expand Down
2 changes: 1 addition & 1 deletion lectures/equalizing_difference.md
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ We'll use the Python module 'sympy' to compute partial derivatives of $\phi$ wit
Define symbols
```{code-cell} ipython3
γ_h, γ_c, w_h0, D = symbols('\gamma_h, \gamma_c, w_0^h, D', real=True)
γ_h, γ_c, w_h0, D = symbols(r'\gamma_h, \gamma_c, w_0^h, D', real=True)
R, T = Symbol('R', real=True), Symbol('T', integer=True)
```
Expand Down
2 changes: 1 addition & 1 deletion lectures/geom_series.md
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ T_max = 10
T=np.arange(0, T_max+1)
rs, gs = (0.9, 0.5, 0.4001, 0.4), (0.4, 0.4, 0.4, 0.5),
comparisons = ('$\gg$', '$>$', r'$\approx$', '$<$')
comparisons = (r'$\gg$', '$>$', r'$\approx$', '$<$')
for r, g, comp in zip(rs, gs, comparisons):
ax.plot(finite_lease_pv_true(T, g, r, x_0), label=f'r(={r}) {comp} g(={g})')
Expand Down
4 changes: 2 additions & 2 deletions lectures/greek_square.md
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ fig, axs = plt.subplots(1, 2, figsize=(12, 6), dpi=500)
axs[0].plot(np.round(ratios_λ1, 6),
label=r'$\frac{y_t}{y_{t-1}}$', linewidth=3)
axs[0].axhline(y=Λ[1], color='red', linestyle='--',
label='$\lambda_2$', alpha=0.5)
label=r'$\lambda_2$', alpha=0.5)
axs[0].set_xlabel('t', size=18)
axs[0].set_ylabel(r'$\frac{y_t}{y_{t-1}}$', size=18)
axs[0].set_title(r'$\frac{y_t}{y_{t-1}}$ after Muting $\lambda_1$',
Expand All @@ -704,7 +704,7 @@ axs[0].legend()
axs[1].plot(ratios_λ2, label=r'$\frac{y_t}{y_{t-1}}$',
linewidth=3)
axs[1].axhline(y=Λ[0], color='green', linestyle='--',
label='$\lambda_1$', alpha=0.5)
label=r'$\lambda_1$', alpha=0.5)
axs[1].set_xlabel('t', size=18)
axs[1].set_ylabel(r'$\frac{y_t}{y_{t-1}}$', size=18)
axs[1].set_title(r'$\frac{y_t}{y_{t-1}}$ after Muting $\lambda_2$',
Expand Down
2 changes: 1 addition & 1 deletion lectures/heavy_tails.md
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ for ax, s in zip(axes[:2], s_vals):
data = np.random.randn(n) * s
ax.plot(list(range(n)), data, linestyle='', marker='o', alpha=0.5, ms=4)
ax.vlines(list(range(n)), 0, data, lw=0.2)
ax.set_title(f"draws from $N(0, \sigma^2)$ with $\sigma = {s}$", fontsize=11)
ax.set_title(fr"draws from $N(0, \sigma^2)$ with $\sigma = {s}$", fontsize=11)
ax = axes[2]
distribution = cauchy()
Expand Down
4 changes: 2 additions & 2 deletions lectures/inequality.md
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ mystnb:
fix, ax = plot_inequality_measures(σ_vals,
ginis,
'simulated',
'$\sigma$',
r'$\sigma$',
'Gini coefficients')
plt.show()
```
Expand Down Expand Up @@ -888,7 +888,7 @@ ax.plot(years, df_topshares["topshare_n_wealth"],
ax.plot(years, df_topshares["topshare_t_income"],
marker='o', label="total income")
ax.set_xlabel("year")
ax.set_ylabel("top $10\%$ share")
ax.set_ylabel(r"top $10\%$ share")
ax.legend()
plt.show()
```
Expand Down
10 changes: 5 additions & 5 deletions lectures/input_output.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,9 @@ ax.plot(np.linspace(55, 380, 100), (50-0.9*np.linspace(55, 380, 100))/(-1.46), c
ax.plot(np.linspace(-1, 400, 100), (60+0.16*np.linspace(-1, 400, 100))/0.83, color="r")
ax.plot(np.linspace(250, 395, 100), (62-0.04*np.linspace(250, 395, 100))/0.33, color="b")
ax.text(130, 38, "$(1-a_{11})x_1 + a_{12}x_2 \geq d_1$", size=10)
ax.text(10, 105, "$-a_{21}x_1 + (1-a_{22})x_2 \geq d_2$", size=10)
ax.text(150, 150, "$a_{01}x_1 +a_{02}x_2 \leq x_0$", size=10)
ax.text(130, 38, r"$(1-a_{11})x_1 + a_{12}x_2 \geq d_1$", size=10)
ax.text(10, 105, r"$-a_{21}x_1 + (1-a_{22})x_2 \geq d_2$", size=10)
ax.text(150, 150, r"$a_{01}x_1 +a_{02}x_2 \leq x_0$", size=10)
# Draw the feasible region
feasible_set = Polygon(np.array([[301, 151],
Expand Down Expand Up @@ -466,8 +466,8 @@ ax.vlines(0, -1, 250)
ax.plot(np.linspace(4.75, 49, 100), (4-0.9*np.linspace(4.75, 49, 100))/(-0.16), color="r")
ax.plot(np.linspace(0, 50, 100), (33+1.46*np.linspace(0, 50, 100))/0.83, color="r")
ax.text(15, 175, "$(1-a_{11})p_1 - a_{21}p_2 \leq a_{01}w$", size=10)
ax.text(30, 85, "$-a_{12}p_1 + (1-a_{22})p_2 \leq a_{02}w$", size=10)
ax.text(15, 175, r"$(1-a_{11})p_1 - a_{21}p_2 \leq a_{01}w$", size=10)
ax.text(30, 85, r"$-a_{12}p_1 + (1-a_{22})p_2 \leq a_{02}w$", size=10)
# Draw the feasible region
feasible_set = Polygon(np.array([[17, 69],
Expand Down
2 changes: 1 addition & 1 deletion lectures/intro_supply_demand.md
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ ab_grid = np.linspace(a, b, 400)
fig, ax = plt.subplots()
ax.plot(x_grid, f(x_grid), label="$f$", color="k")
ax.fill_between(ab_grid, [0] * len(ab_grid), f(ab_grid),
label="$\int_a^b f(x) dx$")
label=r"$\int_a^b f(x) dx$")
ax.legend()
plt.show()
```
Expand Down
8 changes: 4 additions & 4 deletions lectures/laffer_adaptive.md
Original file line number Diff line number Diff line change
Expand Up @@ -379,15 +379,15 @@ def draw_iterations(π0s, model, line_params, π_bars, num_steps):
axes[2].axhline(y=π_bars[0], color='grey', linestyle='--', lw=1.5, alpha=0.6)
axes[2].axhline(y=π_bars[1], color='grey', linestyle='--', lw=1.5, alpha=0.6)
axes[2].text(num_steps * 1.07, π_bars[0], '$\pi_l$', verticalalignment='center',
axes[2].text(num_steps * 1.07, π_bars[0], r'$\pi_l$', verticalalignment='center',
color='grey', size=10)
axes[2].text(num_steps * 1.07, π_bars[1], '$\pi_u$', verticalalignment='center',
axes[2].text(num_steps * 1.07, π_bars[1], r'$\pi_u$', verticalalignment='center',
color='grey', size=10)
axes[0].set_ylabel('$m_t$')
axes[1].set_ylabel('$p_t$')
axes[2].set_ylabel('$\pi_t$')
axes[3].set_ylabel('$\mu_t$')
axes[2].set_ylabel(r'$\pi_t$')
axes[3].set_ylabel(r'$\mu_t$')
axes[3].set_xlabel('timestep')
axes[3].xaxis.set_major_locator(MaxNLocator(integer=True))
Expand Down
4 changes: 2 additions & 2 deletions lectures/lln_clt.md
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ ax.set_xlim(xmin, xmax)
ax.hist(Y, bins=60, alpha=0.4, density=True)
xgrid = np.linspace(xmin, xmax, 200)
ax.plot(xgrid, st.norm.pdf(xgrid, scale=σ),
'k-', lw=2, label='$N(0, \sigma^2)$')
'k-', lw=2, label=r'$N(0, \sigma^2)$')
ax.set_xlabel(r"$Y_n$", size=12)
ax.set_ylabel(r"$density$", size=12)
Expand Down Expand Up @@ -543,7 +543,7 @@ ax.hist(Y, bins=60, alpha=0.4, density=True)
ax.set_xlabel(r"$Y_n$", size=12)
ax.set_ylabel(r"$density$", size=12)
xgrid = np.linspace(xmin, xmax, 200)
ax.plot(xgrid, st.norm.pdf(xgrid, scale=σ), 'k-', lw=2, label='$N(0, \sigma^2)$')
ax.plot(xgrid, st.norm.pdf(xgrid, scale=σ), 'k-', lw=2, label=r'$N(0, \sigma^2)$')
ax.legend()
plt.show()
Expand Down
2 changes: 1 addition & 1 deletion lectures/markov_chains_II.md
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ for i in range(n):
# Generate time series starting at different x_0
X = mc.simulate(ts_length, init=x0)
p_hat = (X == i).cumsum() / np.arange(1, ts_length+1)
axes[i].plot(p_hat, label=f'$x_0 = \, {x0} $')
axes[i].plot(p_hat, label=fr'$x_0 = \, {x0} $')
axes[i].legend()
plt.tight_layout()
Expand Down
8 changes: 4 additions & 4 deletions lectures/money_inflation_nonlinear.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,14 @@ def plot_laffer(model, πs):
# Plot the function
plt.plot(x_values, y_values,
label=f'Laffer curve')
for π, label in zip(πs, ['$\pi_l$', '$\pi_u$']):
for π, label in zip(πs, [r'$\pi_l$', r'$\pi_u$']):
plt.text(π, plt.gca().get_ylim()[0]*2,
label, horizontalalignment='center',
color='brown', size=10)
plt.axvline(π, color='brown', linestyle='--')
plt.axhline(g, color='red', linewidth=0.5,
linestyle='--', label='g')
plt.xlabel('$\pi$')
plt.xlabel(r'$\pi$')
plt.ylabel('seigniorage')
plt.legend()
plt.show()
Expand Down Expand Up @@ -373,8 +373,8 @@ def draw_iterations(p0s, model, line_params, p0_bars, num_steps):
# Draw labels
axes[0].set_ylabel('$m_t$')
axes[1].set_ylabel('$p_t$')
axes[2].set_ylabel('$\pi_t$')
axes[3].set_ylabel('$\mu_t$')
axes[2].set_ylabel(r'$\pi_t$')
axes[3].set_ylabel(r'$\mu_t$')
axes[3].set_xlabel('timestep')
for p_0, label in [(p0_bars[0], '$p_0=p_l$'), (p0_bars[1], '$p_0=p_u$')]:
Expand Down
4 changes: 2 additions & 2 deletions lectures/olg.md
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ fig, ax = plt.subplots(figsize=(6, 6))
ymin, ymax = np.min(k_grid_next), np.max(k_grid_next)
ax.plot(k_grid, k_grid_next, lw=2, alpha=0.6, label='$g$')
ax.plot(k_grid, k_grid, 'k-', lw=1, alpha=0.7, label='$45^{\circ}$')
ax.plot(k_grid, k_grid, 'k-', lw=1, alpha=0.7, label=r'$45^{\circ}$')
ax.legend(loc='upper left', frameon=False, fontsize=12)
Expand Down Expand Up @@ -722,7 +722,7 @@ fig, ax = plt.subplots(figsize=(6, 6))
ymin, ymax = np.min(k_grid_next), np.max(k_grid_next)
ax.plot(k_grid, k_grid_next, lw=2, alpha=0.6, label='$g$')
ax.plot(k_grid, k_grid, 'k-', lw=1, alpha=0.7, label='$45^{\circ}$')
ax.plot(k_grid, k_grid, 'k-', lw=1, alpha=0.7, label=r'$45^{\circ}$')
ax.legend(loc='upper left', frameon=False, fontsize=12)
Expand Down
2 changes: 1 addition & 1 deletion lectures/prob_dist.md
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ for μ, σ in zip(μ_vals, σ_vals):
u = scipy.stats.lognorm(σ, scale=np.exp(μ))
ax.plot(x_grid, u.pdf(x_grid),
alpha=0.5, lw=2,
label=f'$\mu={μ}, \sigma={σ}$')
label=fr'$\mu={μ}, \sigma={σ}$')
ax.set_xlabel('x')
ax.set_ylabel('PDF')
plt.legend()
Expand Down
2 changes: 1 addition & 1 deletion lectures/solow.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def plot45(kstar=None):
lb = r'$g(k) = sAk^{\alpha} + (1 - \delta)k$'
ax.plot(xgrid, g_values, lw=2, alpha=0.6, label=lb)
ax.plot(xgrid, xgrid, 'k-', lw=1, alpha=0.7, label='$45^{\circ}$')
ax.plot(xgrid, xgrid, 'k-', lw=1, alpha=0.7, label=r'$45^{\circ}$')
if kstar:
fps = (kstar,)
Expand Down
2 changes: 1 addition & 1 deletion lectures/unpleasant.md
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ def plot_path(m0_arr, model, length=15):
ax.set_title(titles[i])
axs[0, 1].hlines(model.m0_check, 0, length, color='r', linestyle='--')
axs[0, 1].text(length * 0.8, model.m0_check * 0.9, '$\check{m}_0$')
axs[0, 1].text(length * 0.8, model.m0_check * 0.9, r'$\check{m}_0$')
plt.show()
```
Expand Down

0 comments on commit 6cc6c4b

Please sign in to comment.