We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8fd1c62 commit da01cf8Copy full SHA for da01cf8
lib/matplotlib/mathtext.py
@@ -2894,10 +2894,10 @@ def operatorname(self, s, loc, toks):
2894
hlist_list.append(c)
2895
next_char_loc = loc + len(toks[0]) + 1
2896
if isinstance(toks[0], ParseResults):
2897
- next_char_loc += 14 # Skip `operatorname{}`
+ next_char_loc += len('operatorname{}')
2898
next_char = next((c for c in s[next_char_loc:] if c != ' '), '')
2899
delimiters = self._left_delim | self._ambi_delim | self._right_delim
2900
- delimiters |= set(r"^_".split())
+ delimiters |= {'^', '_'}
2901
if (next_char not in delimiters and
2902
toks[0] not in self._overunder_functions):
2903
# Add thin space except when followed by parenthesis, bracket, etc.
lib/matplotlib/tests/test_mathtext.py
@@ -297,12 +297,17 @@ def test_operator_space(fig_test, fig_ref):
297
fig_test.text(0.1, 0.4, r"$\arcsin|6|$")
298
fig_test.text(0.1, 0.5, r"$\operatorname{op} 6$") # GitHub issue #553
299
fig_test.text(0.1, 0.6, r"$\operatorname{op}[6]$")
300
+ fig_test.text(0.1, 0.7, r"$\cos^2$")
301
+ fig_test.text(0.1, 0.8, r"$\log_2$")
302
+
303
fig_ref.text(0.1, 0.1, r"$\mathrm{log\,}6$")
304
fig_ref.text(0.1, 0.2, r"$\mathrm{log}(6)$")
305
fig_ref.text(0.1, 0.3, r"$\mathrm{arcsin\,}6$")
306
fig_ref.text(0.1, 0.4, r"$\mathrm{arcsin}|6|$")
307
fig_ref.text(0.1, 0.5, r"$\mathrm{op\,}6$")
308
fig_ref.text(0.1, 0.6, r"$\mathrm{op}[6]$")
309
+ fig_ref.text(0.1, 0.7, r"$\mathrm{cos}^2$")
310
+ fig_ref.text(0.1, 0.8, r"$\mathrm{log}_2$")
311
312
313
def test_mathtext_fallback_valid():
0 commit comments