evaluate=False thing is evil (at least in the current form). On
hold branch in my github repo:
http://github.com/mattpap/sympy-polys/commits/hold
I implemented (almost) unevaluated expressions from scratch, e.g:
In [1]: hold('1 + 1 + 1*sin(x + x) + 1*2*3')
Out[1]: 1 + 1 + 1⋅sin(x + x) + 1⋅2⋅3
In [2]: type(_)
Out[2]: <class 'sympy.core.holdclasses.HoldAdd'>
In [3]: _1.unhold()
Out[3]: 8 + sin(2⋅x)
In [4]: _1.unhold(Add)
Out[4]: 2 + 1⋅sin(2⋅x) + 1⋅2⋅3
In [5]: _1.unhold(Mul)
Out[5]: 1 + 1 + sin(x + x) + 6
In [6]: _1.unhold_first()
Out[6]: 2 + 1⋅sin(x + x) + 1⋅2⋅3
(almost means that HoldAdd and HoldMul are flattened automatically).
In hold() I use AST API so currently only >= Python 2.6 interpreters
are supported. Also there are some issues with negation and printing.
To make all this useful for step-by-step rewriting unhold_first()
will have to be improved to unhold not the very first object in the
expression tree (as it does currently), but unhold all Hold* instances
on the first level with Hold* in the expression tree.
> --
> 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.
>
--
Mateusz