Skip to content
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

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

Merged
merged 3 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 6 additions & 6 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.4.0
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
Expand All @@ -9,24 +9,24 @@ repos:
- id: debug-statements
- id: check-ast
- repo: https://github.com/psf/black
rev: 23.3.0
rev: 24.2.0
hooks:
- id: black-jupyter
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: "v0.0.269"
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.2.1"
hooks:
- id: ruff
args: ["--fix"]
- repo: https://github.com/nbQA-dev/nbQA
rev: 1.7.0
rev: 1.7.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.3.0"
rev: "v1.8.0"
hooks:
- id: mypy
exclude: ipynb_filter.py|docs/source/conf.py
7 changes: 4 additions & 3 deletions adaptive/learner/average_learner1D.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@ def __init__(
self,
function: Callable[[tuple[int, Real]], Real],
bounds: tuple[Real, Real],
loss_per_interval: None
| (Callable[[Sequence[Real], Sequence[Real]], float]) = None,
loss_per_interval: None | (
Callable[[Sequence[Real], Sequence[Real]], float]
) = None,
delta: float = 0.2,
alpha: float = 0.005,
neighbor_sampling: float = 0.3,
Expand Down Expand Up @@ -310,7 +311,7 @@ def _ask_for_new_point(self, n: int) -> tuple[Points, list[float]]:
new point, since in general n << min_samples and this point will need
to be resampled many more times"""
points, (loss_improvement,) = self._ask_points_without_adding(1)
seed_points = [(seed, x) for seed, x in zip(range(n), n * points)]
seed_points = list(zip(range(n), n * points))
loss_improvements = [loss_improvement / n] * n
return seed_points, loss_improvements # type: ignore[return-value]

Expand Down
1 change: 0 additions & 1 deletion adaptive/learner/integrator_learner.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ class DivergentIntegralError(ValueError):


class _Interval:

"""
Attributes
----------
Expand Down
12 changes: 7 additions & 5 deletions adaptive/learner/learner1D.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def triangle_loss(xs: XsType1, ys: YsType1) -> Float:
pts = [(x, *y) for x, y in zip(xs, ys)] # type: ignore[misc]
vol = simplex_volume_in_embedding
else:
pts = [(x, y) for x, y in zip(xs, ys)]
pts = list(zip(xs, ys))
vol = volume
return sum(vol(pts[i : i + 3]) for i in range(N)) / N

Expand Down Expand Up @@ -633,10 +633,12 @@ def tell_pending(self, x: float) -> None:
def tell_many(
self,
xs: Sequence[Float] | np.ndarray,
ys: Sequence[Float]
| Sequence[Sequence[Float]]
| Sequence[np.ndarray]
| np.ndarray,
ys: (
Sequence[Float]
| Sequence[Sequence[Float]]
| Sequence[np.ndarray]
| np.ndarray
),
*,
force: bool = False,
) -> None:
Expand Down
8 changes: 5 additions & 3 deletions adaptive/learner/learnerND.py
Original file line number Diff line number Diff line change
Expand Up @@ -987,9 +987,11 @@ def plot_slice(self, cut_mapping, n=None):
xs = ys = np.linspace(0, 1, n)
xys = [xs[:, None], ys[None, :]]
values = [
cut_mapping[i]
if i in cut_mapping
else xys.pop(0) * (b[1] - b[0]) + b[0]
(
cut_mapping[i]
if i in cut_mapping
else xys.pop(0) * (b[1] - b[0]) + b[0]
)
for i, b in enumerate(self._bbox)
]

Expand Down
6 changes: 3 additions & 3 deletions adaptive/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ def __init__(
npoints_goal: int | None = None,
end_time_goal: datetime | None = None,
duration_goal: timedelta | int | float | None = None,
executor: (ExecutorTypes | None) = None,
executor: ExecutorTypes | None = None,
ntasks: int | None = None,
log: bool = False,
shutdown_executor: bool = False,
Expand Down Expand Up @@ -629,7 +629,7 @@ def __init__(
npoints_goal: int | None = None,
end_time_goal: datetime | None = None,
duration_goal: timedelta | int | float | None = None,
executor: (ExecutorTypes | None) = None,
executor: ExecutorTypes | None = None,
ntasks: int | None = None,
log: bool = False,
shutdown_executor: bool = False,
Expand Down Expand Up @@ -956,7 +956,7 @@ def _ensure_executor(executor: ExecutorTypes | None) -> concurrent.Executor:


def _get_ncores(
ex: (ExecutorTypes),
ex: ExecutorTypes,
) -> int:
"""Return the maximum number of cores that an executor can use."""
if with_ipyparallel:
Expand Down
8 changes: 5 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ python_version = "3.9"
[tool.ruff]
line-length = 150
target-version = "py39"

[tool.ruff.lint]
select = ["B", "C", "E", "F", "W", "T", "B9", "I", "UP"]
ignore = [
"T20", # flake8-print
Expand All @@ -109,14 +111,14 @@ ignore = [
"D401", # First line of docstring should be in imperative mood
]

[tool.ruff.lint.mccabe]
max-complexity = 18

[tool.ruff.per-file-ignores]
"tests/*" = ["SLF001"]
"ci/*" = ["INP001"]
"tests/test_examples.py" = ["E501"]

[tool.ruff.mccabe]
max-complexity = 18

[tool.versioningit]

[tool.versioningit.vcs]
Expand Down