Replace .format with f-strings

main
Aurélien Geron 2021-11-22 10:18:02 +13:00
parent c4280cc354
commit 4eb68a8b7a
1 changed files with 3 additions and 3 deletions

View File

@ -346,7 +346,7 @@
" plt.xlabel(\"$x_1$\")\n", " plt.xlabel(\"$x_1$\")\n",
" plt.axis([0, 2, 0, 15])\n", " plt.axis([0, 2, 0, 15])\n",
" plt.grid()\n", " plt.grid()\n",
" plt.title(r\"$\\eta = {}$\".format(eta))\n", " plt.title(fr\"$\\eta = {eta}$\")\n",
" return theta_path\n", " return theta_path\n",
"\n", "\n",
"np.random.seed(42)\n", "np.random.seed(42)\n",
@ -820,7 +820,7 @@
" model.fit(X, y)\n", " model.fit(X, y)\n",
" y_new_regul = model.predict(X_new)\n", " y_new_regul = model.predict(X_new)\n",
" plt.plot(X_new, y_new_regul, style, linewidth=2,\n", " plt.plot(X_new, y_new_regul, style, linewidth=2,\n",
" label=r\"$\\alpha = {}$\".format(alpha))\n", " label=fr\"$\\alpha = {alpha}$\")\n",
" plt.legend(loc=\"upper left\")\n", " plt.legend(loc=\"upper left\")\n",
" plt.xlabel(\"$x_1$\")\n", " plt.xlabel(\"$x_1$\")\n",
" plt.axis([0, 3, 0, 3.5])\n", " plt.axis([0, 3, 0, 3.5])\n",
@ -960,7 +960,7 @@
" ax.plot(path_N[:, 0], path_N[:, 1], \"y--\")\n", " ax.plot(path_N[:, 0], path_N[:, 1], \"y--\")\n",
" ax.plot(0, 0, \"ys\")\n", " ax.plot(0, 0, \"ys\")\n",
" ax.plot(t1_min, t2_min, \"ys\")\n", " ax.plot(t1_min, t2_min, \"ys\")\n",
" ax.set_title(r\"$\\ell_{}$ penalty\".format(i + 1))\n", " ax.set_title(fr\"$\\ell_{i + 1}$ penalty\")\n",
" ax.axis([t1a, t1b, t2a, t2b])\n", " ax.axis([t1a, t1b, t2a, t2b])\n",
" if i == 1:\n", " if i == 1:\n",
" ax.set_xlabel(r\"$\\theta_1$\")\n", " ax.set_xlabel(r\"$\\theta_1$\")\n",