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

Fix issue #10806 #10824

Merged
merged 5 commits into from Mar 31, 2016
Merged

Fix issue #10806 #10824

merged 5 commits into from Mar 31, 2016

Conversation

Upabjojr
Copy link
Contributor

@Upabjojr
Copy link
Contributor Author

Better try a different approach: Integral shall have the same precedence as Atom (as it currently is in master) except for the LaTeX printer, where it shall have the same precedence as Mul.

@Upabjojr
Copy link
Contributor Author

@gxyd what do you think?

@gxyd
Copy link
Contributor

gxyd commented Mar 26, 2016

One quick comment: issue with Limit is still there.

>>> print(latex(Limit(x, x, 1)**2))
\lim_{x \to 1^+} x^{2}

I will look into it.

@Upabjojr
Copy link
Contributor Author

One quick comment: issue with Limit is still there.

That's an easy fix. Other atomic expressions that have a multiplication-like precedence in LaTeX?

@Upabjojr
Copy link
Contributor Author

Also Derivative, Sum, Product are affected.

def parenthesize(self, item, level, strict=False):
# Integral has the precedence of Mul in LaTeX, the precedence of Atom
# for other printers:
from sympy import Integral, Sum, Product, Derivative
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here Limit can also be added.

@gxyd
Copy link
Contributor

gxyd commented Mar 31, 2016

I like the approach of the PR. Everything looks fine, except one issue i have. In "terminal"

>>> from sympy import *
>>> x, y, z = symbols('x y z')
>>> init_printing()
>>> Limit(Limit(x**2, x, y)**(S(5)/2), y, 2)
            5/2
           2   
 lim  lim x    
y─→2⁺x─→y⁺     

>>> Limit(Limit(x**2, x, y), y, 2)**(S(5)/2)
            5/2
           2   
 lim  lim x    
y─→2⁺x─→y⁺     

No brackets are put around Limit of x**2 (in first case), and no brackets around whole Limit object (in second case).
While this issue is not there in Jupyter notebook.

@gxyd
Copy link
Contributor

gxyd commented Mar 31, 2016

+1. Probably that is unrelated to the PR. Will merge in 12 hrs.

@Upabjojr
Copy link
Contributor Author

Everything looks fine, except one issue i have. In "terminal"

Maybe it's an issue in the unicode printer?

@Upabjojr
Copy link
Contributor Author

Sorry, in the pprint, not in the unicode printer.

@Upabjojr
Copy link
Contributor Author

@gxyd I have a fix for your issue. Will post a new PR as soon as this one is merged.

@gxyd
Copy link
Contributor

gxyd commented Mar 31, 2016

Sorry, in the pprint, not in the unicode printer.

Yes, that is a issue in pprint.

I have a fix for your issue. Will post a new PR as soon as this one is merged.

Okay, that will be good.

@Upabjojr
Copy link
Contributor Author

#10940

@gxyd
Copy link
Contributor

gxyd commented Mar 31, 2016

Thanks @Upabjojr merging this.
You may also like to express your views for the question, i asked on google groups.

@gxyd gxyd merged commit da8bb0d into sympy:master Mar 31, 2016
@Upabjojr Upabjojr deleted the integral_precedence branch April 20, 2019 08:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants