MCPcopy Create free account
hub / github.com/ColdGrub1384/Pyto / parse

Method parse

site-packages/matplotlib/mathtext.py:3234–3271  ·  view source on GitHub ↗

Parse the given math expression *s* at the given *dpi*. If *prop* is provided, it is a :class:`~matplotlib.font_manager.FontProperties` object specifying the "default" font to use in the math expression, used for all non-math text. The results are c

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

Source from the content-addressed store, hash-verified

3232
3233 @functools.lru_cache(50)
3234 def parse(self, s, dpi = 72, prop = None):
3235 """
3236 Parse the given math expression *s* at the given *dpi*. If
3237 *prop* is provided, it is a
3238 :class:`~matplotlib.font_manager.FontProperties` object
3239 specifying the "default" font to use in the math expression,
3240 used for all non-math text.
3241
3242 The results are cached, so multiple calls to :meth:`parse`
3243 with the same expression should be fast.
3244 """
3245
3246 if prop is None:
3247 prop = FontProperties()
3248
3249 if self._output == 'ps' and rcParams['ps.useafm']:
3250 font_output = StandardPsFonts(prop)
3251 else:
3252 backend = self._backend_mapping[self._output]()
3253 fontset = rcParams['mathtext.fontset']
3254 fontset_class = self._font_type_mapping.get(fontset.lower())
3255 if fontset_class is not None:
3256 font_output = fontset_class(prop, backend)
3257 else:
3258 raise ValueError(
3259 "mathtext.fontset must be either 'cm', 'dejavuserif', "
3260 "'dejavusans', 'stix', 'stixsans', or 'custom'")
3261
3262 fontsize = prop.get_size_in_points()
3263
3264 # This is a class variable so we don't rebuild the parser
3265 # with each request.
3266 if self._parser is None:
3267 self.__class__._parser = Parser()
3268
3269 box = self._parser.parse(s, font_output, fontsize, dpi)
3270 font_output.set_canvas_size(box.width, box.height, box.depth)
3271 return font_output.get_results(box)
3272
3273 def to_mask(self, texstr, dpi=120, fontsize=14):
3274 """

Callers 4

to_maskMethod · 0.95
get_depthMethod · 0.95
math_to_imageFunction · 0.95
test_mathtext_exceptionsFunction · 0.95

Calls 9

get_size_in_pointsMethod · 0.95
FontPropertiesClass · 0.90
StandardPsFontsClass · 0.85
lowerMethod · 0.80
ParserClass · 0.70
getMethod · 0.45
parseMethod · 0.45
set_canvas_sizeMethod · 0.45
get_resultsMethod · 0.45

Tested by 1

test_mathtext_exceptionsFunction · 0.76