added generic types to remaining non-overwritten rotation functions (exception __mul__)
This commit is contained in:
parent
d1f9e98e3c
commit
9dad54304c
|
@ -165,7 +165,6 @@ class Orientation(Rotation,Crystal):
|
|||
Orientation to check for equality.
|
||||
|
||||
"""
|
||||
|
||||
eq = self.__eq__(other)
|
||||
if not isinstance(eq, bool):
|
||||
return eq
|
||||
|
@ -501,8 +500,8 @@ class Orientation(Rotation,Crystal):
|
|||
return np.ones_like(rho[...,0],dtype=bool)
|
||||
|
||||
def disorientation(self,
|
||||
other,
|
||||
return_operators = False):
|
||||
other: "Orientation",
|
||||
return_operators: bool = False) -> object:
|
||||
"""
|
||||
Calculate disorientation between myself and given other orientation.
|
||||
|
||||
|
@ -575,9 +574,9 @@ class Orientation(Rotation,Crystal):
|
|||
r = np.where(np.any(forward[...,np.newaxis],axis=(0,1),keepdims=True),
|
||||
r_.quaternion,
|
||||
_r.quaternion)
|
||||
loc: Tuple[float] = np.where(ok)
|
||||
sort: np.ndarray = 0 if len(loc) == 2 else np.lexsort(loc[:1:-1])
|
||||
quat: np.ndarray = r[ok][sort].reshape(blend+(4,))
|
||||
loc = np.where(ok)
|
||||
sort = 0 if len(loc) == 2 else np.lexsort(loc[:1:-1])
|
||||
quat = r[ok][sort].reshape(blend+(4,))
|
||||
return (
|
||||
(self.copy(rotation=quat),
|
||||
(np.vstack(loc[:2]).T)[sort].reshape(blend+(2,)))
|
||||
|
|
|
@ -259,7 +259,7 @@ class Rotation:
|
|||
return self**exp
|
||||
|
||||
|
||||
def __mul__(self, other: 'Rotation') -> 'Rotation':
|
||||
def __mul__(self: MyType, other: MyType) -> MyType:
|
||||
"""
|
||||
Compose with other.
|
||||
|
||||
|
@ -281,12 +281,12 @@ class Rotation:
|
|||
p_o = other.quaternion[...,1:]
|
||||
q = (q_m*q_o - np.einsum('...i,...i',p_m,p_o).reshape(self.shape+(1,)))
|
||||
p = q_m*p_o + q_o*p_m + _P * np.cross(p_m,p_o)
|
||||
return Rotation(np.block([q,p]))._standardize()
|
||||
return Rotation(np.block([q,p]))._standardize() #type: ignore
|
||||
else:
|
||||
raise TypeError('Use "R@b", i.e. matmul, to apply rotation "R" to object "b"')
|
||||
|
||||
def __imul__(self,
|
||||
other: 'Rotation') -> 'Rotation':
|
||||
def __imul__(self: MyType,
|
||||
other: MyType) -> MyType:
|
||||
"""
|
||||
Compose with other (in-place).
|
||||
|
||||
|
@ -299,8 +299,8 @@ class Rotation:
|
|||
return self*other
|
||||
|
||||
|
||||
def __truediv__(self: 'Rotation',
|
||||
other: 'Rotation') -> 'Rotation':
|
||||
def __truediv__(self: MyType,
|
||||
other: MyType) -> MyType:
|
||||
"""
|
||||
Compose with inverse of other.
|
||||
|
||||
|
@ -320,8 +320,8 @@ class Rotation:
|
|||
else:
|
||||
raise TypeError('Use "R@b", i.e. matmul, to apply rotation "R" to object "b"')
|
||||
|
||||
def __itruediv__(self: 'Rotation',
|
||||
other: 'Rotation') -> 'Rotation':
|
||||
def __itruediv__(self: MyType,
|
||||
other: MyType) -> MyType:
|
||||
"""
|
||||
Compose with inverse of other (in-place).
|
||||
|
||||
|
@ -492,8 +492,8 @@ class Rotation:
|
|||
accept_homomorph = True)
|
||||
|
||||
|
||||
def misorientation(self,
|
||||
other: 'Rotation') -> 'Rotation':
|
||||
def misorientation(self: MyType,
|
||||
other: MyType) -> MyType:
|
||||
"""
|
||||
Calculate misorientation to other Rotation.
|
||||
|
||||
|
|
Loading…
Reference in New Issue