From be95f9a98ab0419dd5553f15049673acd8af880d Mon Sep 17 00:00:00 2001 From: Daniel Otto de Mentock Date: Mon, 6 Dec 2021 23:49:12 +0000 Subject: [PATCH] Typehints for crystal --- python/damask/_crystal.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/python/damask/_crystal.py b/python/damask/_crystal.py index fd87a90d4..ea9effffe 100644 --- a/python/damask/_crystal.py +++ b/python/damask/_crystal.py @@ -1,3 +1,5 @@ +from typing import Union, Dict, List, Tuple + import numpy as np from . import util @@ -177,7 +179,7 @@ class Crystal(): @property - def standard_triangle(self): + def standard_triangle(self) -> Union[Dict[str, np.ndarray], None]: """ Corners of the standard triangle. @@ -238,7 +240,7 @@ class Crystal(): [-1., 0., 0.], [ 0., 1., 0.] ]), }} - return _basis.get(self.family,None) + return _basis.get(self.family, None) @property @@ -256,7 +258,7 @@ class Crystal(): @property - def basis_real(self): + def basis_real(self) -> np.ndarray: """ Return orthogonal real space crystal basis. @@ -280,7 +282,7 @@ class Crystal(): @property - def basis_reciprocal(self): + def basis_reciprocal(self) -> np.ndarray: """Return reciprocal (dual) crystal basis.""" return np.linalg.inv(self.basis_real.T) @@ -312,7 +314,7 @@ class Crystal(): + _lattice_points.get(self.lattice if self.lattice == 'hP' else \ self.lattice[-1],None),dtype=float) - def to_lattice(self,*,direction=None,plane=None): + def to_lattice(self, *, direction: np.ndarray = None, plane: np.ndarray = None) -> np.ndarray: """ Calculate lattice vector corresponding to crystal frame direction or plane normal. @@ -336,7 +338,7 @@ class Crystal(): return np.einsum('il,...l',basis,axis) - def to_frame(self,*,uvw=None,hkl=None): + def to_frame(self, *, uvw: np.ndarray = None, hkl: np.ndarray = None) -> np.ndarray: """ Calculate crystal frame vector along lattice direction [uvw] or plane normal (hkl). @@ -359,7 +361,7 @@ class Crystal(): return np.einsum('il,...l',basis,axis) - def kinematics(self,mode): + def kinematics(self, mode: str) -> Dict[str, List[np.ndarray]]: """ Return crystal kinematics systems. @@ -555,7 +557,7 @@ class Crystal(): 'plane': [m[:,3:6] for m in master]} - def relation_operations(self,model): + def relation_operations(self, model: str) -> Tuple[str, Rotation]: """ Crystallographic orientation relationships for phase transformations.