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

Updated black formatter #529

Merged
merged 1 commit into from
Jan 28, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions pde/fields/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 2 additions & 4 deletions pde/grids/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions pde/grids/operators/cartesian.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

.. codeauthor:: David Zwicker <[email protected]>
"""

from __future__ import annotations

from typing import Callable, Literal
Expand Down
1 change: 1 addition & 0 deletions pde/grids/operators/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

.. codeauthor:: David Zwicker <[email protected]>
"""

from __future__ import annotations

import logging
Expand Down
1 change: 1 addition & 0 deletions pde/grids/operators/cylindrical_sym.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

.. codeauthor:: David Zwicker <[email protected]>
"""

from __future__ import annotations

from typing import Literal
Expand Down
1 change: 1 addition & 0 deletions pde/grids/operators/spherical_sym.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

.. codeauthor:: David Zwicker <[email protected]>
"""

from __future__ import annotations

from typing import Literal
Expand Down
4 changes: 1 addition & 3 deletions pde/grids/spherical.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions pde/pdes/allen_cahn.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

.. codeauthor:: David Zwicker <[email protected]>
"""

from __future__ import annotations

from typing import Callable
Expand Down
1 change: 1 addition & 0 deletions pde/pdes/cahn_hilliard.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

.. codeauthor:: David Zwicker <[email protected]>
"""

from __future__ import annotations

from typing import Callable
Expand Down
1 change: 1 addition & 0 deletions pde/pdes/diffusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

.. codeauthor:: David Zwicker <[email protected]>
"""

from __future__ import annotations

from typing import Callable
Expand Down
1 change: 1 addition & 0 deletions pde/pdes/kpz_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

.. codeauthor:: David Zwicker <[email protected]>
"""

from __future__ import annotations

from typing import Callable
Expand Down
1 change: 1 addition & 0 deletions pde/pdes/kuramoto_sivashinsky.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

.. codeauthor:: David Zwicker <[email protected]>
"""

from __future__ import annotations

from typing import Callable
Expand Down
1 change: 1 addition & 0 deletions pde/pdes/laplace.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

.. codeauthor:: David Zwicker <[email protected]>
"""

from __future__ import annotations

from ..fields import ScalarField
Expand Down
8 changes: 5 additions & 3 deletions pde/pdes/pde.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)

Expand Down
1 change: 1 addition & 0 deletions pde/pdes/swift_hohenberg.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

.. codeauthor:: David Zwicker <[email protected]>
"""

from __future__ import annotations

from typing import Callable
Expand Down
1 change: 1 addition & 0 deletions pde/pdes/wave.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

.. codeauthor:: David Zwicker <[email protected]>
"""

from __future__ import annotations

from typing import Callable
Expand Down
4 changes: 1 addition & 3 deletions pde/solvers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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],
]:
Expand Down
1 change: 1 addition & 0 deletions pde/solvers/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

.. codeauthor:: David Zwicker <[email protected]>
"""

from __future__ import annotations

import datetime
Expand Down
1 change: 1 addition & 0 deletions pde/solvers/crank_nicolson.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

.. codeauthor:: David Zwicker <[email protected]>
"""

from __future__ import annotations

from typing import Callable
Expand Down
9 changes: 3 additions & 6 deletions pde/solvers/explicit.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

.. codeauthor:: David Zwicker <[email protected]>
"""

from __future__ import annotations

from typing import Callable, Literal
Expand Down Expand Up @@ -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],
]:
Expand Down Expand Up @@ -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],
]:
Expand Down
1 change: 1 addition & 0 deletions pde/solvers/implicit.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

.. codeauthor:: David Zwicker <[email protected]>
"""

from __future__ import annotations

from typing import Callable
Expand Down
1 change: 1 addition & 0 deletions pde/solvers/scipy.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

.. codeauthor:: David Zwicker <[email protected]>
"""

from __future__ import annotations

from typing import Callable
Expand Down
1 change: 1 addition & 0 deletions pde/tools/docstrings.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

.. codeauthor:: David Zwicker <[email protected]>
"""

from __future__ import annotations

import re
Expand Down
1 change: 1 addition & 0 deletions pde/tools/numba.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

.. codeauthor:: David Zwicker <[email protected]>
"""

from __future__ import annotations

import logging
Expand Down
1 change: 0 additions & 1 deletion pde/trackers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
.. codeauthor:: David Zwicker <[email protected]>
"""


from .base import get_named_trackers
from .interactive import InteractivePlotTracker
from .interrupts import (
Expand Down
1 change: 1 addition & 0 deletions pde/trackers/interactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

.. codeauthor:: David Zwicker <[email protected]>
"""

from __future__ import annotations

import logging
Expand Down
1 change: 1 addition & 0 deletions pde/visualization/movies.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

.. codeauthor:: David Zwicker <[email protected]>
"""

from __future__ import annotations

import pathlib
Expand Down
2 changes: 1 addition & 1 deletion scripts/create_requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
1 change: 1 addition & 0 deletions tests/fields/fixtures/fields.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
.. codeauthor:: David Zwicker <[email protected]>
"""

import numpy as np

from pde import (
Expand Down
2 changes: 1 addition & 1 deletion tests/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-r ../requirements.txt
black>=19.*
black>=24.*
importlib-metadata>=5
isort>=5.1
jupyter_contrib_nbextensions>=0.5
Expand Down
Loading