I found some more problems when using non-commutative symbols and subs
and I wonder if I should reopen issue 2022 or open a new issue?
In [1]: import sympy
In [2]: print sympy.__version__
0.6.7-git
In [3]: sympy.var('a b c')
Out[3]: (a, b, c)
In [4]: A=sympy.Symbol('A', commutative=False)
In [5]: B=sympy.Symbol('B', commutative=False)
In [6]: (a*A).subs(a*a*A,B)
Out[6]: a*B
In [7]: (A*A).subs(A*A*A,c)
Out[7]: c**(2/3)
In [8]: (A*A*A).subs(A*A,c)
Out[8]: c**(3/2)
In [6] and [7] no substitution should occur, in [8] c*A should be the result.
[7] and [8] are related to issue 2026, but it's different in that with
non-commutative symbols, it is simply wrong to do algebraic
substitution.
--
Julien
Aaron Meurer
> --
> You received this message because you are subscribed to the Google Groups "sympy" group.
> To post to this group, send email to sy...@googlegroups.com.
> To unsubscribe from this group, send email to sympy+un...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/sympy?hl=en.
>
Aaron Meurer
Before the changes of 2039 you would get:
h[2] >>> (a*A).subs(a*a*A,B)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "sympy\core\basic.py", line 705, in subs
return self._subs_old_new(old, new)
File "sympy\core\cache.py", line 85, in wrapper
func_cache_it_cache[k] = r = func(*args, **kw_args)
File "sympy\core\basic.py", line 714, in _subs_old_new
return self._eval_subs(old, new)
File "sympy\core\mul.py", line 897, in _eval_subs
comms_final.remove(ele)
ValueError: list.remove(x): x not in list
Now you get the wrong result. I'll look into this.
/c