def tensorsymmetry(*args):
 from sympy.combinatorics import Permutation
 def tableau2bsgs(a):
  if (len(a) == 1):
   n = a[0]
   bsgs = get_symmetric_group_sgs(n, 1)
  elif all(((x == 1) for x in a)):
   n = len(a)
   bsgs = get_symmetric_group_sgs(n)
  elif (a == [2, 2]):
   bsgs = riemann_bsgs
  else:
   raise NotImplementedError
  return bsgs
 if (not args):
  return TensorSymmetry(Tuple(), Tuple(Permutation(1)))
 if ((len(args) == 2) and isinstance(args[1][0], Permutation)):
  return TensorSymmetry(args)
 (base, sgs) = tableau2bsgs(args[0])
 for a in args[1:]:
  (basex, sgsx) = tableau2bsgs(a)
  (base, sgs) = bsgs_direct_product(base, sgs, basex, sgsx)
 return TensorSymmetry(Tuple(base, sgs))

def tensorsymmetry ( * args ) : from sympy . combinatorics import Permutation def tableau2bsgs ( a ) : if ( len ( a ) == 1 ) : n = a [ 0 ] bsgs = get_symmetric_group_sgs ( n , 1 ) elif all ( ( ( x == 1 ) for x in a ) ) : n = len ( a ) bsgs = get_symmetric_group_sgs ( n ) elif ( a == [ 2 , 2 ] ) : bsgs = riemann_bsgs else : raise NotImplementedError return bsgs if ( not args ) : return TensorSymmetry ( Tuple ( ) , Tuple ( Permutation ( 1 ) ) ) if ( ( len ( args ) == 2 ) and isinstance ( args [ 1 ] [ 0 ] , Permutation ) ) : return TensorSymmetry ( args ) ( base , sgs ) = tableau2bsgs ( args [ 0 ] ) for a in args [ 1 : ] : ( basex , sgsx ) = tableau2bsgs ( a ) ( base , sgs ) = bsgs_direct_product ( base , sgs , basex , sgsx ) return TensorSymmetry ( Tuple ( base , sgs ) )
return a tensorsymmetry object .