From 35caed305fce4f0c049a01370ad29d0a8ae8d0ca Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 15 Feb 2022 22:08:12 +0100 Subject: [PATCH] consistently define allclose for own type only --- python/damask/_orientation.py | 10 ++++------ python/damask/_rotation.py | 8 ++++---- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/python/damask/_orientation.py b/python/damask/_orientation.py index c3afd0bed..c7fbbbb85 100644 --- a/python/damask/_orientation.py +++ b/python/damask/_orientation.py @@ -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: diff --git a/python/damask/_rotation.py b/python/damask/_rotation.py index b11147482..9c6bde2dc 100644 --- a/python/damask/_rotation.py +++ b/python/damask/_rotation.py @@ -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]: