Skip to content

Commit

Permalink
type: specify more details of the operator parameter spec
Browse files Browse the repository at this point in the history
  • Loading branch information
skim0119 committed Jun 29, 2024
1 parent 9519294 commit cddfa60
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions elastica/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"""

from typing import TYPE_CHECKING
from typing import Callable, Any, ParamSpec, TypeAlias
from typing import Callable, Any, TypeAlias, Protocol

import numpy as np

Expand Down Expand Up @@ -62,10 +62,16 @@
int | np.int32 | list[int] | tuple[int, ...] | np.typing.NDArray[np.int32]
)


# Operators in elastica.modules
OperatorParam = ParamSpec("OperatorParam")
OperatorType: TypeAlias = Callable[[np.float64], None] # args: time
OperatorCallbackType: TypeAlias = Callable[[np.float64, int], None] # args: time, step
class OperatorType(Protocol):
def __call__(self, time: np.float64) -> None: ...


class OperatorCallbackType(Protocol):
def __call__(self, time: np.float64, current_step: int) -> None: ...


OperatorFinalizeType: TypeAlias = Callable[[], None]

MeshType: TypeAlias = "MeshProtocol"

0 comments on commit cddfa60

Please sign in to comment.