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

Function get_unicode_index

lib/matplotlib/_mathtext.py:52–71  ·  view source on GitHub ↗

r""" Return the integer index (from the Unicode table) of *symbol*. Parameters ---------- symbol : str A single (Unicode) character, a TeX command (e.g. r'\pi') or a Type1 symbol name (e.g. 'phi').

(symbol: str)

Source from the content-addressed store, hash-verified

50
51
52def get_unicode_index(symbol: str) -> CharacterCodeType: # Publicly exported.
53 r"""
54 Return the integer index (from the Unicode table) of *symbol*.
55
56 Parameters
57 ----------
58 symbol : str
59 A single (Unicode) character, a TeX command (e.g. r'\pi') or a Type1
60 symbol name (e.g. 'phi').
61 """
62 try: # This will succeed if symbol is a single Unicode char
63 return ord(symbol)
64 except TypeError:
65 pass
66 try: # Is symbol a TeX symbol (i.e. \alpha)
67 return tex2uni[symbol.strip("\\")]
68 except KeyError as err:
69 raise ValueError(
70 f"{symbol!r} is not a valid Unicode character or TeX/Type1 symbol"
71 ) from err
72
73
74class VectorParse(NamedTuple):

Callers 3

_get_glyphMethod · 0.85
_get_glyphMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…