Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Support \sqrt[not-a-number]{...}.
  • Loading branch information
anntzer committed Jan 5, 2021
commit f9cea50f40fec605670c7cf8f4844696a5c1a711
7 changes: 4 additions & 3 deletions lib/matplotlib/_mathtext.py
Original file line number Diff line number Diff line change
Expand Up @@ -2158,7 +2158,8 @@ def __init__(self):

p.sqrt <<= Group(
Suppress(Literal(r"\sqrt"))
- ((Optional(p.lbracket + p.int_literal + p.rbracket, default=None)
- ((Group(Optional(
p.lbracket + OneOrMore(~p.rbracket + p.token) + p.rbracket))
+ p.required_group)
| Error("Expected \\sqrt{value}"))
)
Expand Down Expand Up @@ -2864,10 +2865,10 @@ def sqrt(self, s, loc, toks):

# Add the root and shift it upward so it is above the tick.
# The value of 0.6 is a hard-coded hack ;)
if root is None:
if not root:
root = Box(check.width * 0.5, 0., 0.)
else:
root = Hlist([Char(x, state) for x in root])
root = Hlist(root)
root.shrink()
root.shrink()

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions lib/matplotlib/tests/test_mathtext.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
r'$\dfrac{\$100.00}{y}$', # github issue #1888
]
svg_only_math_tests = [
r'$\sqrt[ab]{123}$', # github issue #8665
]

digits = "0123456789"
Expand Down