示例#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"
示例#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"
示例#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"
示例#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"
示例#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"
示例#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"
示例#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"
示例#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"