pg_utils.sympy_supp.simplify.recursive_collect
- pg_utils.sympy_supp.simplify.recursive_collect(expr: Expr, syms: List[Union[Symbol, List[Symbol]]], evaluate: bool = True) Union[dict, Expr] [source]
Recursively collect an expression by symbols
- Parameters:
expr (sympy.Expr) – expression to be processed
syms (List[Union[sympy.Symbol, List[sympy.Symbol]]]) – sympy symbols, whose coefficients are to be collected
evaluate (bool) –
if True, the output will be an expression, grouped by collected terms; if False, the output will be a dict representing a tree with symbol-coeff key-value pairs. Output {
sym1: term1, sym2: term2, … symN: termN
} represents an expression sym1*term1 + sym2*term2 + … symN*termN Each term can also be a dict, leading to the tree structure
- Returns:
collected output