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
Incorrect printing of non-evaluated multiplication with negative number #16955
Comments
Some more observations:
so as you say, it is when the first argument is negative that it somehow messes up. |
And some more:
|
Parts of it come from this function: Lines 1746 to 1802 in 08644cb
especially the last line that just returns the product unless something else has triggered. The product is for coeff = 2 and factors = 5, as the following piece of code has removed the sign: Lines 270 to 275 in 08644cb
This is for |
I know this issue is over a year old, but I just wanted to update it. With Sympy 1.7.1 (and 1.8.dev), Also, |
First, a workaround: for every >>> from sympy import *
>>> srepr(Mul(-2, 5, evaluate=False), order = 'old')
'Mul(Integer(-2), Integer(5))'
>>> srepr(Mul(2, -5, evaluate=False), order = 'old')
'Mul(Integer(2), Integer(-5))'
>>> srepr(Mul(-2, -5, evaluate=False), order = 'old')
'Mul(Integer(-2), Integer(-5))' However, the reason this works is because it bypasses Lines 1297 to 1310 in 23d11f3
Not sure if this behavior is preferred, or if it should be changed to reflect what people will expect. |
This expression:
will be incorrectly represented by repr(), srepr() and latex() when
a
is a negative number (either integer or float).Examples:
Tested under SymPy 1.4 with Python 3.8.0a2.
The text was updated successfully, but these errors were encountered: