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

Method parse

lib/matplotlib/_mathtext.py:2293–2312  ·  view source on GitHub ↗

Parse expression *s* using the given *fonts_object* for output, at the given *fontsize* and *dpi*. Returns the parse tree of `Node` instances.

(self, s: str, fonts_object: Fonts, fontsize: float, dpi: float)

Source from the content-addressed store, hash-verified

2291 self._needs_space_after_subsuper = False
2292
2293 def parse(self, s: str, fonts_object: Fonts, fontsize: float, dpi: float) -> Hlist:
2294 """
2295 Parse expression *s* using the given *fonts_object* for
2296 output, at the given *fontsize* and *dpi*.
2297
2298 Returns the parse tree of `Node` instances.
2299 """
2300 self._state_stack = [
2301 ParserState(fonts_object, 'default', 'rm', fontsize, dpi)]
2302 self._em_width_cache: dict[tuple[str, float, float], float] = {}
2303 try:
2304 result = self._expression.parse_string(s)
2305 except ParseBaseException as err:
2306 raise ValueError("\n" + err.explain(0)) from None
2307 self._state_stack = []
2308 self._needs_space_after_subsuper = False
2309 # prevent operator spacing from leaking into a new expression
2310 self._em_width_cache = {}
2311 ParserElement.reset_cache()
2312 return T.cast(Hlist, result[0]) # Known return type from main.
2313
2314 def get_state(self) -> ParserState:
2315 """Get the current `State` of the parser."""

Callers 15

get_ast_treeFunction · 0.45
check_fileFunction · 0.45
stubtest.pyFile · 0.45
_str_is_convertibleMethod · 0.45
datestr2numFunction · 0.45
get_glyphs_mathtextMethod · 0.45
_parse_cycler_stringFunction · 0.45
_draw_mathtextMethod · 0.45
draw_mathtextMethod · 0.45

Calls 1

ParserStateClass · 0.85

Tested by 4

test_stem_datesFunction · 0.36
test_box_reprFunction · 0.36