Skip to content
This repository was archived by the owner on Jan 7, 2023. It is now read-only.

Commit f906d45

Browse files
committed
FAQ: remove use of rootpy
1 parent 26dbdcc commit f906d45

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

docs/faq.rst

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,19 @@ memory.
3434
Instead, just use ROOT directly. Deactivate the branches before calling
3535
the tree's ``CloneTree()`` method. Only the activated branches are copied::
3636

37-
from root_numpy import testdata
38-
from rootpy import asrootpy
39-
from rootpy.io import root_open
40-
41-
rfile = root_open(testdata.get_filepath('single1.root'))
42-
tree = rfile['tree']
43-
print tree.branchnames # prints ['n_int', 'f_float', 'd_double']
44-
45-
# remove the branch named 'd_double'
46-
tree.SetBranchStatus('d_double', 0)
47-
48-
# copy the tree into a new file
49-
with root_open('output.root', 'w'):
50-
newtree = asrootpy(tree.CloneTree())
51-
newtree.Write()
52-
print newtree.branchnames # prints ['n_int', 'f_float']
37+
from root_numpy import testdata
38+
import ROOT
39+
40+
rfile = ROOT.TFile.Open(testdata.get_filepath('single1.root'))
41+
tree = rfile.Get('tree')
42+
print([b.GetName() for b in tree.GetListOfBranches()]) # prints ['n_int', 'f_float', 'd_double']
43+
44+
# remove the branch named 'd_double'
45+
tree.SetBranchStatus('d_double', 0)
46+
47+
# copy the tree into a new file
48+
rfile_out = ROOT.TFile.Open('output.root', 'recreate')
49+
newtree = tree.CloneTree()
50+
newtree.Write()
51+
print([b.GetName() for b in newtree.GetListOfBranches()]) # prints ['n_int', 'f_float']
52+

0 commit comments

Comments
 (0)