The culprit here is fraction() from the simplify module, which expands the 
Mul() expression, ignoring the evaluate=False parameter. There is a simple 
fix, which is to use the original expression rather than the (modified) 
numerator. One could ask whether fraction() should respect the 
evaluate=False parameter or not. It is part of the "simplify" module after 
all. Then again, it is quite possible to apply fraction to unevaluated Mul 
object in a way that maintains the unevaluated property.

https://github.com/sympy/sympy/pull/2617

On Tuesday, November 19, 2013 10:26:59 PM UTC-5, Aaron Meurer wrote:
>
> Yes, unfortunately, unevaluated expressions tend to be "unstable". 
> Sometimes things will do what would normally be an innocuous 
> transformation that ends up evaluating it. These bugs have been mostly 
> fixed for the pretty printer, but I guess they are still there for the 
> latex printer. 
>
> Aaron Meurer 
>
> On Mon, Nov 18, 2013 at 4:30 AM,  <[email protected] <javascript:>> 
> wrote: 
> > Hi, 
> > 
> > I work with unevaluated Adds and Muls and today found this: 
> > 
> >>>> from sympy import latex, Mul, Symbol 
> >>>> x = Symbol('x') 
> >>>> e = Mul(-2, x + 1, evaluate=False) 
> >>>> print e 
> > -2*(x + 1) 
> >>>> print latex(e) 
> > - 2 x + 2 
> > 
> > The first print is correct but the second one is not. It's not about 
> simply 
> > dropping parentheses when they are needed. In that case the second print 
> > would read - 2 x + 1 so some computation took place. 
> > 
> > Regards 
> > -- 
> > Greg 
> > 
> > -- 
> > 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] <javascript:>. 
> > To post to this group, send email to [email protected]<javascript:>. 
>
> > Visit this group at http://groups.google.com/group/sympy. 
> > For more options, visit https://groups.google.com/groups/opt_out. 
>

-- 
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.

Reply via email to