Skip to content

[pre-commit.ci] pre-commit autoupdate #455

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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,21 +9,21 @@ repos:
- id: debug-statements
- id: check-ast
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.3.5"
rev: "v0.11.5"
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]
- id: nbqa
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.15.0"
hooks:
- id: mypy
exclude: ipynb_filter.py|docs/source/conf.py
6 changes: 2 additions & 4 deletions adaptive/learner/average_learner1D.py
Original file line number Diff line number Diff line change
@@ -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:
4 changes: 1 addition & 3 deletions adaptive/learner/balancing_learner.py
Original file line number Diff line number Diff line change
@@ -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

2 changes: 1 addition & 1 deletion adaptive/learner/learner2D.py
Original file line number Diff line number Diff line change
@@ -451,7 +451,7 @@ def __init__(
self.aspect_ratio = 1

self._bounds_points = list(itertools.product(*bounds))
self._stack.update({p: np.inf for p in self._bounds_points})
self._stack.update(dict.fromkeys(self._bounds_points, np.inf))
self.function = function # type: ignore
self._ip = self._ip_combined = None

3 changes: 1 addition & 2 deletions adaptive/learner/learnerND.py
Original file line number Diff line number Diff line change
@@ -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
3 changes: 1 addition & 2 deletions adaptive/learner/triangulation.py
Original file line number Diff line number Diff line change
@@ -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)
11 changes: 4 additions & 7 deletions adaptive/notebook_integration.py
Original file line number Diff line number Diff line change
@@ -16,8 +16,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 _holoviews_enabled, _ipywidgets_enabled
@@ -116,8 +115,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
@@ -202,8 +200,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
@@ -268,7 +265,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))

2 changes: 1 addition & 1 deletion adaptive/runner.py
Original file line number Diff line number Diff line change
@@ -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)]
3 changes: 1 addition & 2 deletions example-notebook.ipynb
Original file line number Diff line number Diff line change
@@ -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()"
]
Loading