diff --git a/src/uproot/interpretation/identify.py b/src/uproot/interpretation/identify.py index 95e9bf5f9..814e49b87 100644 --- a/src/uproot/interpretation/identify.py +++ b/src/uproot/interpretation/identify.py @@ -480,15 +480,23 @@ def interpretation_of(branch, context, simplify=True): while isinstance(model_cls, uproot.containers.AsPointer): model_cls = model_cls.pointee - if branch._streamer_isTClonesArray: - if isinstance(branch.streamer, uproot.streamers.Model_TStreamerObject): + if dims != () or branch._streamer_isTClonesArray: + if ( + isinstance(branch.streamer, uproot.streamers.Model_TStreamerObject) + or not branch._streamer_isTClonesArray + ): model_cls = uproot.containers.AsArray(False, False, model_cls, dims) else: if hasattr(model_cls, "header"): model_cls._header = False model_cls = uproot.containers.AsArray(True, False, model_cls, dims) - out = uproot.interpretation.objects.AsObjects(model_cls, branch) + if dims != () and not branch._streamer_isTClonesArray: + out = uproot.interpretation.objects.AsObjects(model_cls, branch) + out._forth = False + else: + out = uproot.interpretation.objects.AsObjects(model_cls, branch) + if simplify: return out.simplify() else: diff --git a/tests/test_0911-fix_interp_array_non_numerical_objs_issue_880.py b/tests/test_0911-fix_interp_array_non_numerical_objs_issue_880.py new file mode 100644 index 000000000..a25581911 --- /dev/null +++ b/tests/test_0911-fix_interp_array_non_numerical_objs_issue_880.py @@ -0,0 +1,16 @@ +# BSD 3-Clause License; see https://github.com/scikit-hep/uproot5/blob/main/LICENSE + +import uproot +import skhep_testdata + + +def test_fix_interpretation_for_arrays_of_nonnumerical_objects_issue_880_p2(): + with uproot.open(skhep_testdata.data_path("uproot-issue-880.root")) as file: + branch = file["Z/Event/Cluster[6]"] + array = branch.array(library="ak") + interp = uproot.interpretation.identify.interpretation_of( + branch, {}, False + ) # AsObjects(AsArray(False, False, Model_zCluster, (6,))) + + assert len(array) == 116 + assert len(array[0][0]) == 6 # all 6 cluster can now be accessed