CARVIEW |
Navigation Menu
-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Corrected the output of latex method in latex.py to return valid latex command #15151
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
Conversation
…x commands. Example:- ln[1]:-from sympy import* ln[2]:-from sympy import init_printing;init_printing() ln[3]:-i=symbols('i') ln[4]:-print(latex(Indexed('x1',i)) Before Correction in code. Output:-x_{1}_{i} which was not a valid latex command. After correction in code. Output:- {x_{1}}_{i} which is valid latex command.
âś… Hi, I am the SymPy bot (v129). I'm here to help you write a release notes entry. Please read the guide on how to write release notes. Your release notes are in good order. Here is what the release notes will look like:
This will be added to https://github.com/sympy/sympy/wiki/Release-Notes-for-1.2.1. Note: This comment will be updated with the latest check if you edit the pull request. You need to reload the page to see it. Click here to see the pull request description that was parsed.
Update The release notes on the wiki have been updated. |
sympy/printing/tests/test_latex.py
Outdated
or symbol_latex.split() == indexed_latex.split()[::-1] | ||
# \\overline{{\\Psi}_{0}} {\\Psi}_{0} vs. \\Psi_{0} \\overline{\\Psi_{0}} | ||
assert symbol_latex=='\\Psi_{0} \\overline{\\Psi_{0}}' \ | ||
or indexed_latex=='\\overline{{\\Psi}_{0}} {\\Psi}_{0}' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be another assert (no or
).
sympy/printing/latex.py
Outdated
tex = self._print(expr.base)+'_{%s}' % ','.join( | ||
tex_base = self._print(expr.base) | ||
tex_base = '{'+tex_base+'}' | ||
tex = tex_base+'_{%s}' % ','.join( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Braces could be added on this line. No need for the one above.
sympy/printing/tests/test_latex.py
Outdated
@@ -524,7 +524,7 @@ def test_latex_indexed(): | |||
indexed_latex = latex(Psi_indexed[0] * conjugate(Psi_indexed[0])) | |||
# \\overline{{\\Psi}_{0}} {\\Psi}_{0} vs. \\Psi_{0} \\overline{\\Psi_{0}} | |||
assert symbol_latex=='\\Psi_{0} \\overline{\\Psi_{0}}' \ | |||
or indexed_latex=='\\overline{{\\Psi}_{0}} {\\Psi}_{0}' | |||
and indexed_latex=='\\overline{{\\Psi}_{0}} {\\Psi}_{0}' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not be a continuation line with and
but assert indexed_latex == ...
. The results are now different and each one should have its own test line.
sympy/printing/tests/test_latex.py
Outdated
or symbol_latex.split() == indexed_latex.split()[::-1] | ||
# \\overline{{\\Psi}_{0}} {\\Psi}_{0} vs. \\Psi_{0} \\overline{\\Psi_{0}} | ||
assert symbol_latex=='\\Psi_{0} \\overline{\\Psi_{0}}' | ||
assert indexed_latex=='\\overline{{\\Psi}_{0}} {\\Psi}_{0}' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SymPy uses spaces around ==
.
Also, it would be good to have meaningful commit messages.
|
Thank You @jksuom for pointing out my mistakes and helping me to fix it.I have made the necessary changes as advised by you and other contributors.Is the description of pull request fine now or should I also add the expected output of @majidaldo inside the description ? I am new to open source contributions and I am trying to contribute to organisation as much I can. |
Please add a test for |
sympy/printing/tests/test_latex.py
Outdated
@@ -1,6 +1,6 @@ | |||
from sympy import ( | |||
Add, Abs, Chi, Ci, CosineTransform, Dict, Ei, Eq, FallingFactorial, | |||
FiniteSet, Float, FourierTransform, Function, IndexedBase, Integral, | |||
FiniteSet, Float, FourierTransform, Function,Indexed, IndexedBase, Integral, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a space after comma.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jksuom Sure sir I have updated the code as asked by you.
This looks good. Thank you for your contribution. |
References to other Issues or PRs
Fixes #15059
Brief description of what is fixed or changed
The problem was that latex function wasn't printing valid Latex commands for Indexed results.In order to overcome this issue we altered the code to wrap the indexedbase in {} so that printer would print valid latex command.
Example:-
Other comments
Release Notes