Skip to content

Commit

Permalink
fix: models should not be wrapped in a ListOffsetForm (#841)
Browse files Browse the repository at this point in the history
* fix:models should not be wrapped in a ListOffsetForm

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Changed test file name to match PR nr.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
ioanaif and pre-commit-ci[bot] authored Feb 23, 2023
1 parent d7036b4 commit 8f7bf18
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/uproot/containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,14 +328,11 @@ def typename(self):
return uproot.model.classname_decode(self._model.__name__)[0]

def awkward_form(self, file, context):
awkward = uproot.extras.awkward()
uproot.extras.awkward()
if self._model is None:
raise uproot.interpretation.objects.CannotBeAwkward("dynamic type")
else:
return awkward.forms.ListOffsetForm(
context["index_format"],
uproot._util.awkward_form(self._model, file, context),
)
return uproot._util.awkward_form(self._model, file, context)

def read(self, chunk, cursor, context, file, selffile, parent, header=True):
# AwkwardForth testing: test_0637's tests aren't expected to enter here
Expand Down
29 changes: 29 additions & 0 deletions tests/test_0841-fix-814.p
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# BSD 3-Clause License; see https://github.com/scikit-hep/uproot4/blob/main/LICENSE
import os
import numpy
import pytest
import uproot

pytest.importorskip("ROOT")


def test_1(tmp_path):
filename = os.path.join(tmp_path, "tfile_with_tvector3_1.root")
tfile = ROOT.TFile(filename, "RECREATE")
tree = ROOT.TTree("tree", "tree")
tvector3 = ROOT.TVector3()
tree.Branch("tvector3", tvector3)
for x in range(10):
tvector3.SetX(x)
tree.Fill()
tree.AutoSave()
tfile.Close()
uproot.open("tfile_with_tvector3_1.root:tree").arrays()

tfile = ROOT.TFile(filename, "READ")
tree = tfile.Get("tree")
rdf = ROOT.RDataFrame(tree)
branchlist = ROOT.std.vector(ROOT.std.string)()
branchlist.push_back("tvector3")
rdf.Snapshot("tree", "tfile_with_tvector3_2.root", branchlist)
uproot.open("tfile_with_tvector3_2.root:tree").arrays()

0 comments on commit 8f7bf18

Please sign in to comment.