pystencils.sympyextensions.math.recursive_collect

pystencils.sympyextensions.math.recursive_collect#

pystencils.sympyextensions.math.recursive_collect(expr, symbols, order_by_occurences=False)#

Applies sympy.collect recursively for a list of symbols, collecting symbol 2 in the coefficients of symbol 1, and so on.

expr must be rewritable as a polynomial in the given symbols. It it is not, recursive_collect will fail quietly, returning the original expression.

Parameters:
  • expr – A sympy expression.

  • symbols – A sequence of symbols

  • order_by_occurences – If True, during recursive descent, always collect the symbol occuring most often in the expression.