(expr, opt, method)
return coeff, factors
Helper function for :func:`_symbolic_factor`.
Helper function for :func:`_symbolic_factor`.
Helper function for : func : _symbolic_factor .
def _symbolic_factor_list(expr, opt, method):
    """Helper function for :func:`_symbolic_factor`. """
    coeff, factors = S.One, []

    for arg in Mul.make_args(expr):
        if arg.is_Number:
            coeff *= arg
            continue
        elif arg.is_Pow:
            base, exp = arg.args
            if base.is_Number:
                factors.append((base, exp))
                continue
        else:
            base, exp = arg, S.One

        try:
            poly, _ = _poly_from_expr(base, opt)
        except PolificationFailed as exc:
            factors.append((exc.expr, exp))
        else:
            func = getattr(poly, method + '_list')

            _coeff, _factors = func()
            if _coeff is not S.One:
                if exp.is_Integer:
                    coeff *= _coeff**exp
                elif _coeff.is_positive:
                    factors.append((_coeff, exp))
                else:
                    _factors.append((_coeff, S.One))

            if exp is S.One:
                factors.extend(_factors)
            elif exp.is_integer or len(_factors) == 1:
                factors.extend([(f, k*exp) for f, k in _factors])
            else:
                other = []

                for f, k in _factors:
                    if f.as_expr().is_positive:
                        factors.append((f, k*exp))
                    else:
                        other.append((f, k))

                if len(other) == 1:
                    f, k = other[0]
                    factors.append((f, k*exp))
                else:
                    factors.append((_factors_product(other), exp))

    return coeff, factors
def _symbolic_factor_list ( expr , opt , method ) : coeff , factors = S . One , [ ] for arg in Mul . make_args ( expr ) : if arg . is_Number : coeff *= arg continue elif arg . is_Pow : base , exp = arg . args if base . is_Number : factors . append ( ( base , exp ) ) continue else : base , exp = arg , S . One try : poly , _ = _poly_from_expr ( base , opt ) except PolificationFailed as exc : factors . append ( ( exc . expr , exp ) ) else : func = getattr ( poly , method + '_list' ) _coeff , _factors = func ( ) if _coeff is not S . One : if exp . is_Integer : coeff *= _coeff ** exp elif _coeff . is_positive : factors . append ( ( _coeff , exp ) ) else : _factors . append ( ( _coeff , S . One ) ) if exp is S . One : factors . extend ( _factors ) elif exp . is_integer or len ( _factors ) == 1 : factors . extend ( [ ( f , k * exp ) for f , k in _factors ] ) else : other = [ ] for f , k in _factors : if f . as_expr ( ) . is_positive : factors . append ( ( f , k * exp ) ) else : other . append ( ( f , k ) ) if len ( other ) == 1 : f , k = other [ 0 ] factors . append ( ( f , k * exp ) ) else : factors . append ( ( _factors_product ( other ) , exp ) ) return coeff , factors