Comment #1 on issue 3681 by [email protected]: bottom_up runs into problem
with Pow
http://code.google.com/p/sympy/issues/detail?id=3681
Traveral strategies use Basic.__new__ to construct the tree without calling
object constructors. Many Exprs require construction to function
properly. Mainly this is because they set the is_commutative flag as a
field rather than as an arg. As a result, the traversal strategies damage
the tree.
This damage can be fixed with the rebuild rule.
In [1]: def f(x):
...: if x.is_Symbol:
...: return x + 1
...: return x
...:
In [2]: from sympy.strategies.traverse import *
In [3]: bottom_up(f)(x**2)
AttributeError: is_commutative
In [4]: from sympy.strategies import rebuild
In [5]: rebuild(bottom_up(f)(x**2))
Out[5]:
2
(x + 1)
--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings
--
You received this message because you are subscribed to the Google Groups
"sympy-issues" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sympy-issues?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.