diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5a0a4184..592fe1fc 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.6.0 + rev: v5.0.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer @@ -9,13 +9,13 @@ repos: - id: debug-statements - id: check-ast - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.3.5" + rev: "v0.9.1" hooks: - id: ruff args: ["--fix"] - id: ruff-format - repo: https://github.com/nbQA-dev/nbQA - rev: 1.8.5 + rev: 1.9.1 hooks: - id: nbqa-black additional_dependencies: [jupytext, black] @@ -23,7 +23,7 @@ repos: args: ["ruff", "--fix", "--ignore=E402,B018,F704"] additional_dependencies: [jupytext, ruff] - repo: https://github.com/pre-commit/mirrors-mypy - rev: "v1.9.0" + rev: "v1.14.1" hooks: - id: mypy exclude: ipynb_filter.py|docs/source/conf.py diff --git a/adaptive/learner/average_learner1D.py b/adaptive/learner/average_learner1D.py index 9678b4f6..7ac23873 100644 --- a/adaptive/learner/average_learner1D.py +++ b/adaptive/learner/average_learner1D.py @@ -500,8 +500,7 @@ def tell_many( # type: ignore[override] # but ignore it going forward. if not np.prod([x >= self.bounds[0] and x <= self.bounds[1] for _, x in xs]): raise ValueError( - "x value out of bounds, " - "remove x or enlarge the bounds of the learner" + "x value out of bounds, remove x or enlarge the bounds of the learner" ) # Create a mapping of points to a list of samples @@ -534,8 +533,7 @@ def tell_many_at_point(self, x: Real, seed_y_mapping: dict[int, Real]) -> None: # Check x is within the bounds if not np.prod(x >= self.bounds[0] and x <= self.bounds[1]): raise ValueError( - "x value out of bounds, " - "remove x or enlarge the bounds of the learner" + "x value out of bounds, remove x or enlarge the bounds of the learner" ) # If x is a new point: diff --git a/adaptive/learner/balancing_learner.py b/adaptive/learner/balancing_learner.py index e9a4a661..d5a6569c 100644 --- a/adaptive/learner/balancing_learner.py +++ b/adaptive/learner/balancing_learner.py @@ -116,9 +116,7 @@ def __init__( self._cdims_default = cdims if len({learner.__class__ for learner in self.learners}) > 1: - raise TypeError( - "A BalacingLearner can handle only one type" " of learners." - ) + raise TypeError("A BalacingLearner can handle only one type of learners.") self.strategy: STRATEGY_TYPE = strategy diff --git a/adaptive/learner/learnerND.py b/adaptive/learner/learnerND.py index c4af7ddc..d0300143 100644 --- a/adaptive/learner/learnerND.py +++ b/adaptive/learner/learnerND.py @@ -1098,8 +1098,7 @@ def _get_iso(self, level=0.0, which="surface"): if which == "surface": if self.ndim != 3 or self.vdim != 1: raise Exception( - "Isosurface plotting is only supported" - " for a 3D input and 1D output" + "Isosurface plotting is only supported for a 3D input and 1D output" ) get_surface = True get_line = False diff --git a/adaptive/learner/triangulation.py b/adaptive/learner/triangulation.py index 03455e3b..26a5ebc2 100644 --- a/adaptive/learner/triangulation.py +++ b/adaptive/learner/triangulation.py @@ -336,8 +336,7 @@ def __init__(self, coords): vectors = subtract(coords[1:], coords[0]) if matrix_rank(vectors) < dim: raise ValueError( - "Initial simplex has zero volumes " - "(the points are linearly dependent)" + "Initial simplex has zero volumes (the points are linearly dependent)" ) self.vertices = list(coords) diff --git a/adaptive/notebook_integration.py b/adaptive/notebook_integration.py index 165a84d8..20a39cf0 100644 --- a/adaptive/notebook_integration.py +++ b/adaptive/notebook_integration.py @@ -17,8 +17,7 @@ def notebook_extension(*, _inline_js=True): """Enable ipywidgets, holoviews, and asyncio notebook integration.""" if not in_ipynb(): raise RuntimeError( - '"adaptive.notebook_extension()" may only be run ' - "from a Jupyter notebook." + '"adaptive.notebook_extension()" may only be run from a Jupyter notebook.' ) global _async_enabled, _holoviews_enabled, _ipywidgets_enabled @@ -122,8 +121,7 @@ def live_plot(runner, *, plotter=None, update_interval=2, name=None, normalize=T """ if not _holoviews_enabled: raise RuntimeError( - "Live plotting is not enabled; did you run " - "'adaptive.notebook_extension()'?" + "Live plotting is not enabled; did you run 'adaptive.notebook_extension()'?" ) import holoviews as hv @@ -208,8 +206,7 @@ def live_info(runner, *, update_interval=0.5): """ if not _holoviews_enabled: raise RuntimeError( - "Live plotting is not enabled; did you run " - "'adaptive.notebook_extension()'?" + "Live plotting is not enabled; did you run 'adaptive.notebook_extension()'?" ) import ipywidgets @@ -274,7 +271,7 @@ def _info_html(runner): info.append(("# of samples", runner.learner.nsamples)) with suppress(Exception): - info.append(("latest loss", f'{runner.learner._cache["loss"]:.3f}')) + info.append(("latest loss", f"{runner.learner._cache['loss']:.3f}")) table = "\n".join(_table_row(i, k, v) for i, (k, v) in enumerate(info)) diff --git a/adaptive/runner.py b/adaptive/runner.py index 4f877096..9c2dc15f 100644 --- a/adaptive/runner.py +++ b/adaptive/runner.py @@ -935,7 +935,7 @@ def _info_text(runner, separator: str = "\n"): info.append(("# of samples", runner.learner.nsamples)) with suppress(Exception): - info.append(("latest loss", f'{runner.learner._cache["loss"]:.3f}')) + info.append(("latest loss", f"{runner.learner._cache['loss']:.3f}")) width = 30 formatted_info = [f"{k}: {v}".ljust(width) for i, (k, v) in enumerate(info)] diff --git a/example-notebook.ipynb b/example-notebook.ipynb index 4f49415f..db8df092 100644 --- a/example-notebook.ipynb +++ b/example-notebook.ipynb @@ -489,8 +489,7 @@ " print(\"WARINING: The runner hasn't reached it goal yet!\")\n", "\n", "print(\n", - " f\"The integral value is {learner.igral} \"\n", - " f\"with a corresponding error of {learner.err}\"\n", + " f\"The integral value is {learner.igral} with a corresponding error of {learner.err}\"\n", ")\n", "learner.plot()" ]