Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
km3io
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container 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
Show more breadcrumbs
km3py
km3io
Commits
c41a8731
Commit
c41a8731
authored
4 years ago
by
Zineb Aly
Browse files
Options
Downloads
Patches
Plain Diff
add tests for rec_stages masks for signle event
parent
bb3bdc67
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!45
Adapt best track root access
Pipeline
#14284
passed with warnings
4 years ago
Stage: test
Stage: coverage
Stage: doc
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_tools.py
+30
-12
30 additions, 12 deletions
tests/test_tools.py
with
30 additions
and
12 deletions
tests/test_tools.py
+
30
−
12
View file @
c41a8731
...
...
@@ -159,22 +159,22 @@ class TestCountNested(unittest.TestCase):
class
TestRecStagesMasks
(
unittest
.
TestCase
):
def
setUp
(
self
):
#
self.nested = ak.Array([[[1, 2, 3], [1, 2, 3], [1]], [[0], [1, 2, 3]],
#
[[0], [0, 1, 3], [0], [1, 2, 3], [1, 2, 3]]])
self
.
nested
=
ak
.
Array
([[[
1
,
2
,
3
],
[
1
,
2
,
3
],
[
1
]],
[[
0
],
[
1
,
2
,
3
]],
[[
0
],
[
0
,
1
,
3
],
[
0
],
[
1
,
2
,
3
],
[
1
,
2
,
3
]]])
self
.
tracks
=
OFFLINE_FILE
.
events
.
tracks
#
def test_find(self):
#
builder = ak.ArrayBuilder()
#
_find(self.nested, ak.Array([1, 2, 3]), builder)
#
labels = builder.snapshot()
def
test_find
(
self
):
builder
=
ak
.
ArrayBuilder
()
_find
(
self
.
nested
,
ak
.
Array
([
1
,
2
,
3
]),
builder
)
labels
=
builder
.
snapshot
()
#
assert labels[0][0] == 1
#
assert labels[0][1] == 1
#
assert labels[0][2] == 0
#
assert labels[1][0] == 0
assert
labels
[
0
][
0
]
==
1
assert
labels
[
0
][
1
]
==
1
assert
labels
[
0
][
2
]
==
0
assert
labels
[
1
][
0
]
==
0
def
test_mask_with_explicit_rec_stages
(
self
):
def
test_mask_with_explicit_rec_stages
_with_multiple_events
(
self
):
rec_stages
=
self
.
tracks
.
rec_stages
stages
=
[
1
,
3
,
5
,
4
]
masks
=
mask
(
self
.
tracks
,
stages
=
stages
)
...
...
@@ -183,7 +183,7 @@ class TestRecStagesMasks(unittest.TestCase):
assert
masks
[
1
][
0
]
==
all
(
rec_stages
[
1
][
0
]
==
ak
.
Array
(
stages
))
assert
masks
[
0
][
1
]
==
False
def
test_mask_with_start_and_end_of_rec_stages
(
self
):
def
test_mask_with_start_and_end_of_rec_stages
_with_multiple_events
(
self
):
rec_stages
=
self
.
tracks
.
rec_stages
stages
=
[
1
,
3
,
5
,
4
]
masks
=
mask
(
self
.
tracks
,
start
=
1
,
end
=
4
)
...
...
@@ -192,6 +192,24 @@ class TestRecStagesMasks(unittest.TestCase):
assert
masks
[
1
][
0
]
==
all
(
rec_stages
[
1
][
0
]
==
ak
.
Array
(
stages
))
assert
masks
[
0
][
1
]
==
False
def
test_mask_with_start_and_end_of_rec_stages_signle_event
(
self
):
rec_stages
=
self
.
tracks
.
rec_stages
[
0
][
0
]
stages
=
[
1
,
3
,
5
,
4
]
track
=
self
.
tracks
[
0
]
masks
=
mask
(
track
,
start
=
1
,
end
=
4
)
assert
track
[
masks
].
rec_stages
[
0
][
0
]
==
1
assert
track
[
masks
].
rec_stages
[
0
][
-
1
]
==
4
def
test_mask_with_explicit_rec_stages_with_single_event
(
self
):
rec_stages
=
self
.
tracks
.
rec_stages
[
0
][
0
]
stages
=
[
1
,
3
]
track
=
self
.
tracks
[
0
]
masks
=
mask
(
track
,
stages
=
stages
)
assert
track
[
masks
].
rec_stages
[
0
][
0
]
==
stages
[
0
]
assert
track
[
masks
].
rec_stages
[
0
][
1
]
==
stages
[
1
]
class
TestUnique
(
unittest
.
TestCase
):
def
run_random_test_with_dtype
(
self
,
dtype
):
...
...
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