Skip to content

Commit

Permalink
Merge pull request #26558 from xzdlj/prevent-extra-dot
Browse files Browse the repository at this point in the history
  • Loading branch information
sylee957 committed May 5, 2024
2 parents a4e651a + 28ba412 commit 0859517
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -1645,6 +1645,7 @@ vishal <vishal.panjwani15@gmail.com>
w495 <w495@yandex-team.ru>
wookie184 <wookie1840@gmail.com>
wuyudi <wuyudi119@163.com>
xzdlj <xzdlj@outlook.com>
ylemkimon <ylemkimon@naver.com> <mail@ylem.kim>
znxftw <vishnu2101@gmail.com>
zsc347 <zsc347@gmail.com>
Expand Down
4 changes: 2 additions & 2 deletions sympy/printing/latex.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@

_between_two_numbers_p = (
re.compile(r'[0-9][} ]*$'), # search
re.compile(r'[0-9]'), # match
re.compile(r'(\d|\\frac{\d+}{\d+})'), # match
)


Expand Down Expand Up @@ -548,7 +548,7 @@ def convert_args(args) -> str:
term_tex = r"\left(%s\right)" % term_tex

if _between_two_numbers_p[0].search(last_term_tex) and \
_between_two_numbers_p[1].match(str(term)):
_between_two_numbers_p[1].match(term_tex):
# between two numbers
_tex += numbersep
elif _tex:
Expand Down
3 changes: 3 additions & 0 deletions sympy/printing/tests/test_latex.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ def test_latex_basic():
assert latex(Mul(S.Half, -5, S.Half, evaluate=False)) == r"\frac{1}{2} \left(-5\right) \frac{1}{2}"
assert latex(Mul(5, I, 5, evaluate=False)) == r"5 i 5"
assert latex(Mul(5, I, -5, evaluate=False)) == r"5 i \left(-5\right)"
assert latex(Mul(Pow(x, 2), S.Half*x + 1)) == r"x^{2} \left(\frac{x}{2} + 1\right)"
assert latex(Mul(Pow(x, 3), Rational(2, 3)*x + 1)) == r"x^{3} \left(\frac{2 x}{3} + 1\right)"
assert latex(Mul(Pow(x, 11), 2*x + 1)) == r"x^{11} \left(2 x + 1\right)"

assert latex(Mul(0, 1, evaluate=False)) == r'0 \cdot 1'
assert latex(Mul(1, 0, evaluate=False)) == r'1 \cdot 0'
Expand Down

0 comments on commit 0859517

Please sign in to comment.