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
7812f04f
Commit
7812f04f
authored
6 years ago
by
Enric Tejedor Saavedra
Browse files
Options
Downloads
Patches
Plain Diff
[Exp PyROOT] Test pythonisation to make TIter a Python iterator
parent
84dad247
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/titer_iterator.py
+33
-0
33 additions, 0 deletions
bindings/pyroot_experimental/PyROOT/test/titer_iterator.py
with
36 additions
and
0 deletions
bindings/pyroot_experimental/PyROOT/test/CMakeLists.txt
+
3
−
0
View file @
7812f04f
...
@@ -17,6 +17,9 @@ ROOT_ADD_PYUNITTEST(pyroot_pyz_ttree_setbranchaddress ttree_setbranchaddress.py
...
@@ -17,6 +17,9 @@ ROOT_ADD_PYUNITTEST(pyroot_pyz_ttree_setbranchaddress ttree_setbranchaddress.py
ROOT_ADD_PYUNITTEST
(
pyroot_pyz_ttree_branch ttree_branch.py
ROOT_ADD_PYUNITTEST
(
pyroot_pyz_ttree_branch ttree_branch.py
COPY_TO_BUILDDIR TreeHelper.h
)
COPY_TO_BUILDDIR TreeHelper.h
)
# TIter pythonisations
ROOT_ADD_PYUNITTEST
(
pyroot_pyz_titer_iterator titer_iterator.py
)
# TCollection and subclasses pythonizations
# TCollection and subclasses pythonizations
ROOT_ADD_PYUNITTEST
(
pyroot_pyz_tcollection_len tcollection_len.py
)
ROOT_ADD_PYUNITTEST
(
pyroot_pyz_tcollection_len tcollection_len.py
)
ROOT_ADD_PYUNITTEST
(
pyroot_pyz_tcollection_listmethods tcollection_listmethods.py
)
ROOT_ADD_PYUNITTEST
(
pyroot_pyz_tcollection_listmethods tcollection_listmethods.py
)
...
...
This diff is collapsed.
Click to expand it.
bindings/pyroot_experimental/PyROOT/test/titer_iterator.py
0 → 100644
+
33
−
0
View file @
7812f04f
import
unittest
import
ROOT
from
libcppyy
import
SetOwnership
class
TIterIterator
(
unittest
.
TestCase
):
"""
Test for the pythonization that allows instances of TIter to
behave as Python iterators.
"""
num_elems
=
3
# Helpers
def
create_tcollection
(
self
):
c
=
ROOT
.
TList
()
for
_
in
range
(
self
.
num_elems
):
o
=
ROOT
.
TObject
()
# Prevent immediate deletion of C++ TObjects
SetOwnership
(
o
,
False
)
c
.
Add
(
o
)
return
c
# Tests
def
test_iterator
(
self
):
c
=
self
.
create_tcollection
()
itc1
=
ROOT
.
TIter
(
c
)
itc2
=
ROOT
.
TIter
(
c
)
for
_
in
range
(
c
.
GetEntries
()):
self
.
assertEqual
(
next
(
itc1
),
itc2
.
Next
())
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