[skip ci] changed almost all function definition lines to multiline
This commit is contained in:
parent
777f2e7868
commit
0fe51f58a8
|
@ -123,7 +123,8 @@ class Orientation(Rotation,Crystal):
|
|||
return '\n'.join([Crystal.__repr__(self),
|
||||
Rotation.__repr__(self)])
|
||||
|
||||
def __copy__(self,rotation: Union[FloatSequence, Rotation] = None) -> "Orientation":
|
||||
def __copy__(self,
|
||||
rotation: Union[FloatSequence, Rotation] = None) -> "Orientation":
|
||||
"""Create deep copy."""
|
||||
dup = copy.deepcopy(self)
|
||||
if rotation is not None:
|
||||
|
@ -134,7 +135,8 @@ class Orientation(Rotation,Crystal):
|
|||
|
||||
|
||||
|
||||
def __eq__(self, other: object) -> bool:
|
||||
def __eq__(self,
|
||||
other: object) -> bool:
|
||||
"""
|
||||
Equal to other.
|
||||
|
||||
|
@ -151,7 +153,8 @@ class Orientation(Rotation,Crystal):
|
|||
self.parameters == other.parameters
|
||||
return np.logical_and(matching_type,super(self.__class__,self.reduced).__eq__(other.reduced))
|
||||
|
||||
def __ne__(self, other: object) -> bool:
|
||||
def __ne__(self,
|
||||
other: object) -> bool:
|
||||
"""
|
||||
Not equal to other.
|
||||
|
||||
|
@ -230,7 +233,8 @@ class Orientation(Rotation,Crystal):
|
|||
return np.all(self.isclose(other,rtol,atol,equal_nan))
|
||||
|
||||
|
||||
def __mul__(self, other: Union[Rotation, "Orientation"]) -> "Orientation":
|
||||
def __mul__(self,
|
||||
other: Union[Rotation, "Orientation"]) -> "Orientation":
|
||||
"""
|
||||
Compose this orientation with other.
|
||||
|
||||
|
@ -252,7 +256,8 @@ class Orientation(Rotation,Crystal):
|
|||
|
||||
|
||||
@staticmethod
|
||||
def _split_kwargs(kwargs: Dict[str, Any], target: Callable) -> Tuple[Dict[str, Any], ...]:
|
||||
def _split_kwargs(kwargs: Dict[str, Any],
|
||||
target: Callable) -> Tuple[Dict[str, Any], ...]:
|
||||
"""
|
||||
Separate keyword arguments in 'kwargs' targeted at 'target' from general keyword arguments of Orientation objects.
|
||||
|
||||
|
@ -492,7 +497,9 @@ class Orientation(Rotation,Crystal):
|
|||
else:
|
||||
return np.ones_like(rho[...,0],dtype=bool)
|
||||
|
||||
def disorientation(self, other, return_operators = False):
|
||||
def disorientation(self,
|
||||
other,
|
||||
return_operators = False):
|
||||
"""
|
||||
Calculate disorientation between myself and given other orientation.
|
||||
|
||||
|
@ -576,7 +583,9 @@ class Orientation(Rotation,Crystal):
|
|||
)
|
||||
|
||||
|
||||
def average(self, weights = None, return_cloud = False):
|
||||
def average(self,
|
||||
weights = None,
|
||||
return_cloud = False):
|
||||
"""
|
||||
Return orientation average over last dimension.
|
||||
|
||||
|
@ -659,7 +668,9 @@ class Orientation(Rotation,Crystal):
|
|||
)
|
||||
|
||||
|
||||
def in_SST(self, vector: np.ndarray, proper: bool = False) -> Union[np.bool_, np.ndarray]:
|
||||
def in_SST(self,
|
||||
vector: np.ndarray,
|
||||
proper: bool = False) -> Union[np.bool_, np.ndarray]:
|
||||
"""
|
||||
Check whether given crystal frame vector falls into standard stereographic triangle of own symmetry.
|
||||
|
||||
|
@ -700,7 +711,10 @@ class Orientation(Rotation,Crystal):
|
|||
return np.all(components >= 0.0,axis=-1)
|
||||
|
||||
|
||||
def IPF_color(self, vector: np.ndarray, in_SST: bool = True, proper: bool = False) -> np.ndarray:
|
||||
def IPF_color(self,
|
||||
vector: np.ndarray,
|
||||
in_SST: bool = True,
|
||||
proper: bool = False) -> np.ndarray:
|
||||
"""
|
||||
Map vector to RGB color within standard stereographic triangle of own symmetry.
|
||||
|
||||
|
@ -925,7 +939,8 @@ class Orientation(Rotation,Crystal):
|
|||
@ np.broadcast_to(P.reshape(util.shapeshifter(P.shape,shape)),shape)
|
||||
|
||||
|
||||
def related(self, model: str) -> "Orientation":
|
||||
def related(self,
|
||||
model: str) -> "Orientation":
|
||||
"""
|
||||
Orientations derived from the given relationship.
|
||||
|
||||
|
|
|
@ -64,7 +64,8 @@ class Rotation:
|
|||
|
||||
__slots__ = ['quaternion']
|
||||
|
||||
def __init__(self, rotation: Union[FloatSequence, "Rotation"] = np.array([1.0,0.0,0.0,0.0])):
|
||||
def __init__(self,
|
||||
rotation: Union[FloatSequence, "Rotation"] = np.array([1.0,0.0,0.0,0.0])):
|
||||
"""
|
||||
New rotation.
|
||||
|
||||
|
@ -91,7 +92,8 @@ class Rotation:
|
|||
+ str(self.quaternion)
|
||||
|
||||
|
||||
def __copy__(self, rotation: Union[FloatSequence, "Rotation"] = None) -> "Rotation":
|
||||
def __copy__(self,
|
||||
rotation: Union[FloatSequence, "Rotation"] = None) -> "Rotation":
|
||||
"""Create deep copy."""
|
||||
dup = copy.deepcopy(self)
|
||||
if rotation is not None:
|
||||
|
@ -101,7 +103,8 @@ class Rotation:
|
|||
copy = __copy__
|
||||
|
||||
|
||||
def __getitem__(self, item: Union[Tuple[int], int, bool, np.bool_, np.ndarray]):
|
||||
def __getitem__(self,
|
||||
item: Union[Tuple[int], int, bool, np.bool_, np.ndarray]):
|
||||
"""Return slice according to item."""
|
||||
return self.copy() \
|
||||
if self.shape == () else \
|
||||
|
@ -139,7 +142,11 @@ class Rotation:
|
|||
return np.logical_not(self==other)
|
||||
|
||||
|
||||
def isclose(self, other: "Rotation", rtol: float = 1e-5, atol: float = 1e-8, equal_nan: bool = True) -> bool:
|
||||
def isclose(self,
|
||||
other: "Rotation",
|
||||
rtol: float = 1e-5,
|
||||
atol: float = 1e-8,
|
||||
equal_nan: bool = True) -> bool:
|
||||
"""
|
||||
Report where values are approximately equal to corresponding ones of other Rotation.
|
||||
|
||||
|
@ -166,7 +173,11 @@ class Rotation:
|
|||
np.all(np.isclose(s,-1.0*o,rtol,atol,equal_nan),axis=-1))
|
||||
|
||||
|
||||
def allclose(self, other: "Rotation", rtol: float = 1e-5, atol: float = 1e-8, equal_nan: bool = True) -> Union[np.bool_, bool]:
|
||||
def allclose(self,
|
||||
other: "Rotation",
|
||||
rtol: float = 1e-5,
|
||||
atol: float = 1e-8,
|
||||
equal_nan: bool = True) -> Union[np.bool_, bool]:
|
||||
"""
|
||||
Test whether all values are approximately equal to corresponding ones of other Rotation.
|
||||
|
||||
|
@ -330,7 +341,7 @@ class Rotation:
|
|||
Rotated vector or tensor, i.e. transformed to frame defined by rotation.
|
||||
|
||||
"""
|
||||
if isinstance(other,np.ndarray):
|
||||
if isinstance(other, np.ndarray):
|
||||
if self.shape + (3,) == other.shape:
|
||||
q_m = self.quaternion[...,0]
|
||||
p_m = self.quaternion[...,1:]
|
||||
|
@ -350,7 +361,7 @@ class Rotation:
|
|||
return np.einsum('...im,...jn,...ko,...lp,...mnop',R,R,R,R,other)
|
||||
else:
|
||||
raise ValueError('Can only rotate vectors, 2nd order tensors, and 4th order tensors')
|
||||
elif isinstance(other,Rotation):
|
||||
elif isinstance(other, Rotation):
|
||||
raise TypeError('Use "R1*R2", i.e. multiplication, to compose rotations "R1" and "R2"')
|
||||
else:
|
||||
raise TypeError(f'Cannot rotate {type(other)}')
|
||||
|
@ -364,7 +375,9 @@ class Rotation:
|
|||
return self
|
||||
|
||||
|
||||
def append(self, other: Union["Rotation", List["Rotation"]]) -> "Rotation":
|
||||
def append(self,
|
||||
other: Union["Rotation",
|
||||
List["Rotation"]]) -> "Rotation":
|
||||
"""
|
||||
Extend array along first dimension with other array(s).
|
||||
|
||||
|
@ -377,7 +390,8 @@ class Rotation:
|
|||
[self]+other if isinstance(other,list) else [self,other]))))
|
||||
|
||||
|
||||
def flatten(self, order: Literal['C','F','A'] = 'C') -> "Rotation":
|
||||
def flatten(self,
|
||||
order: Literal['C','F','A'] = 'C') -> "Rotation":
|
||||
"""
|
||||
Flatten array.
|
||||
|
||||
|
@ -390,7 +404,9 @@ class Rotation:
|
|||
return self.copy(rotation=self.quaternion.reshape((-1,4),order=order))
|
||||
|
||||
|
||||
def reshape(self,shape: Union[int, Tuple[int, ...]], order: Literal['C','F','A'] = 'C') -> "Rotation":
|
||||
def reshape(self,
|
||||
shape: Union[int, Tuple[int, ...]],
|
||||
order: Literal['C','F','A'] = 'C') -> "Rotation":
|
||||
"""
|
||||
Reshape array.
|
||||
|
||||
|
@ -404,7 +420,9 @@ class Rotation:
|
|||
return self.copy(rotation=self.quaternion.reshape(tuple(shape)+(4,),order=order))
|
||||
|
||||
|
||||
def broadcast_to(self, shape: Union[int, Tuple[int, ...]], mode: Literal["left", "right"] = 'right') -> "Rotation":
|
||||
def broadcast_to(self,
|
||||
shape: Union[int, Tuple[int, ...]],
|
||||
mode: Literal["left", "right"] = 'right') -> "Rotation":
|
||||
"""
|
||||
Broadcast array.
|
||||
|
||||
|
@ -427,7 +445,8 @@ class Rotation:
|
|||
shape+(4,)))
|
||||
|
||||
|
||||
def average(self, weights: np.ndarray = None) -> "Rotation":
|
||||
def average(self,
|
||||
weights: np.ndarray = None) -> "Rotation":
|
||||
"""
|
||||
Average along last array dimension.
|
||||
|
||||
|
@ -466,7 +485,8 @@ class Rotation:
|
|||
accept_homomorph = True)
|
||||
|
||||
|
||||
def misorientation(self, other: "Rotation") -> "Rotation":
|
||||
def misorientation(self,
|
||||
other: "Rotation") -> "Rotation":
|
||||
"""
|
||||
Calculate misorientation to other Rotation.
|
||||
|
||||
|
@ -1649,7 +1669,8 @@ class Rotation:
|
|||
|
||||
|
||||
@staticmethod
|
||||
def _get_pyramid_order(xyz: np.ndarray, direction: Literal['forward', 'backward']) -> np.ndarray:
|
||||
def _get_pyramid_order(xyz: np.ndarray,
|
||||
direction: Literal['forward', 'backward']) -> np.ndarray:
|
||||
"""
|
||||
Get order of the coordinates.
|
||||
|
||||
|
|
Loading…
Reference in New Issue