consistently define allclose for own type only

This commit is contained in:
Martin Diehl 2022-02-15 22:08:12 +01:00
parent b1922c9fc0
commit 35caed305f
2 changed files with 8 additions and 10 deletions

View File

@ -168,8 +168,8 @@ class Orientation(Rotation,Crystal):
return np.logical_not(self==other) if isinstance(other, Orientation) else NotImplemented
def isclose(self,
other: object,
def isclose(self: MyType,
other: MyType,
rtol: float = 1e-5,
atol: float = 1e-8,
equal_nan: bool = True) -> bool:
@ -193,8 +193,6 @@ class Orientation(Rotation,Crystal):
Mask indicating where corresponding orientations are close.
"""
if not isinstance(other, Orientation):
raise TypeError
matching_type = self.family == other.family and \
self.lattice == other.lattice and \
self.parameters == other.parameters
@ -202,8 +200,8 @@ class Orientation(Rotation,Crystal):
def allclose(self,
other: object,
def allclose(self: MyType,
other: MyType,
rtol: float = 1e-5,
atol: float = 1e-8,
equal_nan: bool = True) -> bool:

View File

@ -140,8 +140,8 @@ class Rotation:
"""
return np.logical_not(self==other) if isinstance(other, Rotation) else NotImplemented
def isclose(self,
other: 'Rotation',
def isclose(self: MyType,
other: MyType,
rtol: float = 1e-5,
atol: float = 1e-8,
equal_nan: bool = True) -> bool:
@ -171,8 +171,8 @@ class Rotation:
np.all(np.isclose(s,-1.0*o,rtol,atol,equal_nan),axis=-1))
def allclose(self,
other: 'Rotation',
def allclose(self: MyType,
other: MyType,
rtol: float = 1e-5,
atol: float = 1e-8,
equal_nan: bool = True) -> Union[np.bool_, bool]: