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)
| 50 | |
| 51 | |
| 52 | def 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 | |
| 74 | class VectorParse(NamedTuple): |
no outgoing calls
no test coverage detected
searching dependent graphs…