11import copy
2+ import warnings
23from typing import Optional , Union , TypeVar , Literal , Sequence , NamedTuple # mypy 1.11, overload
34
45import numpy as np
6+ import numpy .typing as npt
57
68from ._typehints import FloatSequence , IntSequence , CrystalFamily , BravaisLattice , NumpyRngSeed
79from . import Rotation
@@ -156,9 +158,8 @@ def __copy__(self: MyType,
156158 copy = __copy__
157159
158160
159-
160- def __eq__ (self ,
161- other : object ) -> bool :
161+ def __eq__ (self , # type: ignore[override]
162+ other : object ) -> npt .NDArray [np .bool_ ]:
162163 """
163164 Return self==other.
164165
@@ -177,8 +178,8 @@ def __eq__(self,
177178 self .parameters == other .parameters
178179 return np .logical_and (matching_type ,super (self .__class__ ,self .reduced ).__eq__ (other .reduced ))
179180
180- def __ne__ (self ,
181- other : object ) -> bool :
181+ def __ne__ (self , # type: ignore[override]
182+ other : object ) -> npt . NDArray [ np . bool_ ] :
182183 """
183184 Return self!=other.
184185
@@ -190,14 +191,14 @@ def __ne__(self,
190191 Orientation to check for equality.
191192
192193 """
193- return np .logical_not (self == other ) if isinstance ( other , Orientation ) else NotImplemented
194+ return np .logical_not (self == other )
194195
195196
196197 def isclose (self : MyType ,
197198 other : MyType ,
198199 rtol : float = 1e-5 ,
199200 atol : float = 1e-8 ,
200- equal_nan : bool = True ) -> bool :
201+ equal_nan : bool = True ) -> np . ndarray :
201202 """
202203 Report where values are approximately equal to corresponding ones of other Orientation.
203204
@@ -223,13 +224,11 @@ def isclose(self: MyType,
223224 self .parameters == other .parameters
224225 return np .logical_and (matching_type ,super (self .__class__ ,self .reduced ).isclose (other .reduced ))
225226
226-
227-
228227 def allclose (self : MyType ,
229228 other : MyType ,
230229 rtol : float = 1e-5 ,
231230 atol : float = 1e-8 ,
232- equal_nan : bool = True ) -> bool :
231+ equal_nan : bool = True ) -> np . bool_ :
233232 """
234233 Test whether all values are approximately equal to corresponding ones of other Orientation.
235234
@@ -250,7 +249,7 @@ def allclose(self: MyType,
250249 Whether all values are close between both orientations.
251250
252251 """
253- return bool ( np .all (self .isclose (other ,rtol ,atol ,equal_nan ) ))
252+ return np .all (self .isclose (other ,rtol ,atol ,equal_nan ))
254253
255254
256255 def __mul__ (self : MyType ,
@@ -1359,15 +1358,16 @@ def average(self: MyType,
13591358 # mypy 1.11
13601359 #@overload
13611360 #def to_SST(self, vector: FloatSequence, proper: bool = False, # noqa
1362- # return_operators : Literal[False] = False) -> np.ndarray: ...
1361+ # return_operator : Literal[False] = False) -> np.ndarray: ...
13631362 #@overload
13641363 #def to_SST(self, vector: FloatSequence, proper: bool = False, # noqa
1365- # return_operators : Literal[True] = True) -> Tuple[np.ndarray,np.ndarray]: ...
1364+ # return_operator : Literal[True] = True) -> Tuple[np.ndarray,np.ndarray]: ...
13661365 def to_SST (self ,
13671366 vector : FloatSequence ,
13681367 proper : bool = False ,
1368+ return_operator : bool = False ,
13691369 # return_operators: bool = False) -> Union[np.ndarray,Tuple[np.ndarray,np.ndarray]]:
1370- return_operator : bool = False ) -> Union [np .ndarray , ToSSTTuple ]:
1370+ return_operators : bool = False ) -> Union [np .ndarray , ToSSTTuple ]:
13711371 """
13721372 Rotate lab frame vector to ensure it falls into (improper or proper) standard stereographic triangle of crystal symmetry.
13731373
@@ -1392,6 +1392,8 @@ def to_SST(self,
13921392 Index of the symmetrically equivalent orientation that rotated vector to SST.
13931393
13941394 """
1395+ if return_operators :
1396+ warnings .warn ('"return_operators" is deprecated, use "return_operator".' ,DeprecationWarning ,stacklevel = 2 )
13951397 vector_ = np .array (vector ,float )
13961398 if vector_ .shape [- 1 ] != 3 :
13971399 raise ValueError ('input is not a field of three-dimensional vectors' )
@@ -1520,13 +1522,13 @@ def IPF_color(self,
15201522 components_improper = np .around (np .einsum ('...ji,...i' ,
15211523 np .broadcast_to (self .standard_triangle ['improper' ], vector_ .shape + (3 ,)),
15221524 vector_ ), 12 )
1523- in_SST_ = np .all (components_proper >= 0.0 ,axis = - 1 ) \
1524- | np .all (components_improper >= 0.0 ,axis = - 1 )
1525- components = np .where ((in_SST_ & np .all (components_proper >= 0.0 ,axis = - 1 ))[...,np .newaxis ],
1525+ in_SST_ = np .logical_or ( np . all (components_proper >= 0.0 ,axis = - 1 ),
1526+ np .all (components_improper >= 0.0 ,axis = - 1 ) )
1527+ components = np .where ((np . logical_and ( in_SST_ , np .all (components_proper >= 0.0 ,axis = - 1 ) ))[...,np .newaxis ],
15261528 components_proper ,components_improper )
15271529 else :
15281530 components = np .around (np .einsum ('...ji,...i' ,
1529- np .broadcast_to (self .standard_triangle ['improper' ], vector_ .shape + (3 ,)),
1531+ np .broadcast_to (self .standard_triangle ['improper' ], vector_ .shape + (3 ,)),
15301532 np .block ([vector_ [...,:2 ],np .abs (vector_ [...,2 :3 ])])), 12 )
15311533
15321534 in_SST_ = np .all (components >= 0.0 ,axis = - 1 )
0 commit comments