Skip to content

Commit

Permalink
treat more cases for typename
Browse files Browse the repository at this point in the history
  • Loading branch information
nikoladze committed Nov 8, 2024
1 parent dfc4e99 commit f02b67e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
19 changes: 15 additions & 4 deletions src/uproot/interpretation/known_forth/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"""
from __future__ import annotations

import uproot
from uproot.interpretation.known_forth.atlas.element_link import VectorVectorElementLink

KNOWN_FORTH_DICT = {
Expand All @@ -20,10 +21,20 @@


def known_forth_of(model):
if not hasattr(model, "typename"):
return

typename = model.typename
"""
Args:
model: The :doc:`uproot.model.Model` to look up known forth for
Returns an object with attributes `forth_code` and `awkward_form` if a known
special case exists, else None
"""
try:
typename = model.typename
except AttributeError:
try:
typename = model.classname
except AttributeError:
typename = uproot.model.classname_decode(model.__name__)

if typename not in KNOWN_FORTH_DICT:
return
Expand Down
3 changes: 2 additions & 1 deletion src/uproot/interpretation/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ class AsObjects(uproot.interpretation.Interpretation):
replace this interpretation with a faster-to-read equivalent, but not all
data types can be simplified.
# TODO: known_forth can define forth code and forms for special cases that will be picked up here as well
:doc:`uproot.interpretation.known_forth` defines forth code and forms for
special cases that will be picked up here as well
"""

def __init__(self, model, branch=None):
Expand Down

0 comments on commit f02b67e

Please sign in to comment.