-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add extended typing through janus_types module
- Loading branch information
Showing
4 changed files
with
104 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
""" | ||
Module containing types used in Janus-Core | ||
""" | ||
from pathlib import Path, PurePath | ||
from typing import IO, List, Literal, Optional, Sequence, TypedDict, TypeVar, Union | ||
|
||
from ase import Atoms | ||
import numpy as np | ||
from numpy.typing import NDArray | ||
|
||
|
||
# General | ||
|
||
T = TypeVar("T") | ||
MaybeList = Union[T, List[T]] | ||
MaybeSequence = Union[T, Sequence[T]] | ||
PathLike = Union[str, Path] | ||
|
||
|
||
# ASE Arg types | ||
|
||
class ASEReadArgs(TypedDict, total=False): | ||
"""Main arguments for ase.io.read""" | ||
filename: Union[str, PurePath, IO] | ||
index: Union[int, slice, str] | ||
format: Optional[str] | ||
parallel: bool | ||
do_not_split_by_at_sign: bool | ||
|
||
|
||
class ASEWriteArgs(TypedDict, total=False): | ||
"""Main arguments for ase.io.write""" | ||
filename: Union[str, PurePath, IO] | ||
images: MaybeSequence[Atoms] | ||
format: Optional[str] | ||
parallel: bool | ||
append: bool | ||
|
||
|
||
class ASEOptArgs(TypedDict, total=False): | ||
"""Main arugments for ase optimisers""" | ||
restart: Optional[bool] | ||
logfile: Optional[PathLike] | ||
trajectory: PathLike | ||
|
||
|
||
class ASEOptRunArgs(TypedDict, total=False): | ||
"""Main arugments for running ase optimisers""" | ||
fmax: float | ||
steps: int | ||
|
||
|
||
# Janus specific | ||
Architectures = Literal["mace", "mace_mp", "mace_off", "m3gnet", "chgnet"] | ||
Devices = Literal["cpu", "cuda", "mps"] | ||
|
||
|
||
class CalcResults(TypedDict, total=False): | ||
"""Return type from calculations""" | ||
energy: MaybeList[float] | ||
forces: MaybeList[NDArray[np.float64]] | ||
stress: MaybeList[NDArray[np.float64]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters