Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Printing of unevaluated Mul needs brackets #21814

Closed
oscarbenjamin opened this issue Aug 2, 2021 · 3 comments · Fixed by #22236
Closed

Printing of unevaluated Mul needs brackets #21814

oscarbenjamin opened this issue Aug 2, 2021 · 3 comments · Fixed by #22236

Comments

@oscarbenjamin
Copy link
Contributor

The second version here should use brackets or something:

In [16]: Mul(Rational(1, 2), x + y, evaluate=False)
Out[16]: 
x + y
─────
  2  

In [17]: Mul(x + y, Rational(1, 2), evaluate=False)
Out[17]: x + y1/2
@eric-wieser
Copy link
Member

eric-wieser commented Oct 8, 2021

I can't reproduce this on e359645 (master as of writing):

In [1]: from sympy import *

In [2]: x, y = symbols('x y', commutative=False)

In [3]: pretty_print(Mul(Rational(1, 2), x + y, evaluate=False))
x + y
─────
  2

In [4]: pretty_print(Mul(x + y, Rational(1, 2), evaluate=False))
x + y
─────
  2

@oscarbenjamin
Copy link
Contributor Author

I think your master branch is out of date.

@eric-wieser
Copy link
Member

Ah, in that case my PR fixes this. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment