Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jan 14, 2025
1 parent deeafba commit 6684599
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 21 deletions.
6 changes: 2 additions & 4 deletions adaptive/learner/average_learner1D.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 1 addition & 3 deletions adaptive/learner/balancing_learner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 1 addition & 2 deletions adaptive/learner/learnerND.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions adaptive/learner/triangulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 4 additions & 7 deletions adaptive/notebook_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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))

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

0 comments on commit 6684599

Please sign in to comment.