gEconpy.utilities.substitute_repeatedly#

gEconpy.utilities.substitute_repeatedly(expr, sub_dict, max_subs=10)#

Repeatedly call expr = expr.sub(sub_dict).

Used when substitutions in sub_dict themselves require substitution.

Parameters:
expr: sp.Expr

Expression to substitute into

sub_dict: dict of sp.Expr, sp.Expr

Dictionary of substitutions

max_subs: int

Maximum number of substitutions to make. If the number of substitutions exceeds this number, the function will return the expression as is.

Returns:
substituted_expr: sp.Expr

The expression with all substitutions made.