From 66324c9cbb14d72deab7a9b016bc5080002404bb Mon Sep 17 00:00:00 2001 From: Jarrod Millman Date: Sat, 11 May 2024 11:43:18 -0700 Subject: [PATCH 1/3] Update ruff --- .pre-commit-config.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 697d347f5..c6d3e3eff 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -26,16 +26,16 @@ repos: args: [--prose-wrap=preserve] - repo: https://github.com/MarcoGorelli/cython-lint - rev: 582556b052c898dc484a981bea48de3284a4b8ee # frozen: v0.16.0 + rev: 9247866fce7128f2c0eaf4a09f437880397d4689 # frozen: v0.16.2 hooks: - id: cython-lint args: [--no-pycodestyle, --max-line-length=88] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: c0bff48397a5119af3fadb07c507dd09ac9e2aa8 # frozen: v0.3.6 + rev: f8a3f8c471fb698229face5ed7640a64900b781e # frozen: v0.4.4 hooks: - id: ruff - args: [--fix, --exit-non-zero-on-fix] + args: ["--fix", "--show-fixes", "--exit-non-zero-on-fix"] - id: ruff-format - repo: https://github.com/codespell-project/codespell From d6b447cab8c40aa47dc675a0f4349ae254e8b3ce Mon Sep 17 00:00:00 2001 From: Jarrod Millman Date: Sat, 11 May 2024 11:49:59 -0700 Subject: [PATCH 2/3] Autoformat with ruff --- .../examples/plot_gradient_descent.py | 4 ++-- .../examples/plot_cumulative_wind_speed_prediction.py | 2 +- .../examples/plot_gumbell_wind_speed_prediction.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/advanced/mathematical_optimization/examples/plot_gradient_descent.py b/advanced/mathematical_optimization/examples/plot_gradient_descent.py index aae737a56..47453246a 100644 --- a/advanced/mathematical_optimization/examples/plot_gradient_descent.py +++ b/advanced/mathematical_optimization/examples/plot_gradient_descent.py @@ -32,9 +32,9 @@ def super_fmt(value): if value > 1: if np.abs(int(value) - value) < 0.1: - out = "$10^{%.1i}$" % value + out = f"$10^{{{int(value):d}}}$" else: - out = "$10^{%.1f}$" % value + out = f"$10^{{{value:.1f}}}$" else: value = np.exp(value - 0.01) if value > 0.1: diff --git a/intro/scipy/summary-exercises/examples/plot_cumulative_wind_speed_prediction.py b/intro/scipy/summary-exercises/examples/plot_cumulative_wind_speed_prediction.py index 4435a7c87..699268c9f 100644 --- a/intro/scipy/summary-exercises/examples/plot_cumulative_wind_speed_prediction.py +++ b/intro/scipy/summary-exercises/examples/plot_cumulative_wind_speed_prediction.py @@ -26,7 +26,7 @@ plt.plot(sorted_max_speeds, cprob, "o") plt.plot(fitted_max_speeds, nprob, "g--") plt.plot([fifty_wind], [fifty_prob], "o", ms=8.0, mfc="y", mec="y") -plt.text(30, 0.05, r"$V_{50} = %.2f \, m/s$" % fifty_wind) +plt.text(30, 0.05, rf"$V_{{50}} = {fifty_wind:.2f} \, m/s$") plt.plot([fifty_wind, fifty_wind], [plt.axis()[2], fifty_prob], "k--") plt.xlabel("Annual wind speed maxima [$m/s$]") plt.ylabel("Cumulative probability") diff --git a/intro/scipy/summary-exercises/examples/plot_gumbell_wind_speed_prediction.py b/intro/scipy/summary-exercises/examples/plot_gumbell_wind_speed_prediction.py index a4b0969bf..a632610b0 100644 --- a/intro/scipy/summary-exercises/examples/plot_gumbell_wind_speed_prediction.py +++ b/intro/scipy/summary-exercises/examples/plot_gumbell_wind_speed_prediction.py @@ -33,7 +33,7 @@ def gumbell_dist(arr): plt.plot(fitted_max_speeds, nprob, "g--") plt.plot([fifty_wind], [fifty_prob], "o", ms=8.0, mfc="y", mec="y") plt.plot([fifty_wind, fifty_wind], [plt.axis()[2], fifty_prob], "k--") -plt.text(35, -1, r"$V_{50} = %.2f \, m/s$" % fifty_wind) +plt.text(35, -1, rf"$V_{{50}} = {fifty_wind:.2f} \, m/s$") plt.xlabel("Annual wind speed maxima [$m/s$]") plt.ylabel("Gumbell cumulative probability") plt.show() From 325b61efcc2d0460fc9b3fe4ad0f45efec57b147 Mon Sep 17 00:00:00 2001 From: Jarrod Millman Date: Sat, 11 May 2024 12:24:51 -0700 Subject: [PATCH 3/3] Ignore ruff formatting with git blame --- .git-blame-ignore-revs | 1 + 1 file changed, 1 insertion(+) diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index c4a66acac..7ad2a6935 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -4,3 +4,4 @@ bb473f6ff4a23e4fd5205eacdef713db15decadf 7cb7b365c51ab20d92745e5eefb95690e3ba2e14 67c4efab4e3ec1dc16c18b9ab8c5cd5f375040e0 8d00b416689c428b2bafdaad61ed3ec660ca06c2 +d6b447cab8c40aa47dc675a0f4349ae254e8b3ce