Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def test_jagged_i8(tmp_path):
- filename = join(str(tmp_path), "example.root")
- a = awkward.fromiter([[0],
- [1, 2],
- [10, 11, 12]])
- with uproot.recreate(filename, compression=None) as f:
- f["t"] = uproot.newtree({"branch": uproot.newbranch(numpy.dtype(">i8"), dependence="n")})
- f["t"].extend({"branch": a, "n": [1, 2, 3]})
- ROOT.gInterpreter.Declare("""
- void readnewbasket(Long64_t* arr, char* filename) {
- TFile *f = new TFile("jaggedint.root");
- Long64_t x;
- Int_t num;
- Int_t last_num = 0;
- auto tree = f->Get<TTree>("t");
- auto n = tree->GetBranch("n");
- auto branch = tree->GetBranch("branch");
- n->SetAddress(&num);
- branch->SetAddress(&x);
- for (int i=0; i<tree->GetEntries(); i++) {
- tree->GetEvent(i);
- for (int j=0; j<num; j++) {
- *(arr + (i*last_num) + j) = x+j;
- }
- last_num = num;
- }
- }""")
- testa = awkward.fromiter([[0], [0, 0], [0, 0, 0]])
- ROOT.readnewbasket(testa, filename)
- for i in range(3):
- assert (a[i] == testa[i])
Add Comment
Please, Sign In to add comment