MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / operatorname

Method operatorname

lib/matplotlib/_mathtext.py:2508–2536  ·  view source on GitHub ↗
(self, s: str, loc: int, toks: ParseResults)

Source from the content-addressed store, hash-verified

2506 return hlist
2507
2508 def operatorname(self, s: str, loc: int, toks: ParseResults) -> T.Any:
2509 self.push_state()
2510 state = self.get_state()
2511 state.font = 'rm'
2512 hlist_list: list[Node] = []
2513 # Change the font of Chars, but leave Kerns alone
2514 name = toks["name"]
2515 for c in name:
2516 if isinstance(c, Char):
2517 c.font = 'rm'
2518 c._update_metrics()
2519 hlist_list.append(c)
2520 elif isinstance(c, str):
2521 hlist_list.append(Char(c, state))
2522 else:
2523 hlist_list.append(c)
2524 next_char_loc = loc + len(name) + 1
2525 if isinstance(name, ParseResults):
2526 next_char_loc += len('operatorname{}')
2527 next_char = next((c for c in s[next_char_loc:] if c != ' '), '')
2528 delimiters = self._delims | {'^', '_'}
2529 if next_char not in delimiters:
2530 # Add thin space except when followed by parenthesis, bracket, etc.
2531 hlist_list += [self._make_space(self._space_widths[r'\,'])]
2532 self.pop_state()
2533 # If followed by a sub/superscript, set flag to true to tell subsuper
2534 # to add space after this operator.
2535 self._needs_space_after_subsuper = next_char in {'^', '_'}
2536 return Hlist(hlist_list)
2537
2538 def start_group(self, toks: ParseResults) -> T.Any:
2539 self.push_state()

Callers 1

functionMethod · 0.95

Calls 7

push_stateMethod · 0.95
get_stateMethod · 0.95
_make_spaceMethod · 0.95
pop_stateMethod · 0.95
CharClass · 0.85
HlistClass · 0.85
_update_metricsMethod · 0.45

Tested by

no test coverage detected