Skip to content

Commit d2c8041

Browse files
authored
Use ruff-format instead of black (#446)
1 parent 378f9f6 commit d2c8041

File tree

5 files changed

+19
-16
lines changed

5 files changed

+19
-16
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,12 @@ repos:
88
- id: check-yaml
99
- id: debug-statements
1010
- id: check-ast
11-
- repo: https://github.com/psf/black
12-
rev: 24.2.0
13-
hooks:
14-
- id: black-jupyter
1511
- repo: https://github.com/astral-sh/ruff-pre-commit
1612
rev: "v0.2.1"
1713
hooks:
1814
- id: ruff
1915
args: ["--fix"]
16+
- id: ruff-format
2017
- repo: https://github.com/nbQA-dev/nbQA
2118
rev: 1.7.1
2219
hooks:

adaptive/learner/average_learner1D.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,8 @@ def __init__(
7979
self,
8080
function: Callable[[tuple[int, Real]], Real],
8181
bounds: tuple[Real, Real],
82-
loss_per_interval: None | (
83-
Callable[[Sequence[Real], Sequence[Real]], float]
84-
) = None,
82+
loss_per_interval: None
83+
| (Callable[[Sequence[Real], Sequence[Real]], float]) = None,
8584
delta: float = 0.2,
8685
alpha: float = 0.005,
8786
neighbor_sampling: float = 0.3,

adaptive/runner.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -788,8 +788,8 @@ def live_info_terminal(
788788
Parameters
789789
----------
790790
update_interval : float, optional
791-
The time interval (in seconds) at which the runner's status is updated in the terminal.
792-
Default is 0.5 seconds.
791+
The time interval (in seconds) at which the runner's status is updated
792+
in the terminal. Default is 0.5 seconds.
793793
overwrite_previous : bool, optional
794794
If True, each update will overwrite the previous status in the terminal.
795795
If False, each update will be printed on a new line.
@@ -798,7 +798,8 @@ def live_info_terminal(
798798
Returns
799799
-------
800800
asyncio.Task
801-
The asynchronous task responsible for updating the runner's status in the terminal.
801+
The asynchronous task responsible for updating the runner's status in
802+
the terminal.
802803
803804
Examples
804805
--------
@@ -807,8 +808,8 @@ def live_info_terminal(
807808
808809
Notes
809810
-----
810-
This function uses ANSI escape sequences to control the terminal's cursor position.
811-
It might not work as expected on all terminal emulators.
811+
This function uses ANSI escape sequences to control the terminal's cursor
812+
position. It might not work as expected on all terminal emulators.
812813
"""
813814

814815
async def _update(runner: AsyncRunner) -> None:
@@ -1189,7 +1190,8 @@ def auto_goal(
11891190
for lrn in learner.learners
11901191
]
11911192
return lambda learner: all(
1192-
goal(lrn) for lrn, goal in zip(learner.learners, goals) # type: ignore[attr-defined]
1193+
goal(lrn)
1194+
for lrn, goal in zip(learner.learners, goals) # type: ignore[attr-defined]
11931195
)
11941196
if npoints is not None:
11951197
return lambda learner: learner.npoints >= npoints # type: ignore[operator]

adaptive/tests/algorithm_4.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,11 @@ def refine(self, f: Callable) -> tuple[np.ndarray, bool, int]:
319319

320320

321321
def algorithm_4(
322-
f: Callable, a: int, b: int, tol: float, N_loops: int = int(1e9) # noqa: B008
322+
f: Callable,
323+
a: int,
324+
b: int,
325+
tol: float,
326+
N_loops: int = int(1e9), # noqa: B008
323327
) -> tuple[float, float, int, list[_Interval]]:
324328
"""ALGORITHM_4 evaluates an integral using adaptive quadrature. The
325329
algorithm uses Clenshaw-Curtis quadrature rules of increasing

pyproject.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ ignore_missing_imports = true
9595
python_version = "3.9"
9696

9797
[tool.ruff]
98-
line-length = 150
98+
line-length = 88
9999
target-version = "py39"
100100

101101
[tool.ruff.lint]
@@ -109,12 +109,13 @@ ignore = [
109109
"D402", # First line should not be the function's signature
110110
"PLW0603", # Using the global statement to update `X` is discouraged
111111
"D401", # First line of docstring should be in imperative mood
112+
"E501", # Line too long
112113
]
113114

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

117-
[tool.ruff.per-file-ignores]
118+
[tool.ruff.lint.per-file-ignores]
118119
"tests/*" = ["SLF001"]
119120
"ci/*" = ["INP001"]
120121
"tests/test_examples.py" = ["E501"]

0 commit comments

Comments
 (0)