debugger22/sympy — pull request #8 by smichr (2014-05-19 11:24:25+00:00)
Title: modify simultaneous subs to avoid dummy variables

While subs is smart enough not to put a Number or a product directly into
a dummy variable of something like Derivative, xreplace is not:

>>> from sympy import *;ok=var('x y z')
>>> Derivative(x,y).subs({x:2*z,y:2*z})
Subs(Derivative(2*z, y), (y,), (2*z,))
>>> Derivative(x,y).xreplace({x:2*z,y:2*z})
Traceback (most recent call last):
File "", line 1, in
File "sympy\core\basic.py", line 1176, in xreplace
return self.func(*args)
File "sympy\core\function.py", line 1030, in __new__
Can\'t differentiate wrt the variable: %s, %s''' % (v, count)))
ValueError:
Can't differentiate wrt the variable: 2*z, 1

So simultaneous subs (which uses xreplace) was modified to use
a product of dummies in the subs step that replaces all old patterns with
dummy variables so the xreplace step will not fail.