Skip to content

Commit

Permalink
Merge pull request #160 from pyiron/type_hints
Browse files Browse the repository at this point in the history
Add type hints
  • Loading branch information
jan-janssen authored Mar 19, 2024
2 parents 53cd6af + 975868a commit 32a421c
Show file tree
Hide file tree
Showing 16 changed files with 541 additions and 385 deletions.
12 changes: 10 additions & 2 deletions structuretoolkit/analyse/distance.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
from typing import Optional
from ase.atoms import Atoms
import numpy as np


def get_distances_array(structure, p1=None, p2=None, mic=True, vectors=False):
def get_distances_array(
structure: Atoms,
p1: Optional[np.ndarray] = None,
p2: Optional[np.ndarray] = None,
mic: bool = True,
vectors: bool = False,
):
"""
Return distance matrix of every position in p1 with every position in
p2. If p2 is not set, it is assumed that distances between all
Expand Down Expand Up @@ -39,7 +47,7 @@ def get_distances_array(structure, p1=None, p2=None, mic=True, vectors=False):
return find_mic(structure=structure, v=diff_relative, vectors=vectors)


def find_mic(structure, v, vectors=True):
def find_mic(structure: Atoms, v: np.ndarray, vectors: bool = True):
"""
Find vectors following minimum image convention (mic). In principle this
function does the same as ase.geometry.find_mic
Expand Down
41 changes: 23 additions & 18 deletions structuretoolkit/analyse/dscribe.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
import numpy as np
from ase.atoms import Atoms
from typing import Optional


def soap_descriptor_per_atom(
structure,
r_cut=None,
n_max=None,
l_max=None,
sigma=1.0,
rbf="gto",
weighting=None,
average="off",
compression={"mode": "off", "species_weighting": None},
species=None,
periodic=True,
sparse=False,
dtype="float64",
centers=None,
n_jobs=1,
only_physical_cores=False,
verbose=False,
):
structure: Atoms,
r_cut: Optional[float] = None,
n_max: Optional[int] = None,
l_max: Optional[int] = None,
sigma: Optional[float] = 1.0,
rbf: str = "gto",
weighting: Optional[np.ndarray] = None,
average: str = "off",
compression: dict = {"mode": "off", "species_weighting": None},
species: Optional[list] = None,
periodic: bool = True,
sparse: bool = False,
dtype: str = "float64",
centers: Optional[np.ndarray] = None,
n_jobs: int = 1,
only_physical_cores: bool = False,
verbose: bool = False,
) -> np.ndarray:
from dscribe.descriptors import SOAP

if species is None:
Expand Down
Loading

0 comments on commit 32a421c

Please sign in to comment.