Skip to content

Commit 1d71821

Browse files
committed
Support non-integer bases in mathtext sqrt
1 parent 79ae33a commit 1d71821

17 files changed

+1067
-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

Binary file not shown.
1.67 KB
Loading
Lines changed: 266 additions & 0 deletions
Loading
Binary file not shown.
1.86 KB
Loading

0 commit comments

Comments
 (0)