finesse.symbols.Symbol.substitute

Symbol.substitute(mapping)[source]

Uses a dictionary to substitute terms in this expression with another. This does not perform any evaluation of any terms, unlike eval(subs=…).

Parameters
mappingdict

Dictionary of substitutions/mappings to make. Keys can be the actual symbol or the name of the symbol in string form. Values must all be proper symbols.

Notes

The symbolic substitution implemented here is not recursive, consider:

>>> y = a + b
>>> y.subs({a:a+b, b:a}) # results in => a+b+a

Here b is not replaced in the substitutions. The only time this happens is if one mapping is purely numeric:

>>> y.subs({a:a+b, b:1}) # results in => a+2