diff --git a/src/uproot/interpretation/__init__.py b/src/uproot/interpretation/__init__.py index 5cde64fea..0f15788b4 100644 --- a/src/uproot/interpretation/__init__.py +++ b/src/uproot/interpretation/__init__.py @@ -56,6 +56,17 @@ def numpy_dtype(self): """ raise AssertionError + @staticmethod + def _make_context(context, index_format, header, tobject_header, breadcrumbs): + if context is None: + context = {} + context["index_format"] = "i64" + context["header"] = False + context["tobject_header"] = True + context["breadcrumbs"] = () + + return context + def awkward_form(self, file, context): """ Args: diff --git a/src/uproot/interpretation/grouped.py b/src/uproot/interpretation/grouped.py index ecf6f864b..5b8ac4b35 100644 --- a/src/uproot/interpretation/grouped.py +++ b/src/uproot/interpretation/grouped.py @@ -84,7 +84,18 @@ def typename(self): ) ) - def awkward_form(self, file, context): + def awkward_form( + self, + file, + context=None, + index_format="i64", + header=False, + tobject_header=True, + breadcrumbs=(), + ): + context = self._make_context( + context, index_format, header, tobject_header, breadcrumbs + ) awkward = uproot.extras.awkward() names = [] fields = [] diff --git a/src/uproot/interpretation/numerical.py b/src/uproot/interpretation/numerical.py index 047199db0..efc7423e7 100644 --- a/src/uproot/interpretation/numerical.py +++ b/src/uproot/interpretation/numerical.py @@ -249,7 +249,18 @@ def inner_shape(self): def numpy_dtype(self): return self._to_dtype - def awkward_form(self, file, context): + def awkward_form( + self, + file, + context=None, + index_format="i64", + header=False, + tobject_header=True, + breadcrumbs=(), + ): + context = self._make_context( + context, index_format, header, tobject_header, breadcrumbs + ) awkward = uproot.extras.awkward() d, s = _dtype_shape(self._to_dtype) out = uproot._util.awkward_form(d, file, context) @@ -624,7 +635,18 @@ def to_dtype(self): def typename(self): return "Double32_t" + "".join("[" + str(dim) + "]" for dim in self._to_dims) - def awkward_form(self, file, context): + def awkward_form( + self, + file, + context=None, + index_format="i64", + header=False, + tobject_header=True, + breadcrumbs=(), + ): + context = self._make_context( + context, index_format, header, tobject_header, breadcrumbs + ) awkward = uproot.extras.awkward() out = awkward.forms.NumpyForm( (), @@ -683,7 +705,18 @@ def to_dtype(self): def typename(self): return "Float16_t" + "".join("[" + str(dim) + "]" for dim in self._to_dims) - def awkward_form(self, file, context): + def awkward_form( + self, + file, + context=None, + index_format="i64", + header=False, + tobject_header=True, + breadcrumbs=(), + ): + context = self._make_context( + context, index_format, header, tobject_header, breadcrumbs + ) awkward = uproot.extras.awkward() out = awkward.forms.NumpyForm( (), diff --git a/src/uproot/interpretation/objects.py b/src/uproot/interpretation/objects.py index 16f85da56..53d4cbd0e 100644 --- a/src/uproot/interpretation/objects.py +++ b/src/uproot/interpretation/objects.py @@ -104,7 +104,18 @@ def typename(self): else: return uproot.model.classname_decode(self._model.__name__)[0] - def awkward_form(self, file, context): + def awkward_form( + self, + file, + context=None, + index_format="i64", + header=False, + tobject_header=True, + breadcrumbs=(), + ): + context = self._make_context( + context, index_format, header, tobject_header, breadcrumbs + ) if isinstance(self._model, type): return self._model.awkward_form(self._branch.file, context) else: @@ -425,7 +436,18 @@ def __eq__(self, other): def numpy_dtype(self): return numpy.dtype(object) - def awkward_form(self, file, context): + def awkward_form( + self, + file, + context=None, + index_format="i64", + header=False, + tobject_header=True, + breadcrumbs=(), + ): + context = self._make_context( + context, index_format, header, tobject_header, breadcrumbs + ) awkward = uproot.extras.awkward() cname = uproot.model.classname_decode(self._model.__name__)[0] form = _strided_awkward_form(awkward, cname, self._members, file, context) diff --git a/src/uproot/interpretation/strings.py b/src/uproot/interpretation/strings.py index fc4b6e60d..789ebe1ed 100644 --- a/src/uproot/interpretation/strings.py +++ b/src/uproot/interpretation/strings.py @@ -119,7 +119,18 @@ def typename(self): def numpy_dtype(self): return numpy.dtype(object) - def awkward_form(self, file, context): + def awkward_form( + self, + file, + context=None, + index_format="i64", + header=False, + tobject_header=True, + breadcrumbs=(), + ): + context = self._make_context( + context, index_format, header, tobject_header, breadcrumbs + ) awkward = uproot.extras.awkward() return awkward.forms.ListOffsetForm( context["index_format"],