diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index cb7f97e8b..eccb0b4bd 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -9,7 +9,7 @@ repos: - id: debug-statements - id: check-ast - repo: https://github.com/psf/black - rev: 22.12.0 + rev: 23.1.0 hooks: - id: black - repo: https://github.com/asottile/pyupgrade diff --git a/adaptive/learner/learner1D.py b/adaptive/learner/learner1D.py index 9987da468..d147a5b84 100644 --- a/adaptive/learner/learner1D.py +++ b/adaptive/learner/learner1D.py @@ -342,7 +342,8 @@ def vdim(self) -> int: def to_numpy(self): """Data as NumPy array of size ``(npoints, 2)`` if ``learner.function`` returns a scalar - and ``(npoints, 1+vdim)`` if ``learner.function`` returns a vector of length ``vdim``.""" + and ``(npoints, 1+vdim)`` if ``learner.function`` returns a vector of length ``vdim``. + """ return np.array([(x, *np.atleast_1d(y)) for x, y in sorted(self.data.items())]) def to_dataframe( diff --git a/adaptive/learner/learner2D.py b/adaptive/learner/learner2D.py index 385f5b7d5..048c1f26f 100644 --- a/adaptive/learner/learner2D.py +++ b/adaptive/learner/learner2D.py @@ -407,7 +407,8 @@ def xy_scale(self) -> np.ndarray: def to_numpy(self): """Data as NumPy array of size ``(npoints, 3)`` if ``learner.function`` returns a scalar - and ``(npoints, 2+vdim)`` if ``learner.function`` returns a vector of length ``vdim``.""" + and ``(npoints, 2+vdim)`` if ``learner.function`` returns a vector of length ``vdim``. + """ return np.array( [(x, y, *np.atleast_1d(z)) for (x, y), z in sorted(self.data.items())] ) diff --git a/adaptive/runner.py b/adaptive/runner.py index ff3a137c3..9d1a24206 100644 --- a/adaptive/runner.py +++ b/adaptive/runner.py @@ -190,7 +190,6 @@ def __init__( raise_if_retries_exceeded: bool = True, allow_running_forever: bool = False, ): - self.executor = _ensure_executor(executor) self.goal = _goal( learner, @@ -638,7 +637,6 @@ def __init__( retries: int = 0, raise_if_retries_exceeded: bool = True, ) -> None: - if ( executor is None and _default_executor is concurrent.ProcessPoolExecutor @@ -977,6 +975,7 @@ def _get_ncores( # --- Useful runner goals + # TODO: deprecate def stop_after(*, seconds=0, minutes=0, hours=0) -> Callable[[BaseLearner], bool]: """Stop a runner after a specified time. diff --git a/adaptive/tests/test_learner1d.py b/adaptive/tests/test_learner1d.py index f3c555a04..d0d595594 100644 --- a/adaptive/tests/test_learner1d.py +++ b/adaptive/tests/test_learner1d.py @@ -128,7 +128,6 @@ def f(x): def test_termination_on_discontinuities(): - learner = _run_on_discontinuity(0, (-1, 1)) smallest_interval = min(abs(a - b) for a, b in learner.losses.keys()) assert smallest_interval >= np.finfo(float).eps