def _get_indices_Add(expr):
 inds = list(map(get_indices, expr.args))
 (inds, syms) = list(zip(*inds))
 non_scalars = [x for x in inds if (x != set())]
 if (not non_scalars):
  return (set(), {})
 if (not all([(x == non_scalars[0]) for x in non_scalars[1:]])):
  raise IndexConformanceException(('Indices are not consistent: %s' % expr))
 if (not reduce((lambda x, y: ((x != y) or y)), syms)):
  symmetries = syms[0]
 else:
  symmetries = {}
 return (non_scalars[0], symmetries)

def _get_indices_Add ( expr ) : inds = list ( map ( get_indices , expr . args ) ) ( inds , syms ) = list ( zip ( * inds ) ) non_scalars = [ x for x in inds if ( x != set ( ) ) ] if ( not non_scalars ) : return ( set ( ) , { } ) if ( not all ( [ ( x == non_scalars [ 0 ] ) for x in non_scalars [ 1 : ] ] ) ) : raise IndexConformanceException ( ( 'Indices are not consistent: %s' % expr ) ) if ( not reduce ( ( lambda x , y : ( ( x != y ) or y ) ) , syms ) ) : symmetries = syms [ 0 ] else : symmetries = { } return ( non_scalars [ 0 ] , symmetries )
determine outer indices of an add object .