@cacheit
def _extract_delta(expr, index):
 if (not _has_simple_delta(expr, index)):
  return (None, expr)
 if isinstance(expr, KroneckerDelta):
  return (expr, S(1))
 if (not expr.is_Mul):
  raise ValueError('Incorrect expr')
 delta = None
 terms = []
 for arg in expr.args:
  if ((delta is None) and _is_simple_delta(arg, index)):
   delta = arg
  else:
   terms.append(arg)
 return (delta, expr.func(*terms))

@ cacheit def _extract_delta ( expr , index ) : if ( not _has_simple_delta ( expr , index ) ) : return ( None , expr ) if isinstance ( expr , KroneckerDelta ) : return ( expr , S ( 1 ) ) if ( not expr . is_Mul ) : raise ValueError ( 'Incorrect expr' ) delta = None terms = [ ] for arg in expr . args : if ( ( delta is None ) and _is_simple_delta ( arg , index ) ) : delta = arg else : terms . append ( arg ) return ( delta , expr . func ( * terms ) )
extract a simple kroneckerdelta from the expression .