Comment #6 on issue 2022 by smichr: inconsistent behaviour of subs when using non-commutative symbols
http://code.google.com/p/sympy/issues/detail?id=2022

OK, there is a beta commit available for testing on my t2 branch at github/smichr. extrat_multiplicatively and Mul.subs are now more nc compliant. I still have to run the full test suite to see the full impact, but all the above now work:

a,b,c=symbols('abc',commutative=False)
(a*a*a+a*b*a).subs(a*a*a,c)
c + a*b*a
(a*(a+b)*a).subs(a*a*a,c)
a*(a + b)*a
a,b,c=symbols('abc',commutative=True)
var('A', commutative=0)
A
(a*b*A).subs(a*b,c)
c*A

With these changes, too, subs is going to behave (IMHO) in a more logical manner since it bases its substitution on whether items can be extrated additively or multiplicatively..."while maintaining the original structure." So [eventually] (x**3).subs(x**2, y) won't become y**(3/2) because that changes the structure. And right now, (1+x).subs(2+x,y) won't become -1 + y because that changes the structure; (3+x).subs(2+x,y) will become 1+y, though.

Anyway...it's open for testing.

--
You received this message because you are subscribed to the Google Groups 
"sympy-issues" 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-issues?hl=en.

Reply via email to