diff --git a/pde/fields/collection.py b/pde/fields/collection.py index 6f028562..a3bb27ff 100644 --- a/pde/fields/collection.py +++ b/pde/fields/collection.py @@ -158,12 +158,10 @@ def __iter__(self) -> Iterator[DataFieldBase]: return iter(self.fields) @overload - def __getitem__(self, index: int | str) -> DataFieldBase: - ... + def __getitem__(self, index: int | str) -> DataFieldBase: ... @overload - def __getitem__(self, index: slice) -> FieldCollection: - ... + def __getitem__(self, index: slice) -> FieldCollection: ... def __getitem__(self, index: int | str | slice) -> DataFieldBase | FieldCollection: """returns one or many fields from the collection diff --git a/pde/grids/base.py b/pde/grids/base.py index 1927f4ac..ce25988f 100644 --- a/pde/grids/base.py +++ b/pde/grids/base.py @@ -335,14 +335,12 @@ def get_valid(data_full: np.ndarray) -> np.ndarray: return get_valid # type: ignore @overload - def _make_set_valid(self) -> Callable[[np.ndarray, np.ndarray], None]: - ... + def _make_set_valid(self) -> Callable[[np.ndarray, np.ndarray], None]: ... @overload def _make_set_valid( self, bcs: Boundaries - ) -> Callable[[np.ndarray, np.ndarray, dict], None]: - ... + ) -> Callable[[np.ndarray, np.ndarray, dict], None]: ... def _make_set_valid(self, bcs: Boundaries | None = None) -> Callable: """create a function to set the valid part of a full data array diff --git a/pde/grids/operators/cartesian.py b/pde/grids/operators/cartesian.py index 57d1e242..295b5513 100644 --- a/pde/grids/operators/cartesian.py +++ b/pde/grids/operators/cartesian.py @@ -14,6 +14,7 @@ .. codeauthor:: David Zwicker """ + from __future__ import annotations from typing import Callable, Literal diff --git a/pde/grids/operators/common.py b/pde/grids/operators/common.py index 6fd8a5a6..04d17c81 100644 --- a/pde/grids/operators/common.py +++ b/pde/grids/operators/common.py @@ -3,6 +3,7 @@ .. codeauthor:: David Zwicker """ + from __future__ import annotations import logging diff --git a/pde/grids/operators/cylindrical_sym.py b/pde/grids/operators/cylindrical_sym.py index 2e6362ef..65b4df40 100644 --- a/pde/grids/operators/cylindrical_sym.py +++ b/pde/grids/operators/cylindrical_sym.py @@ -14,6 +14,7 @@ .. codeauthor:: David Zwicker """ + from __future__ import annotations from typing import Literal diff --git a/pde/grids/operators/spherical_sym.py b/pde/grids/operators/spherical_sym.py index 9ba4c10a..d8fbd940 100644 --- a/pde/grids/operators/spherical_sym.py +++ b/pde/grids/operators/spherical_sym.py @@ -13,6 +13,7 @@ .. codeauthor:: David Zwicker """ + from __future__ import annotations from typing import Literal diff --git a/pde/grids/spherical.py b/pde/grids/spherical.py index 0187ec81..adcae31b 100644 --- a/pde/grids/spherical.py +++ b/pde/grids/spherical.py @@ -218,9 +218,7 @@ def get_random_point( raise RuntimeError("Random points would be too close to boundary") # choose random radius scaled such that points are uniformly distributed - r = np.array( - [rng.uniform(r_min**self.dim, r_max**self.dim) ** (1 / self.dim)] - ) + r = np.array([rng.uniform(r_min**self.dim, r_max**self.dim) ** (1 / self.dim)]) if coords == "cartesian": # choose random angles for the already chosen radius if self.dim == 2: diff --git a/pde/pdes/allen_cahn.py b/pde/pdes/allen_cahn.py index c3df06e1..36a22702 100644 --- a/pde/pdes/allen_cahn.py +++ b/pde/pdes/allen_cahn.py @@ -3,6 +3,7 @@ .. codeauthor:: David Zwicker """ + from __future__ import annotations from typing import Callable diff --git a/pde/pdes/cahn_hilliard.py b/pde/pdes/cahn_hilliard.py index f2747098..4ff425fa 100644 --- a/pde/pdes/cahn_hilliard.py +++ b/pde/pdes/cahn_hilliard.py @@ -3,6 +3,7 @@ .. codeauthor:: David Zwicker """ + from __future__ import annotations from typing import Callable diff --git a/pde/pdes/diffusion.py b/pde/pdes/diffusion.py index 73fcd7ab..a006dfcc 100644 --- a/pde/pdes/diffusion.py +++ b/pde/pdes/diffusion.py @@ -3,6 +3,7 @@ .. codeauthor:: David Zwicker """ + from __future__ import annotations from typing import Callable diff --git a/pde/pdes/kpz_interface.py b/pde/pdes/kpz_interface.py index 6ef923bd..308d85b9 100644 --- a/pde/pdes/kpz_interface.py +++ b/pde/pdes/kpz_interface.py @@ -3,6 +3,7 @@ .. codeauthor:: David Zwicker """ + from __future__ import annotations from typing import Callable diff --git a/pde/pdes/kuramoto_sivashinsky.py b/pde/pdes/kuramoto_sivashinsky.py index 325c9b7b..acc4bc52 100644 --- a/pde/pdes/kuramoto_sivashinsky.py +++ b/pde/pdes/kuramoto_sivashinsky.py @@ -3,6 +3,7 @@ .. codeauthor:: David Zwicker """ + from __future__ import annotations from typing import Callable diff --git a/pde/pdes/laplace.py b/pde/pdes/laplace.py index 59d1fa4c..579295c4 100644 --- a/pde/pdes/laplace.py +++ b/pde/pdes/laplace.py @@ -3,6 +3,7 @@ .. codeauthor:: David Zwicker """ + from __future__ import annotations from ..fields import ScalarField diff --git a/pde/pdes/pde.py b/pde/pdes/pde.py index 280021ee..5eeda98f 100644 --- a/pde/pdes/pde.py +++ b/pde/pdes/pde.py @@ -458,9 +458,11 @@ def _prepare_cache( def get_data_tuple(state_data: np.ndarray) -> tuple[np.ndarray, ...]: """helper for turning state_data into a tuple of field data""" return tuple( - state_data[starts[i]] - if isscalar[i] - else state_data[starts[i] : stops[i]] + ( + state_data[starts[i]] + if isscalar[i] + else state_data[starts[i] : stops[i]] + ) for i in range(num_fields) ) diff --git a/pde/pdes/swift_hohenberg.py b/pde/pdes/swift_hohenberg.py index a7a91530..b418146b 100644 --- a/pde/pdes/swift_hohenberg.py +++ b/pde/pdes/swift_hohenberg.py @@ -3,6 +3,7 @@ .. codeauthor:: David Zwicker """ + from __future__ import annotations from typing import Callable diff --git a/pde/pdes/wave.py b/pde/pdes/wave.py index 83b02601..86559701 100644 --- a/pde/pdes/wave.py +++ b/pde/pdes/wave.py @@ -3,6 +3,7 @@ .. codeauthor:: David Zwicker """ + from __future__ import annotations from typing import Callable diff --git a/pde/solvers/base.py b/pde/solvers/base.py index 6615122e..4361b043 100644 --- a/pde/solvers/base.py +++ b/pde/solvers/base.py @@ -475,9 +475,7 @@ def single_step_error_estimate( return single_step_error_estimate - def _make_adaptive_stepper( - self, state: FieldBase - ) -> Callable[ + def _make_adaptive_stepper(self, state: FieldBase) -> Callable[ [np.ndarray, float, float, float, OnlineStatistics | None], tuple[float, float, int, float], ]: diff --git a/pde/solvers/controller.py b/pde/solvers/controller.py index ab382cdd..25533100 100644 --- a/pde/solvers/controller.py +++ b/pde/solvers/controller.py @@ -3,6 +3,7 @@ .. codeauthor:: David Zwicker """ + from __future__ import annotations import datetime diff --git a/pde/solvers/crank_nicolson.py b/pde/solvers/crank_nicolson.py index f8f74b63..bd957db1 100644 --- a/pde/solvers/crank_nicolson.py +++ b/pde/solvers/crank_nicolson.py @@ -3,6 +3,7 @@ .. codeauthor:: David Zwicker """ + from __future__ import annotations from typing import Callable diff --git a/pde/solvers/explicit.py b/pde/solvers/explicit.py index c0ad59c1..78fb3a1d 100644 --- a/pde/solvers/explicit.py +++ b/pde/solvers/explicit.py @@ -3,6 +3,7 @@ .. codeauthor:: David Zwicker """ + from __future__ import annotations from typing import Callable, Literal @@ -152,9 +153,7 @@ def _make_single_step_fixed_dt( else: raise ValueError(f"Explicit scheme `{self.scheme}` is not supported") - def _make_adaptive_euler_stepper( - self, state: FieldBase - ) -> Callable[ + def _make_adaptive_euler_stepper(self, state: FieldBase) -> Callable[ [np.ndarray, float, float, float, OnlineStatistics | None], tuple[float, float, int, float], ]: @@ -370,9 +369,7 @@ def _make_single_step_error_estimate( # optimizations; see method `_make_adaptive_euler_stepper` raise ValueError(f"Adaptive scheme `{self.scheme}` is not supported") - def _make_adaptive_stepper( - self, state: FieldBase - ) -> Callable[ + def _make_adaptive_stepper(self, state: FieldBase) -> Callable[ [np.ndarray, float, float, float, OnlineStatistics | None], tuple[float, float, int, float], ]: diff --git a/pde/solvers/implicit.py b/pde/solvers/implicit.py index 0239bfb6..60a7740c 100644 --- a/pde/solvers/implicit.py +++ b/pde/solvers/implicit.py @@ -3,6 +3,7 @@ .. codeauthor:: David Zwicker """ + from __future__ import annotations from typing import Callable diff --git a/pde/solvers/scipy.py b/pde/solvers/scipy.py index 41dc275c..5745fd6a 100644 --- a/pde/solvers/scipy.py +++ b/pde/solvers/scipy.py @@ -3,6 +3,7 @@ .. codeauthor:: David Zwicker """ + from __future__ import annotations from typing import Callable diff --git a/pde/tools/docstrings.py b/pde/tools/docstrings.py index 6c4c9c62..f1e36841 100644 --- a/pde/tools/docstrings.py +++ b/pde/tools/docstrings.py @@ -10,6 +10,7 @@ .. codeauthor:: David Zwicker """ + from __future__ import annotations import re diff --git a/pde/tools/numba.py b/pde/tools/numba.py index 4b274f2e..abc051f7 100644 --- a/pde/tools/numba.py +++ b/pde/tools/numba.py @@ -3,6 +3,7 @@ .. codeauthor:: David Zwicker """ + from __future__ import annotations import logging diff --git a/pde/trackers/__init__.py b/pde/trackers/__init__.py index 7d481a92..aaec6551 100644 --- a/pde/trackers/__init__.py +++ b/pde/trackers/__init__.py @@ -47,7 +47,6 @@ .. codeauthor:: David Zwicker """ - from .base import get_named_trackers from .interactive import InteractivePlotTracker from .interrupts import ( diff --git a/pde/trackers/interactive.py b/pde/trackers/interactive.py index 7097de4a..bf531ec5 100644 --- a/pde/trackers/interactive.py +++ b/pde/trackers/interactive.py @@ -3,6 +3,7 @@ .. codeauthor:: David Zwicker """ + from __future__ import annotations import logging diff --git a/pde/visualization/movies.py b/pde/visualization/movies.py index f5d6d9ab..3437c6fe 100644 --- a/pde/visualization/movies.py +++ b/pde/visualization/movies.py @@ -11,6 +11,7 @@ .. codeauthor:: David Zwicker """ + from __future__ import annotations import pathlib diff --git a/scripts/create_requirements.py b/scripts/create_requirements.py index 55264cc3..d31b977a 100755 --- a/scripts/create_requirements.py +++ b/scripts/create_requirements.py @@ -152,7 +152,7 @@ def line(self, relation: str = ">=") -> str: Requirement( name="jupyter_contrib_nbextensions", version_min="0.5", tests_only=True ), - Requirement(name="black", version_min="19.*", tests_only=True), + Requirement(name="black", version_min="24.*", tests_only=True), Requirement(name="importlib-metadata", version_min="5", tests_only=True), Requirement(name="isort", version_min="5.1", tests_only=True), Requirement(name="mypy", version_min="0.770", tests_only=True), diff --git a/tests/fields/fixtures/fields.py b/tests/fields/fixtures/fields.py index 5a58a5c8..d9bd02f7 100644 --- a/tests/fields/fixtures/fields.py +++ b/tests/fields/fixtures/fields.py @@ -1,6 +1,7 @@ """ .. codeauthor:: David Zwicker """ + import numpy as np from pde import ( diff --git a/tests/requirements.txt b/tests/requirements.txt index 0c827b43..314c2b9d 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -1,5 +1,5 @@ -r ../requirements.txt -black>=19.* +black>=24.* importlib-metadata>=5 isort>=5.1 jupyter_contrib_nbextensions>=0.5