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

Method parse

lib/matplotlib/mathtext.py:62–86  ·  view source on GitHub ↗

Parse the given math expression *s* at the given *dpi*. If *prop* is provided, it is a `.FontProperties` object specifying the "default" font to use in the math expression, used for all non-math text. The results are cached, so multiple calls to `parse` wit

(self, s, dpi=72, prop=None, *, antialiased=None)

Source from the content-addressed store, hash-verified

60 output=output.lower())
61
62 def parse(self, s, dpi=72, prop=None, *, antialiased=None):
63 """
64 Parse the given math expression *s* at the given *dpi*. If *prop* is
65 provided, it is a `.FontProperties` object specifying the "default"
66 font to use in the math expression, used for all non-math text.
67
68 The results are cached, so multiple calls to `parse`
69 with the same expression should be fast.
70
71 Depending on the *output* type, this returns either a `VectorParse` or
72 a `RasterParse`.
73 """
74 # lru_cache can't decorate parse() directly because prop is
75 # mutable, so we key the cache using an internal copy (see
76 # Text._get_text_metrics_with_cache for a similar case); likewise,
77 # we need to check the mutable state of the text.antialiased and
78 # text.hinting rcParams.
79 prop = prop.copy() if prop is not None else None
80 antialiased = mpl._val_or_rc(antialiased, 'text.antialiased')
81 from matplotlib.backends import backend_agg
82 load_glyph_flags = {
83 "vector": LoadFlags.NO_HINTING,
84 "raster": backend_agg.get_hinting_flag(),
85 }[self._output_type]
86 return self._parse_cached(s, dpi, prop, antialiased, load_glyph_flags)
87
88 @functools.lru_cache(50)
89 def _parse_cached(self, s, dpi, prop, antialiased, load_glyph_flags):

Callers 3

math_to_imageFunction · 0.95
test_mathtext_exceptionsFunction · 0.95
_parse_cachedMethod · 0.45

Calls 2

_parse_cachedMethod · 0.95
copyMethod · 0.45

Tested by 1

test_mathtext_exceptionsFunction · 0.76