This is awesome!!! Your simple fix with overriding flatten() works perfectly. My last question is -- how do you do the same thing with Pow? It is subclassed differently to Add, Mul (which both subclass "AssocOp"). I have taken a look at the source code (go me!!!) - it seems that in this case, because Pow is defined like this:
"def __new__(cls, b, e, evaluate=True): b = _sympify(b) e = _sympify(e) if evaluate: if e is S.Zero: return S.One elif e is S.One: return b else: obj = b._eval_power(e) if obj is not None: return obj obj = Expr.__new__(cls, b, e) obj.is_commutative = (b. is_commutative and e.is_commutative) return obj" So it seems a change to __new__ is necessary, right? It looks like evaluate=False is not even supported for Pow - am I right? (just a noob asking questions) Thanks!! -- You received this message because you are subscribed to the Google Groups "sympy" 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. For more options, visit https://groups.google.com/groups/opt_out.
