@public
def factor(f, *gens, **args):
 f = sympify(f)
 if args.pop('deep', False):
  partials = {}
  muladd = f.atoms(Mul, Add)
  for p in muladd:
   fac = factor(p, *gens, **args)
   if ((fac.is_Mul or fac.is_Pow) and (fac != p)):
    partials[p] = fac
  return f.xreplace(partials)
 try:
  return _generic_factor(f, gens, args, method='factor')
 except PolynomialError as msg:
  if (not f.is_commutative):
   from sympy.core.exprtools import factor_nc
   return factor_nc(f)
  else:
   raise PolynomialError(msg)

@ public def factor ( f , * gens , ** args ) : f = sympify ( f ) if args . pop ( 'deep' , False ) : partials = { } muladd = f . atoms ( Mul , Add ) for p in muladd : fac = factor ( p , * gens , ** args ) if ( ( fac . is_Mul or fac . is_Pow ) and ( fac != p ) ) : partials [ p ] = fac return f . xreplace ( partials ) try : return _generic_factor ( f , gens , args , method = 'factor' ) except PolynomialError as msg : if ( not f . is_commutative ) : from sympy . core . exprtools import factor_nc return factor_nc ( f ) else : raise PolynomialError ( msg )
compute the factorization of expression .