From 3d6eb76da3992d64a37edb170e77beb7efb6c696 Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Thu, 11 Apr 2019 19:07:41 -0400 Subject: [PATCH] equivalentOrientations accepts scalar argument to directly return single rotation object (not single element list) --- python/damask/orientation.py | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/python/damask/orientation.py b/python/damask/orientation.py index f4df909c6..227f02cda 100644 --- a/python/damask/orientation.py +++ b/python/damask/orientation.py @@ -510,7 +510,7 @@ class Symmetry: otherOrder = Symmetry.lattices.index(other.lattice) return (myOrder > otherOrder) - (myOrder < otherOrder) - def symmetryOperations(self,who=[]): + def symmetryOperations(self,members=[]): """List of symmetry operations as quaternions.""" if self.lattice == 'cubic': symQuats = [ @@ -577,8 +577,14 @@ class Symmetry: [ 1.0,0.0,0.0,0.0 ], ] - return list(map(Rotation, - np.array(symQuats)[np.atleast_1d(np.array(who)) if who != [] else range(len(symQuats))])) + symOps = list(map(Rotation, + np.array(symQuats)[np.atleast_1d(members) if members != [] else range(len(symQuats))])) + try: + iter(members) # asking for (even empty) list of members? + except TypeError: + return symOps[0] # no, return rotation object + else: + return symOps # yes, return list of rotations def inFZ(self,R): @@ -1096,10 +1102,15 @@ class Orientation: def inFZ(self): return self.lattice.symmetry.inFZ(self.rotation.asRodrigues()) - def equivalentOrientations(self, who=[]): + def equivalentOrientations(self,members=[]): """List of orientations which are symmetrically equivalent""" - return [self.__class__(q*self.rotation,self.lattice) \ - for q in self.lattice.symmetry.symmetryOperations(who)] + try: + iter(members) # asking for (even empty) list of members? + except TypeError: + return self.__class__(self.lattice.symmetry.symmetryOperations(members)*self.rotation,self.lattice) # no, return rotation object + else: + return [self.__class__(q*self.rotation,self.lattice) \ + for q in self.lattice.symmetry.symmetryOperations(members)] # yes, return list of rotations def relatedOrientations(self,model): """List of orientations related by the given orientation relationship"""