>>> def fsub(e, a, f):
... args = a.args
... if not all(ai.is_Symbol for ai in args):
... raise ValueError('arguments of function must be symbols')
... return e.replace(a.func, lambda *args: f)
...
>>> Expr.fsub = fsub
>>> (1+f(x,y)).fsub(f(a,b), a+b)
a + b + 1
Maybe this detection could be part of replace: it could be type 2.1b
(expr -> expr NOT involving wild symbols).
--
You received this message because you are subscribed to the Google Groups
"sympy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sympy?hl=en.