From 5d7f9305920c1e76b59986ceb7eab8c23a1c9d8a Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Mon, 17 Dec 2018 20:04:16 +0100 Subject: [PATCH] math.isclose does not exist for older versions np.isclose does the same --- lib/damask/orientation.py | 14 +++++++------- processing/pre/geom_rotate.py | 2 -- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/lib/damask/orientation.py b/lib/damask/orientation.py index fbf4dd8a8..946c97d1e 100644 --- a/lib/damask/orientation.py +++ b/lib/damask/orientation.py @@ -161,8 +161,8 @@ class Quaternion: def __eq__(self,other): """Equal (sufficiently close) to each other""" - return math.isclose(( self-other).magnitude(),0.0) \ - or math.isclose((-self-other).magnitude(),0.0) + return np.isclose(( self-other).magnitude(),0.0) \ + or np.isclose((-self-other).magnitude(),0.0) def __ne__(self,other): """Not equal (sufficiently close) to each other""" @@ -230,10 +230,10 @@ class Quaternion: angle = 2.0*math.acos(self.q) - if math.isclose(angle,0.0): + if np.isclose(angle,0.0): angle = 0.0 axis = np.array([0.0,0.0,1.0]) - elif math.isclose(self.q,0.0): + elif np.isclose(self.q,0.0): angle = math.pi axis = self.p else: @@ -244,7 +244,7 @@ class Quaternion: return np.hstack((angle,axis)) if flat else (angle,axis) def asRodrigues(self): - return np.inf*np.ones(3) if math.isclose(self.q,0.0) else self.p/self.q + return np.inf*np.ones(3) if np.isclose(self.q,0.0) else self.p/self.q def asEulers(self, degrees = False): @@ -255,9 +255,9 @@ class Quaternion: q12 = self.p[0]**2 + self.p[1]**2 chi = np.sqrt(q03*q12) - if math.isclose(chi,0.0) and math.isclose(q12,0.0): + if np.isclose(chi,0.0) and np.isclose(q12,0.0): eulers = np.array([math.atan2(-2*P*self.q*self.p[2],self.q**2-self.p[2]**2),0,0]) - elif math.isclose(chi,0.0) and math.isclose(q03,0.0): + elif np.isclose(chi,0.0) and np.isclose(q03,0.0): eulers = np.array([math.atan2( 2 *self.p[0]*self.p[1],self.p[0]**2-self.p[1]**2),np.pi,0]) else: eulers = np.array([math.atan2((self.p[0]*self.p[2]-P*self.q*self.p[1])/chi,(-P*self.q*self.p[0]-self.p[1]*self.p[2])/chi), diff --git a/processing/pre/geom_rotate.py b/processing/pre/geom_rotate.py index 939f2b943..eb70f7137 100755 --- a/processing/pre/geom_rotate.py +++ b/processing/pre/geom_rotate.py @@ -60,8 +60,6 @@ eulers = np.array(damask.orientation.Orientation( degrees = options.degrees, ).asEulers(degrees=True)) -damask.util.croak('{} {} {}'.format(*eulers)) - # --- loop over input files ------------------------------------------------------------------------- if filenames == []: filenames = [None]