Skip to content

Commit e9f5798

Browse files
committed
Update pre-commit hooks
1 parent 8be21af commit e9f5798

64 files changed

Lines changed: 205 additions & 170 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.envs/update_envs.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ def main():
4040
docs_env.append(" - -e ../") # add local installation
4141

4242
# write environments
43-
for name, env in zip(["linux", "others"], [test_env_linux, test_env_others]):
43+
for name, env in zip(
44+
["linux", "others"], [test_env_linux, test_env_others], strict=False
45+
):
4446
Path(f".envs/testenv-{name}.yml").write_text("\n".join(env) + "\n")
4547

4648

.pre-commit-config.yaml

Lines changed: 22 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ repos:
66
- id: check-useless-excludes
77
# - id: identity # Prints all files passed to pre-commits. Debugging.
88
- repo: https://github.com/lyz-code/yamlfix
9-
rev: 1.17.0
9+
rev: 1.19.0
1010
hooks:
1111
- id: yamlfix
1212
- repo: local
@@ -18,7 +18,7 @@ repos:
1818
always_run: true
1919
require_serial: true
2020
- repo: https://github.com/pre-commit/pre-commit-hooks
21-
rev: v4.4.0
21+
rev: v6.0.0
2222
hooks:
2323
- id: check-added-large-files
2424
args:
@@ -46,21 +46,12 @@ repos:
4646
- --branch
4747
- main
4848
- id: trailing-whitespace
49+
exclude: docs/
4950
- id: check-ast
50-
- id: check-docstring-first
5151
- repo: https://github.com/adrienverge/yamllint.git
52-
rev: v1.30.0
52+
rev: v1.37.1
5353
hooks:
5454
- id: yamllint
55-
- repo: https://github.com/psf/black
56-
rev: 23.3.0
57-
hooks:
58-
- id: black
59-
language_version: python3.10
60-
- repo: https://github.com/asottile/blacken-docs
61-
rev: 1.13.0
62-
hooks:
63-
- id: blacken-docs
6455
- repo: https://github.com/PyCQA/docformatter
6556
rev: v1.7.7
6657
hooks:
@@ -72,58 +63,44 @@ repos:
7263
- --wrap-descriptions
7364
- '88'
7465
- --blank
75-
- repo: https://github.com/charliermarsh/ruff-pre-commit
76-
rev: v0.0.261
66+
- repo: https://github.com/astral-sh/ruff-pre-commit
67+
rev: v0.14.0
7768
hooks:
69+
# Run the linter.
7870
- id: ruff
79-
# args:
80-
# - --verbose
81-
# - repo: https://github.com/kynan/nbstripout
82-
# rev: 0.6.1
83-
# hooks:
84-
# - id: nbstripout
85-
# args:
86-
# - --extra-keys
87-
# - metadata.kernelspec metadata.language_info.version metadata.vscode
88-
- repo: https://github.com/nbQA-dev/nbQA
89-
rev: 1.7.0
90-
hooks:
91-
- id: nbqa-black
92-
- id: nbqa-ruff
71+
types_or:
72+
- python
73+
- pyi
74+
- jupyter
75+
args:
76+
- --fix
77+
# Run the formatter.
78+
- id: ruff-format
79+
types_or:
80+
- python
81+
- pyi
82+
- jupyter
9383
- repo: https://github.com/executablebooks/mdformat
9484
rev: 0.7.22
9585
hooks:
9686
- id: mdformat
9787
additional_dependencies:
9888
- mdformat-gfm
99-
- mdformat-black
89+
- mdformat-ruff
10090
args:
10191
- --wrap
10292
- '88'
10393
files: (README\.md)
10494
- repo: https://github.com/executablebooks/mdformat
105-
rev: 0.7.16
95+
rev: 0.7.22
10696
hooks:
10797
- id: mdformat
10898
additional_dependencies:
10999
- mdformat-myst
110-
- mdformat-black
100+
- mdformat-ruff
111101
args:
112102
- --wrap
113103
- '88'
114104
files: (docs/.)
115-
- repo: https://github.com/asottile/setup-cfg-fmt
116-
rev: v2.2.0
117-
hooks:
118-
- id: setup-cfg-fmt
119-
- repo: https://github.com/mgedmin/check-manifest
120-
rev: '0.49'
121-
hooks:
122-
- id: check-manifest
123-
args:
124-
- --no-build-isolation
125-
additional_dependencies:
126-
- setuptools-scm
127-
- toml
128105
ci:
129106
autoupdate_schedule: monthly

