Skip to content

Commit 7f7fad9

Browse files
committed
Support \sqrt[not-a-number]{...}.
1 parent d6687ce commit 7f7fad9

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

lib/matplotlib/_mathtext.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2158,7 +2158,8 @@ def __init__(self):
21582158

21592159
p.sqrt <<= Group(
21602160
Suppress(Literal(r"\sqrt"))
2161-
- ((Optional(p.lbracket + p.int_literal + p.rbracket, default=None)
2161+
- ((Group(Optional(
2162+
p.lbracket + OneOrMore(~p.rbracket + p.token) + p.rbracket))
21622163
+ p.required_group)
21632164
| Error("Expected \\sqrt{value}"))
21642165
)
@@ -2864,10 +2865,10 @@ def sqrt(self, s, loc, toks):
28642865

28652866
# Add the root and shift it upward so it is above the tick.
28662867
# The value of 0.6 is a hard-coded hack ;)
2867-
if root is None:
2868+
if not root:
28682869
root = Box(check.width * 0.5, 0., 0.)
28692870
else:
2870-
root = Hlist([Char(x, state) for x in root])
2871+
root = Hlist(root)
28712872
root.shrink()
28722873
root.shrink()
28732874

1.85 KB
Loading

lib/matplotlib/tests/test_mathtext.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@
114114
# default) and only png outputs, in order to minimize the size of baseline
115115
# images.
116116
lightweight_math_tests = [
117+
r'$\sqrt[ab]{123}$', # github issue #8665
117118
]
118119

119120
digits = "0123456789"

0 commit comments

Comments
 (0)