Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
Root
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
为了安全,强烈建议开启2FA双因子认证:User Settings -> Account -> Enable two-factor authentication!!!
Show more breadcrumbs
cxwx
Root
Commits
a42edc26
Commit
a42edc26
authored
6 years ago
by
Enric Tejedor Saavedra
Browse files
Options
Downloads
Patches
Plain Diff
[Exp PyROOT] Test branch-as-attribute syntax with TNtuples
parent
2b943f46
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bindings/pyroot_experimental/PyROOT/test/ttree_branch_attr.py
+25
-10
25 additions, 10 deletions
...ings/pyroot_experimental/PyROOT/test/ttree_branch_attr.py
with
25 additions
and
10 deletions
bindings/pyroot_experimental/PyROOT/test/ttree_branch_attr.py
+
25
−
10
View file @
a42edc26
...
...
@@ -9,12 +9,13 @@ class TTreeBranchAttr(unittest.TestCase):
Test for the pythonization that allows to access top-level tree branches/leaves as attributes
(i.e. `mytree.mybranch`)
Since this pythonization is common to TTree and its subclasses, TChain
is
also tested here.
Since this pythonization is common to TTree and its subclasses, TChain
and TNtuple
are
also tested here.
"""
filename
=
'
treebranchattr.root
'
treename
=
'
mytree
'
tuplename
=
'
mytuple
'
nentries
=
1
arraysize
=
10
more
=
10
...
...
@@ -29,6 +30,11 @@ class TTreeBranchAttr(unittest.TestCase):
cls
.
arraysize
,
cls
.
more
,
'
RECREATE
'
)
ROOT
.
CreateTNtuple
(
cls
.
filename
,
cls
.
tuplename
,
cls
.
nentries
,
cls
.
more
,
'
UPDATE
'
)
# Helper
def
get_file_objects
(
self
):
...
...
@@ -41,21 +47,30 @@ class TTreeBranchAttr(unittest.TestCase):
c
.
Add
(
self
.
filename
)
c
.
Add
(
self
.
filename
)
nt
=
f
.
Get
(
self
.
tuplename
)
SetOwnership
(
nt
,
False
)
# Read first entry
for
ds
in
t
,
c
:
for
ds
in
t
,
c
,
nt
:
ds
.
GetEntry
(
0
)
return
f
,
t
,
c
return
f
,
t
,
c
,
nt
# Tests
def
test_basic_type_branch
(
self
):
f
,
t
,
c
=
self
.
get_file_objects
()
f
,
t
,
c
,
nt
=
self
.
get_file_objects
()
# TTree, TChain
for
ds
in
t
,
c
:
self
.
assertEqual
(
ds
.
floatb
,
self
.
more
)
# TNtuple
self
.
assertEqual
(
nt
.
x
,
0.
)
self
.
assertEqual
(
nt
.
y
,
self
.
more
)
self
.
assertEqual
(
nt
.
z
,
2
*
self
.
more
)
def
test_array_branch
(
self
):
f
,
t
,
c
=
self
.
get_file_objects
()
f
,
t
,
c
,
_
=
self
.
get_file_objects
()
for
ds
in
t
,
c
:
a
=
ds
.
arrayb
...
...
@@ -64,7 +79,7 @@ class TTreeBranchAttr(unittest.TestCase):
self
.
assertEqual
(
a
[
j
],
j
)
def
test_vector_branch
(
self
):
f
,
t
,
c
=
self
.
get_file_objects
()
f
,
t
,
c
,
_
=
self
.
get_file_objects
()
for
ds
in
t
,
c
:
v
=
ds
.
vectorb
...
...
@@ -73,7 +88,7 @@ class TTreeBranchAttr(unittest.TestCase):
self
.
assertEqual
(
v
[
j
],
j
)
def
test_struct_branch
(
self
):
f
,
t
,
c
=
self
.
get_file_objects
()
f
,
t
,
c
,
_
=
self
.
get_file_objects
()
for
ds
in
t
,
c
:
ms
=
ds
.
structb
...
...
@@ -82,14 +97,14 @@ class TTreeBranchAttr(unittest.TestCase):
self
.
assertEqual
(
ms
.
myint2
,
0
)
def
test_struct_branch_leaflist
(
self
):
f
,
t
,
c
=
self
.
get_file_objects
()
f
,
t
,
c
,
_
=
self
.
get_file_objects
()
for
ds
in
t
,
c
:
self
.
assertEqual
(
ds
.
myintll1
,
self
.
more
)
self
.
assertEqual
(
ds
.
myintll2
,
0
)
def
test_alias_branch
(
self
):
f
,
t
,
c
=
self
.
get_file_objects
()
f
,
t
,
c
,
_
=
self
.
get_file_objects
()
for
ds
in
t
,
c
:
ds
.
SetAlias
(
'
myalias
'
,
'
floatb
'
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment