Skip to content

Commit 270f3f2

Browse files
Merge branch 'main' into executable-pages
2 parents 5f7179b + 2c01f4d commit 270f3f2

File tree

17 files changed

+46
-40
lines changed

17 files changed

+46
-40
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
strategy:
1919
matrix:
2020
os: [ubuntu, macos]
21-
python-version: ["3.11", "3.12"]
21+
python-version: ["3.11", "3.12", "3.13"]
2222
steps:
2323
- uses: actions/checkout@v4
2424
- name: Set up Python ${{ matrix.python-version }}

.pre-commit-config.yaml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,27 @@ repos:
1919
- id: trailing-whitespace
2020

2121
- repo: https://github.com/rbubley/mirrors-prettier
22-
rev: 1463d990e0801964764a375260dca598513f3be5 # frozen: v3.3.3
22+
rev: bc7af46104f0f5368b95878decf720f9f00c2559 # frozen: v3.4.2
2323
hooks:
2424
- id: prettier
2525
files: \.(md|rst|yml|yaml)
2626
args: [--prose-wrap=preserve]
2727

2828
- repo: https://github.com/MarcoGorelli/cython-lint
29-
rev: 9247866fce7128f2c0eaf4a09f437880397d4689 # frozen: v0.16.2
29+
rev: 1ac5158c1b0f405350517c218f03d3a21bbb381c # frozen: v0.16.6
3030
hooks:
3131
- id: cython-lint
3232
args: [--no-pycodestyle, --max-line-length=88]
3333

3434
- repo: https://github.com/astral-sh/ruff-pre-commit
35-
rev: 75b98813cfb7e663870a28c74366a1e99d7bfe79 # frozen: v0.6.9
35+
rev: 8b76f04e7e5a9cd259e9d1db7799599355f97cdf # frozen: v0.8.2
3636
hooks:
3737
- id: ruff
3838
args: ["--fix", "--show-fixes", "--exit-non-zero-on-fix"]
3939
- id: ruff-format
4040

4141
- repo: https://github.com/pre-commit/mirrors-mypy
42-
rev: "d4911cfb7f1010759fde68da196036feeb25b99d" # frozen: v1.11.2
42+
rev: "f56614daa94d5cd733d3b7004c5df9caad267b4a" # frozen: v1.13.0
4343
hooks:
4444
- id: mypy
4545
additional_dependencies:
@@ -68,6 +68,8 @@ repos:
6868
| advanced/interfacing_with_c/numpy_c_api/test_cos_module_np\.py$
6969
| intro/numpy/solutions/2_a_call_fortran\.py$
7070
| advanced/advanced_numpy/examples/mandelplot\.py$
71+
| intro/numpy/solutions/2_5_markov_chain\.py$
72+
| intro/matplotlib/examples/plot_bar\.py$
7173
)
7274
7375
- repo: https://github.com/codespell-project/codespell

CONTRIBUTING.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Design choices:
3333

3434
* Each chapter should provide a useful basis for a 1‒2 h tutorial.
3535
* The code should be readable.
36-
* An idomatic style should be followed, e.g. ``import numpy as np``,
36+
* An idiomatic style should be followed, e.g. ``import numpy as np``,
3737
preference for array operations, PEP8 coding conventions.
3838

3939

advanced/advanced_numpy/examples/wavreader.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,5 @@
4646
f.close()
4747

4848
print(
49-
"Sample rate: %d, channels: %d"
50-
% (wav_header["sample_rate"][0], wav_header["num_channels"][0])
49+
f"Sample rate: {wav_header['sample_rate'][0]}, channels: {wav_header['num_channels'][0]}"
5150
)

advanced/debugging/to_debug.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ def compare_optimizers(optimizers):
6161
print("Benching 1D root-finder optimizers from scipy.optimize:")
6262
for optimizer in OPTIMIZERS:
6363
print(
64-
"% 20s: % 8i total function calls"
65-
% (optimizer.__name__, bench_optimizer(optimizer, param_grid))
64+
f"{optimizer.__name__:>20s}: {bench_optimizer(optimizer, param_grid):>8d} total function calls"
6665
)
6766

6867

advanced/debugging/to_debug_solution.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ def compare_optimizers(optimizers):
6161
print("Benching 1D root-finder optimizers from scipy.optimize:")
6262
for optimizer in OPTIMIZERS:
6363
print(
64-
"% 20s: % 8i total function calls"
65-
% (optimizer.__name__, bench_optimizer(optimizer, param_grid))
64+
f"{optimizer.__name__:>20s}: {bench_optimizer(optimizer, param_grid):>8d} total function calls"
6665
)
6766

6867

advanced/mathematical_optimization/examples/helper/compare_optimizers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,8 @@ def mk_costs(ndim=2):
183183

184184
# Normalize across methods
185185
x0_mean = np.mean(all_bench)
186-
for method_name in function_bench:
187-
function_bench[method_name][-1] /= x0_mean
186+
for _, values in function_bench.items():
187+
values[-1] /= x0_mean
188188
this_dim_benchs[cost_name] = function_bench
189189
gradient_less_benchs[ndim] = this_dim_benchs
190190
print(80 * "_")

advanced/mathematical_optimization/examples/plot_compare_optimizers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
],
8787
"o",
8888
color=color,
89-
label="# dim: %i" % n_dim,
89+
label=f"# dim: {n_dim}",
9090
)
9191
plt.legend(
9292
loc=(0.47, 0.07),

advanced/optimizing/ica.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def _ica_par(X, tol, g, gprime, fun_args, maxit, w_init):
8787

8888
W1 = _sym_decorrelation(W1)
8989

90-
lim = max(abs(abs(np.diag(W1 @ W.T)) - 1))
90+
lim = np.max(np.abs(np.abs(np.diag(W1 @ W.T)) - 1))
9191
W = W1
9292
it = it + 1
9393

advanced/scipy_sparse/examples/pyamg_with_lobpcg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
for i in range(K):
3838
plt.subplot(3, 3, i + 1)
39-
plt.title("Eigenvector %d" % i)
39+
plt.title(f"Eigenvector {i}")
4040
plt.pcolor(V[:, i].reshape(N, N))
4141
plt.axis("equal")
4242
plt.axis("off")

0 commit comments

Comments
 (0)