Interestingly, with noevalMul: noevalMul(2, 3) >>> 2*3
noevalMul(-2, 3) >>> -6 occurs because of some combination of "as_coeff_Mul" and "_keep_coeff", and the SymPy printer calls the "_keep_coeff" owned by Mul, not noevalMul, so I'm not sure how to override this behaviour in noevalMul. On 12 October 2013 01:21, Ben Lucato <[email protected]> wrote: > 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!! > -- Ben Lucato ---------------------------------------------------------------------------------- Phone: +61 400 159 632 | Email: [email protected] -- 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.
