Skip to content
This repository has been archived by the owner on Jun 21, 2022. It is now read-only.

Commit

Permalink
Alternate test for ROOT reading jagged arrays of i8 type
Browse files Browse the repository at this point in the history
  • Loading branch information
reikdas committed May 1, 2020
1 parent a1ed12f commit 4ebbcd0
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions tests/test_write.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import pytest
import numpy
import ctypes

import awkward

Expand Down Expand Up @@ -1909,6 +1910,7 @@ def test_jagged_uproot_bool(tmp_path):
for j in range(len(array[i])):
assert(array[i][j] == a[i][j])

#Need to use C++ code to read out because of bug in PyROOT layer (of Conda ROOT build?)
def test_jagged_i8(tmp_path):
filename = join(str(tmp_path), "example.root")

Expand All @@ -1920,10 +1922,29 @@ def test_jagged_i8(tmp_path):
f["t"] = uproot.newtree({"branch": uproot.newbranch(numpy.dtype(">i8"), dependence="n")})
f["t"].extend({"branch": a, "n": [1, 2, 3]})

f = ROOT.TFile.Open(filename)
tree = f.Get("t")
for i, event in enumerate(tree):
assert(numpy.all([x for x in event.branch] == a[i]))
ROOT.gInterpreter.Declare("""
void assertint(bool &flag, char* filename) {
TFile *f = new TFile(filename);
Long64_t x;
Int_t num;
auto tree = f->Get<TTree>("t");
auto n = tree->GetBranch("n");
auto branch = tree->GetBranch("branch");
n->SetAddress(&num);
branch->SetAddress(&x);
Long64_t values[3][3] = {{0,0,0}, {1, 2, 0}, {10, 11, 12}};
for (int i=0; i<tree->GetEntries(); i++) {
tree->GetEvent(i);
for (int j=0; j<num; j++) {
if (values[i][j] != x+j)
flag = false;
}
}
}""")

flag = ctypes.c_bool(True)
ROOT.assertint(flag, filename)
assert(flag)

def test_jagged_uproot_i8(tmp_path):
filename = join(str(tmp_path), "example.root")
Expand Down

0 comments on commit 4ebbcd0

Please sign in to comment.