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
89c0c548
Commit
89c0c548
authored
6 years ago
by
Enric Tejedor Saavedra
Browse files
Options
Downloads
Patches
Plain Diff
[Exp PyROOT] Add test for pythonized getters of TGraph family
parent
08a16635
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
bindings/pyroot_experimental/PyROOT/test/CMakeLists.txt
+3
-0
3 additions, 0 deletions
bindings/pyroot_experimental/PyROOT/test/CMakeLists.txt
bindings/pyroot_experimental/PyROOT/test/tgraph_getters.py
+76
-0
76 additions, 0 deletions
bindings/pyroot_experimental/PyROOT/test/tgraph_getters.py
with
79 additions
and
0 deletions
bindings/pyroot_experimental/PyROOT/test/CMakeLists.txt
+
3
−
0
View file @
89c0c548
...
...
@@ -27,6 +27,9 @@ ROOT_ADD_PYUNITTEST(pyroot_pyz_ttree_branch ttree_branch.py
# TH1 and subclasses pythonizations
ROOT_ADD_PYUNITTEST
(
pyroot_pyz_th1_operators th1_operators.py
)
# TGraph, TGraph2D and error subclasses pythonizations
ROOT_ADD_PYUNITTEST
(
pyroot_pyz_tgraph_getters tgraph_getters.py
)
# TCollection and subclasses pythonizations
ROOT_ADD_PYUNITTEST
(
pyroot_pyz_tcollection_len tcollection_len.py
)
ROOT_ADD_PYUNITTEST
(
pyroot_pyz_tcollection_listmethods tcollection_listmethods.py
)
...
...
This diff is collapsed.
Click to expand it.
bindings/pyroot_experimental/PyROOT/test/tgraph_getters.py
0 → 100644
+
76
−
0
View file @
89c0c548
import
unittest
import
array
import
ROOT
class
TGraphGetters
(
unittest
.
TestCase
):
"""
Test for the pythonization of TGraph, TGraph2D and their error
subclasses, in particular of their X,Y,Z coordinates and errors
getters, which sets the size of the returned buffers.
"""
# Tests
def
test_graph
(
self
):
N
=
5
xval
,
yval
=
1
,
2
ax
=
array
.
array
(
'
d
'
,
map
(
lambda
x
:
x
*
xval
,
range
(
N
)))
ay
=
array
.
array
(
'
d
'
,
map
(
lambda
x
:
x
*
yval
,
range
(
N
)))
g
=
ROOT
.
TGraph
(
N
,
ax
,
ay
)
# x and y are buffers of doubles
x
=
g
.
GetX
()
y
=
g
.
GetY
()
# We can get the size of the buffers
self
.
assertEqual
(
len
(
x
),
N
)
self
.
assertEqual
(
len
(
y
),
N
)
# The buffers are iterable
self
.
assertEqual
(
list
(
x
),
list
(
ax
))
self
.
assertEqual
(
list
(
y
),
list
(
ay
))
def
test_graph2derrors
(
self
):
N
=
5
xval
,
yval
,
zval
=
1
,
2
,
3
xerrval
,
yerrval
,
zerrval
=
0.1
,
0.2
,
0.3
ax
=
array
.
array
(
'
d
'
,
map
(
lambda
x
:
x
*
xval
,
range
(
N
)))
ay
=
array
.
array
(
'
d
'
,
map
(
lambda
x
:
x
*
yval
,
range
(
N
)))
az
=
array
.
array
(
'
d
'
,
map
(
lambda
x
:
x
*
zval
,
range
(
N
)))
aex
=
array
.
array
(
'
d
'
,
map
(
lambda
x
:
x
*
xerrval
,
range
(
N
)))
aey
=
array
.
array
(
'
d
'
,
map
(
lambda
x
:
x
*
yerrval
,
range
(
N
)))
aez
=
array
.
array
(
'
d
'
,
map
(
lambda
x
:
x
*
zerrval
,
range
(
N
)))
g
=
ROOT
.
TGraph2DErrors
(
N
,
ax
,
ay
,
az
,
aex
,
aey
,
aez
)
# x, y, z, ex, ey and ez are buffers of doubles
x
=
g
.
GetX
()
y
=
g
.
GetY
()
z
=
g
.
GetZ
()
ex
=
g
.
GetEX
()
ey
=
g
.
GetEY
()
ez
=
g
.
GetEZ
()
# We can get the size of the buffers
self
.
assertEqual
(
len
(
x
),
N
)
self
.
assertEqual
(
len
(
y
),
N
)
self
.
assertEqual
(
len
(
z
),
N
)
self
.
assertEqual
(
len
(
ex
),
N
)
self
.
assertEqual
(
len
(
ey
),
N
)
self
.
assertEqual
(
len
(
ez
),
N
)
# The buffers are iterable
self
.
assertEqual
(
list
(
x
),
list
(
ax
))
self
.
assertEqual
(
list
(
y
),
list
(
ay
))
self
.
assertEqual
(
list
(
z
),
list
(
az
))
self
.
assertEqual
(
list
(
ex
),
list
(
aex
))
self
.
assertEqual
(
list
(
ey
),
list
(
aey
))
self
.
assertEqual
(
list
(
ez
),
list
(
aez
))
if
__name__
==
'
__main__
'
:
unittest
.
main
()
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