Esempio n. 1
0
def test_ttree_uproot(tmp_path):
    filename = join(str(tmp_path), "example.root")

    tree = newtree()
    with uproot.recreate(filename, compression=None) as f:
        f["t"] = tree

    f = uproot.open(filename)
    assert f["t"]._classname == b"TTree"
Esempio n. 2
0
def test_ttree(tmp_path):
    filename = join(str(tmp_path), "example.root")

    tree = newtree()
    with uproot.recreate(filename, compression=None) as f:
        f["t"] = tree

    f = ROOT.TFile.Open(filename)
    assert f.GetKey("t").GetClassName() == "TTree"
Esempio n. 3
0
def test_ttree_empty_tbranch_title(tmp_path):
    filename = join(str(tmp_path), "example.root")

    b = newbranch("int32", title="hi")
    branchdict = {"intBranch": b}
    tree = newtree(branchdict)
    with uproot.recreate(filename, compression=None) as f:
        f["t"] = tree

    f = ROOT.TFile.Open(filename)
    assert f.Get("t").GetBranch("intBranch").GetTitle() == "hi"
Esempio n. 4
0
def test_ttree_empty_tbranch_uproot(tmp_path):
    filename = join(str(tmp_path), "example.root")

    b = newbranch("int32")
    branchdict = {"intBranch": b}
    tree = newtree(branchdict)
    with uproot.recreate(filename, compression=None) as f:
        f["t"] = tree

    f = uproot.open(filename)
    assert f["t"]["intBranch"]._classname == b"TBranch"
Esempio n. 5
0
def test_ttree_multiple_uproot(tmp_path):
    filename = join(str(tmp_path), "example.root")

    tree = newtree()
    with uproot.recreate(filename, compression=None) as f:
        for i in range(100):
            f["t" * (i + 1)] = tree

    f = uproot.open(filename)
    for i in range(100):
        assert f["t" * (i + 1)]._classname == b"TTree"
Esempio n. 6
0
def test_ttree_multiple(tmp_path):
    filename = join(str(tmp_path), "example.root")

    tree = newtree()
    with uproot.recreate(filename, compression=None) as f:
        for i in range(100):
            f["t" * (i + 1)] = tree

    f = ROOT.TFile.Open(filename)
    for i in range(100):
        assert f.GetKey("t" * (i + 1)).GetClassName() == "TTree"
Esempio n. 7
0
def test_ttree_empty_tbranch_multitree(tmp_path):
    filename = join(str(tmp_path), "example.root")

    b = newbranch("int32")
    branchdict = {"intBranch": b}
    tree = newtree(branchdict)
    with uproot.recreate(filename, compression=None) as f:
        for i in range(100):
            f["t" * (i + 1)] = tree

    f = ROOT.TFile.Open(filename)
    for i in range(100):
        assert f.Get("t" *
                     (i + 1)).GetBranch("intBranch").GetName() == "intBranch"
Esempio n. 8
0
def test_empty_ttree_rewrite_root(tmp_path):
    filename = join(str(tmp_path), "example.root")

    b = newbranch("int32")
    branchdict = {"intBranch": b}
    tree = newtree(branchdict)
    with uproot.recreate(filename, compression=None) as f:
        f["t"] = tree

    f = ROOT.TFile.Open(filename, "UPDATE")
    t = ROOT.TObjString("Hello World")
    t.Write()
    f.Close()

    f = ROOT.TFile.Open(filename)
    assert f.Get("Hello World") == "Hello World"