Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions lib/matplotlib/_mathtext.py
Original file line number Diff line number Diff line change
Expand Up @@ -2426,10 +2426,15 @@ def font(self, toks: ParseResults) -> T.Any:
return []

def is_overunder(self, nucleus: Node) -> bool:
if isinstance(nucleus, Char):
return nucleus.c in self._overunder_symbols
elif isinstance(nucleus, Hlist) and hasattr(nucleus, 'function_name'):
return nucleus.function_name in self._overunder_functions
# OPTIMIZED: eliminate repeated hasattr on Hlist that are not Hlists,
# avoid double work for isinstance checks
nc = nucleus
if type(nc) is Char:
# type() check is faster and sufficient here, also avoids inheritance issues
return nc.c in self._overunder_symbols
if type(nc) is Hlist:
# Only check attribute if we're sure it's Hlist for maximal speed
return getattr(nc, 'function_name', None) in self._overunder_functions
return False

def is_dropsub(self, nucleus: Node) -> bool:
Expand Down