diff --git a/src/uproot/interpretation/objects.py b/src/uproot/interpretation/objects.py index 891d26735..0a01f30d9 100644 --- a/src/uproot/interpretation/objects.py +++ b/src/uproot/interpretation/objects.py @@ -596,15 +596,16 @@ class AsStridedObjects(uproot.interpretation.numerical.AsDtype): def __init__(self, model, members, original=None): all_headers_prepended = False - first_value_loc = 0 - while members[first_value_loc] == (None, None): - first_value_loc += 1 + + for first_value_loc in range(len(members)): + if members[first_value_loc] != (None, None): + break for i in range(first_value_loc, len(members)): member, value = members[i] if member is not None and not all_headers_prepended: all_headers_prepended = True - if member is None and all_headers_prepended: + if member is None and all_headers_prepended or len(members) == 1: all_headers_prepended = False del members[i] diff --git a/tests/test_0910-fix_906_members_non_numerical_branches.py b/tests/test_0910-fix_906_members_non_numerical_branches.py new file mode 100644 index 000000000..ed03c7de5 --- /dev/null +++ b/tests/test_0910-fix_906_members_non_numerical_branches.py @@ -0,0 +1,14 @@ +import uproot + +from skhep_testdata import data_path + + +def test_fix_906_members_non_numerical_branches(): + filename = data_path("uproot-issue-798.root") # PHYSLITE example file + f = uproot.open(filename) + tree = f["CollectionTree"] + + assert ( + str(tree["EventInfo"].interpretation) + == "AsStridedObjects(Model_xAOD_3a3a_EventInfo_5f_v1_v1)" + )