src/tranquilo/acceptance_decision.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
also do own function evaluations and decide to accept a different point.
55
66
"""
7+
78
from typing import NamedTuple
89

910
import numpy as np

src/tranquilo/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
from pathlib import Path
21
import importlib.util
2+
from pathlib import Path
33

44
DOCS_DIR = Path(__file__).parent.parent / "docs"
55

src/tranquilo/estimate_variance.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
"""Estimate the variance or covariance matrix of the noise in the objective function."""
22

3-
43
import numpy as np
54

65
from tranquilo.get_component import get_component
76
from tranquilo.history import History
8-
from tranquilo.region import Region
97
from tranquilo.options import VarianceEstimatorOptions
8+
from tranquilo.region import Region
109

1110

1211
def get_variance_estimator(fitter, user_options):
@@ -48,14 +47,14 @@ def _estimate_variance_classic(
4847
if model_type == "scalar":
4948
samples = list(history.get_fvals(valid_indices).values())
5049
out = 0.0
51-
for weight, sample in zip(weights, samples):
50+
for weight, sample in zip(weights, samples, strict=False):
5251
out += weight * np.var(sample, ddof=1)
5352
else:
5453
samples = list(history.get_fvecs(valid_indices).values())
5554

5655
dim = samples[0].shape[1]
5756
out = np.zeros((dim, dim))
58-
for weight, sample in zip(weights, samples):
57+
for weight, sample in zip(weights, samples, strict=False):
5958
out += weight * np.cov(sample, rowvar=False, ddof=1)
6059

6160
return out

src/tranquilo/exploration_sample.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import numpy as np
22
from scipy.stats import qmc, triang
3+
34
from tranquilo.utilities import get_rng
45

56

@@ -46,7 +47,7 @@ def draw_exploration_sample(
4647
if sampling_distribution not in valid_distributions:
4748
raise ValueError(f"Unsupported distribution: {sampling_distribution}")
4849

49-
for name, bound in zip(["lower", "upper"], [lower, upper]):
50+
for name, bound in zip(["lower", "upper"], [lower, upper], strict=False):
5051
if not np.isfinite(bound).all():
5152
raise ValueError(
5253
f"multistart optimization requires finite {name}_bounds or "

src/tranquilo/filter_points.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
from tranquilo.clustering import cluster
55
from tranquilo.get_component import get_component
6-
from tranquilo.volume import get_radius_after_volume_scaling
76
from tranquilo.options import FilterOptions
7+
from tranquilo.volume import get_radius_after_volume_scaling
88

99

1010
def get_sample_filter(sample_filter="keep_all", user_options=None):

src/tranquilo/fit_models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66

77
from tranquilo.get_component import get_component
88
from tranquilo.handle_infinity import get_infinity_handler
9-
from tranquilo.options import FitterOptions
109
from tranquilo.models import (
1110
VectorModel,
1211
add_models,
1312
move_model,
1413
n_second_order_terms,
1514
)
15+
from tranquilo.options import FitterOptions
1616

1717

1818
def get_fitter(

src/tranquilo/get_component.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import warnings
44
from functools import partial
55

6-
from tranquilo.utilities import propose_alternatives
76
from tranquilo.options import update_option_bundle
7+
from tranquilo.utilities import propose_alternatives
88

99

1010
def get_component(
@@ -213,7 +213,7 @@ def _add_redundant_argument_handling(func, signature, warn):
213213

214214
@functools.wraps(func)
215215
def _wrapper_add_redundant_argument_handling(*args, **kwargs):
216-
_kwargs = {**dict(zip(signature[: len(args)], args)), **kwargs}
216+
_kwargs = {**dict(zip(signature[: len(args)], args, strict=False)), **kwargs}
217217

218218
_redundant = {k: v for k, v in _kwargs.items() if k not in signature}
219219
_valid = {k: v for k, v in _kwargs.items() if k in signature}

src/tranquilo/history.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def add_evals(self, x_indices, evals):
104104

105105
f_indices = np.arange(self.n_fun, self.n_fun + n_new_points)
106106

107-
for x_index, f_index in zip(x_indices, f_indices):
107+
for x_index, f_index in zip(x_indices, f_indices, strict=False):
108108
self.index_mapper[x_index].append(f_index)
109109

110110
self.n_fun += n_new_points

0 commit comments

Comments
 (0)