diff --git a/src/uproot/behaviors/TBranch.py b/src/uproot/behaviors/TBranch.py index 6686b2cad..8e3945feb 100644 --- a/src/uproot/behaviors/TBranch.py +++ b/src/uproot/behaviors/TBranch.py @@ -2490,7 +2490,7 @@ def _awkward_check(self, interpretation): {} -instead, try library="np" instead of library="ak" or globally set uproot.default_library +instead, try library="np" rather than library="ak" or globally set uproot.default_library in file {} in object {}""".format( diff --git a/src/uproot/models/TAtt.py b/src/uproot/models/TAtt.py index 7ddbc3867..3a0ce5166 100644 --- a/src/uproot/models/TAtt.py +++ b/src/uproot/models/TAtt.py @@ -526,6 +526,7 @@ def awkward_form(cls, file, context): raise uproot.interpretation.objects.CannotBeAwkward( "classes that can contain members of the same type cannot be Awkward Arrays because the depth of instances is unbounded" ) + context = context.copy() context["breadcrumbs"] = context["breadcrumbs"] + (cls,) contents = {} if context["header"]: @@ -679,6 +680,7 @@ def awkward_form(cls, file, context): raise uproot.interpretation.objects.CannotBeAwkward( "classes that can contain members of the same type cannot be Awkward Arrays because the depth of instances is unbounded" ) + context = context.copy() context["breadcrumbs"] = context["breadcrumbs"] + (cls,) contents = {} if context["header"]: diff --git a/src/uproot/models/TGraph.py b/src/uproot/models/TGraph.py index 691a792f9..0eb517983 100644 --- a/src/uproot/models/TGraph.py +++ b/src/uproot/models/TGraph.py @@ -249,6 +249,7 @@ def awkward_form(cls, file, context): raise uproot.interpretation.objects.CannotBeAwkward( "classes that can contain members of the same type cannot be Awkward Arrays because the depth of instances is unbounded" ) + context = context.copy() context["breadcrumbs"] = context["breadcrumbs"] + (cls,) contents = {} if context["header"]: @@ -455,6 +456,7 @@ def awkward_form(cls, file, context): raise uproot.interpretation.objects.CannotBeAwkward( "classes that can contain members of the same type cannot be Awkward Arrays because the depth of instances is unbounded" ) + context = context.copy() context["breadcrumbs"] = context["breadcrumbs"] + (cls,) contents = {} if context["header"]: @@ -666,6 +668,7 @@ def awkward_form(cls, file, context): raise uproot.interpretation.objects.CannotBeAwkward( "classes that can contain members of the same type cannot be Awkward Arrays because the depth of instances is unbounded" ) + context = context.copy() context["breadcrumbs"] = context["breadcrumbs"] + (cls,) contents = {} if context["header"]: diff --git a/src/uproot/models/TH.py b/src/uproot/models/TH.py index a39c39dda..5bff39b87 100644 --- a/src/uproot/models/TH.py +++ b/src/uproot/models/TH.py @@ -338,6 +338,7 @@ def awkward_form(cls, file, context): raise uproot.interpretation.objects.CannotBeAwkward( "classes that can contain members of the same type cannot be Awkward Arrays because the depth of instances is unbounded" ) + context = context.copy() context["breadcrumbs"] = context["breadcrumbs"] + (cls,) contents = {} if context["header"]: @@ -814,6 +815,7 @@ def awkward_form(cls, file, context): raise uproot.interpretation.objects.CannotBeAwkward( "classes that can contain members of the same type cannot be Awkward Arrays because the depth of instances is unbounded" ) + context = context.copy() context["breadcrumbs"] = context["breadcrumbs"] + (cls,) contents = {} if context["header"]: @@ -1119,6 +1121,7 @@ def awkward_form(cls, file, context): raise uproot.interpretation.objects.CannotBeAwkward( "classes that can contain members of the same type cannot be Awkward Arrays because the depth of instances is unbounded" ) + context = context.copy() context["breadcrumbs"] = context["breadcrumbs"] + (cls,) contents = {} if context["header"]: @@ -1328,6 +1331,7 @@ def awkward_form(cls, file, context): raise uproot.interpretation.objects.CannotBeAwkward( "classes that can contain members of the same type cannot be Awkward Arrays because the depth of instances is unbounded" ) + context = context.copy() context["breadcrumbs"] = context["breadcrumbs"] + (cls,) contents = {} if context["header"]: @@ -1517,6 +1521,7 @@ def awkward_form(cls, file, context): raise uproot.interpretation.objects.CannotBeAwkward( "classes that can contain members of the same type cannot be Awkward Arrays because the depth of instances is unbounded" ) + context = context.copy() context["breadcrumbs"] = context["breadcrumbs"] + (cls,) contents = {} if context["header"]: @@ -1679,6 +1684,7 @@ def awkward_form(cls, file, context): raise uproot.interpretation.objects.CannotBeAwkward( "classes that can contain members of the same type cannot be Awkward Arrays because the depth of instances is unbounded" ) + context = context.copy() context["breadcrumbs"] = context["breadcrumbs"] + (cls,) contents = {} if context["header"]: @@ -1836,6 +1842,7 @@ def awkward_form(cls, file, context): raise uproot.interpretation.objects.CannotBeAwkward( "classes that can contain members of the same type cannot be Awkward Arrays because the depth of instances is unbounded" ) + context = context.copy() context["breadcrumbs"] = context["breadcrumbs"] + (cls,) contents = {} if context["header"]: @@ -1993,6 +2000,7 @@ def awkward_form(cls, file, context): raise uproot.interpretation.objects.CannotBeAwkward( "classes that can contain members of the same type cannot be Awkward Arrays because the depth of instances is unbounded" ) + context = context.copy() context["breadcrumbs"] = context["breadcrumbs"] + (cls,) contents = {} if context["header"]: @@ -2155,6 +2163,7 @@ def awkward_form(cls, file, context): raise uproot.interpretation.objects.CannotBeAwkward( "classes that can contain members of the same type cannot be Awkward Arrays because the depth of instances is unbounded" ) + context = context.copy() context["breadcrumbs"] = context["breadcrumbs"] + (cls,) contents = {} if context["header"]: @@ -2317,6 +2326,7 @@ def awkward_form(cls, file, context): raise uproot.interpretation.objects.CannotBeAwkward( "classes that can contain members of the same type cannot be Awkward Arrays because the depth of instances is unbounded" ) + context = context.copy() context["breadcrumbs"] = context["breadcrumbs"] + (cls,) contents = {} if context["header"]: @@ -2480,6 +2490,7 @@ def awkward_form(cls, file, context): raise uproot.interpretation.objects.CannotBeAwkward( "classes that can contain members of the same type cannot be Awkward Arrays because the depth of instances is unbounded" ) + context = context.copy() context["breadcrumbs"] = context["breadcrumbs"] + (cls,) contents = {} if context["header"]: @@ -2638,6 +2649,7 @@ def awkward_form(cls, file, context): raise uproot.interpretation.objects.CannotBeAwkward( "classes that can contain members of the same type cannot be Awkward Arrays because the depth of instances is unbounded" ) + context = context.copy() context["breadcrumbs"] = context["breadcrumbs"] + (cls,) contents = {} if context["header"]: @@ -2801,6 +2813,7 @@ def awkward_form(cls, file, context): raise uproot.interpretation.objects.CannotBeAwkward( "classes that can contain members of the same type cannot be Awkward Arrays because the depth of instances is unbounded" ) + context = context.copy() context["breadcrumbs"] = context["breadcrumbs"] + (cls,) contents = {} if context["header"]: @@ -2964,6 +2977,7 @@ def awkward_form(cls, file, context): raise uproot.interpretation.objects.CannotBeAwkward( "classes that can contain members of the same type cannot be Awkward Arrays because the depth of instances is unbounded" ) + context = context.copy() context["breadcrumbs"] = context["breadcrumbs"] + (cls,) contents = {} if context["header"]: @@ -3127,6 +3141,7 @@ def awkward_form(cls, file, context): raise uproot.interpretation.objects.CannotBeAwkward( "classes that can contain members of the same type cannot be Awkward Arrays because the depth of instances is unbounded" ) + context = context.copy() context["breadcrumbs"] = context["breadcrumbs"] + (cls,) contents = {} if context["header"]: @@ -3291,6 +3306,7 @@ def awkward_form(cls, file, context): raise uproot.interpretation.objects.CannotBeAwkward( "classes that can contain members of the same type cannot be Awkward Arrays because the depth of instances is unbounded" ) + context = context.copy() context["breadcrumbs"] = context["breadcrumbs"] + (cls,) contents = {} if context["header"]: @@ -3450,6 +3466,7 @@ def awkward_form(cls, file, context): raise uproot.interpretation.objects.CannotBeAwkward( "classes that can contain members of the same type cannot be Awkward Arrays because the depth of instances is unbounded" ) + context = context.copy() context["breadcrumbs"] = context["breadcrumbs"] + (cls,) contents = {} if context["header"]: @@ -3614,6 +3631,7 @@ def awkward_form(cls, file, context): raise uproot.interpretation.objects.CannotBeAwkward( "classes that can contain members of the same type cannot be Awkward Arrays because the depth of instances is unbounded" ) + context = context.copy() context["breadcrumbs"] = context["breadcrumbs"] + (cls,) contents = {} if context["header"]: @@ -3778,6 +3796,7 @@ def awkward_form(cls, file, context): raise uproot.interpretation.objects.CannotBeAwkward( "classes that can contain members of the same type cannot be Awkward Arrays because the depth of instances is unbounded" ) + context = context.copy() context["breadcrumbs"] = context["breadcrumbs"] + (cls,) contents = {} if context["header"]: @@ -3978,6 +3997,7 @@ def awkward_form(cls, file, context): raise uproot.interpretation.objects.CannotBeAwkward( "classes that can contain members of the same type cannot be Awkward Arrays because the depth of instances is unbounded" ) + context = context.copy() context["breadcrumbs"] = context["breadcrumbs"] + (cls,) contents = {} if context["header"]: @@ -4217,6 +4237,7 @@ def awkward_form(cls, file, context): raise uproot.interpretation.objects.CannotBeAwkward( "classes that can contain members of the same type cannot be Awkward Arrays because the depth of instances is unbounded" ) + context = context.copy() context["breadcrumbs"] = context["breadcrumbs"] + (cls,) contents = {} if context["header"]: @@ -4458,6 +4479,7 @@ def awkward_form(cls, file, context): raise uproot.interpretation.objects.CannotBeAwkward( "classes that can contain members of the same type cannot be Awkward Arrays because the depth of instances is unbounded" ) + context = context.copy() context["breadcrumbs"] = context["breadcrumbs"] + (cls,) contents = {} if context["header"]: diff --git a/src/uproot/streamers.py b/src/uproot/streamers.py index 84f737d98..e99bf3ee7 100644 --- a/src/uproot/streamers.py +++ b/src/uproot/streamers.py @@ -242,6 +242,7 @@ def class_code(self): " from awkward.forms import NumpyForm, ListOffsetForm, RegularForm, RecordForm", " if cls in context['breadcrumbs']:", " raise uproot.interpretation.objects.CannotBeAwkward('classes that can contain members of the same type cannot be Awkward Arrays because the depth of instances is unbounded')", + " context = context.copy()", " context['breadcrumbs'] = context['breadcrumbs'] + (cls,)", " contents = {}", " if context['header']:", diff --git a/tests/test_0886-fix-awkward-form-breadcrumbs.py b/tests/test_0886-fix-awkward-form-breadcrumbs.py new file mode 100644 index 000000000..6309dbf55 --- /dev/null +++ b/tests/test_0886-fix-awkward-form-breadcrumbs.py @@ -0,0 +1,10 @@ +# BSD 3-Clause License; see https://github.com/scikit-hep/uproot5/blob/main/LICENSE + +import uproot +import skhep_testdata + + +def test_fix_awkward_form_breadcrumbs(): + file = uproot.open(skhep_testdata.data_path("uproot-issue-880.root")) + tree = file["Z"] + assert tree.num_entries == 116