From ebdb65d31ff6bbe9327556c7f3bbaf9581d20983 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sat, 20 Jun 2020 16:35:22 +0200 Subject: [PATCH] standard broadcast_to behavior --- python/damask/_rotation.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/python/damask/_rotation.py b/python/damask/_rotation.py index 9a0266871..694384de2 100644 --- a/python/damask/_rotation.py +++ b/python/damask/_rotation.py @@ -156,18 +156,18 @@ class Rotation: Rotation to which the misorientation is computed. """ - return other@self.inversed() + return other*self.inversed() def broadcast_to(self,shape): - if isinstance(shape,int): - shape = (shape,) - N = np.prod(shape)//np.prod(self.shape,dtype=int) - - q = np.block([np.repeat(self.quaternion[...,0:1],N).reshape(shape+(1,)), - np.repeat(self.quaternion[...,1:2],N).reshape(shape+(1,)), - np.repeat(self.quaternion[...,2:3],N).reshape(shape+(1,)), - np.repeat(self.quaternion[...,3:4],N).reshape(shape+(1,))]) + if isinstance(shape,int): shape = (shape,) + if self.shape == (): + q = np.broadcast_to(self.quaternion,shape+(4,)) + else: + q = np.block([np.broadcast_to(self.quaternion[...,0:1],shape).reshape(shape+(1,)), + np.broadcast_to(self.quaternion[...,1:2],shape).reshape(shape+(1,)), + np.broadcast_to(self.quaternion[...,2:3],shape).reshape(shape+(1,)), + np.broadcast_to(self.quaternion[...,3:4],shape).reshape(shape+(1,))]) return self.__class__(q)