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
387225a8
Commit
387225a8
authored
4 years ago
by
Tamas Gal
Browse files
Options
Downloads
Patches
Plain Diff
Fixing more tests
parent
000d7354
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!47
Resolve "uproot4 integration"
Pipeline
#16282
failed
4 years ago
Stage: test
Stage: coverage
Stage: doc
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
km3io/offline.py
+5
-3
5 additions, 3 deletions
km3io/offline.py
km3io/tools.py
+1
-1
1 addition, 1 deletion
km3io/tools.py
tests/test_offline.py
+14
-18
14 additions, 18 deletions
tests/test_offline.py
with
20 additions
and
22 deletions
km3io/offline.py
+
5
−
3
View file @
387225a8
...
...
@@ -186,8 +186,10 @@ class OfflineReader:
def
__getitem__
(
self
,
key
):
# indexing
if
isinstance
(
key
,
(
slice
,
int
,
np
.
int32
,
np
.
int64
)):
if
not
isinstance
(
key
,
slice
):
# TODO: maybe just propagate everything to awkward and let it deal
# with the type?
if
isinstance
(
key
,
(
slice
,
int
,
np
.
int32
,
np
.
int64
,
list
,
np
.
ndarray
,
ak
.
Array
)):
if
isinstance
(
key
,
(
int
,
np
.
int32
,
np
.
int64
)):
key
=
int
(
key
)
return
self
.
__class__
(
self
.
_fobj
,
...
...
@@ -296,7 +298,7 @@ class OfflineReader:
return
1
else
:
# ignore the usual index magic and access `id` directly
return
len
(
self
.
_fobj
[
self
.
event_path
][
"
id
"
].
array
(),
self
.
_index_chain
)
return
len
(
unfold_indices
(
self
.
_fobj
[
self
.
event_path
][
"
id
"
].
array
(),
self
.
_index_chain
)
)
def
__actual_len__
(
self
):
"""
The raw number of events without any indexing/slicing magic
"""
...
...
This diff is collapsed.
Click to expand it.
km3io/tools.py
+
1
−
1
View file @
387225a8
...
...
@@ -288,7 +288,7 @@ def best_track(tracks, startend=None, minmax=None, stages=None):
return
namedtuple
(
"
BestTrack
"
,
out
.
fields
)(
*
[
getattr
(
out
,
a
)[
0
]
for
a
in
out
.
fields
]
)
return
out
return
m3
,
out
def
mask
(
arr
,
sequence
=
None
,
startend
=
None
,
minmax
=
None
,
atleast
=
None
):
...
...
This diff is collapsed.
Click to expand it.
tests/test_offline.py
+
14
−
18
View file @
387225a8
...
...
@@ -165,7 +165,6 @@ class TestOfflineEvents(unittest.TestCase):
assert
np
.
allclose
(
self
.
t_sec
,
self
.
events
[
"
t_sec
"
].
tolist
())
assert
np
.
allclose
(
self
.
t_ns
,
self
.
events
[
"
t_ns
"
].
tolist
())
@unittest.skip
def
test_slicing
(
self
):
s
=
slice
(
2
,
8
,
2
)
s_events
=
self
.
events
[
s
]
...
...
@@ -191,15 +190,14 @@ class TestOfflineEvents(unittest.TestCase):
)
assert
np
.
allclose
(
self
.
events
[
3
:
5
][
0
].
n_hits
,
self
.
events
.
n_hits
[
3
:
5
][
0
])
@unittest.skip
def
test_index_chaining_on_nested_branches_aka_records
(
self
):
assert
np
.
allclose
(
self
.
events
[
3
:
5
].
hits
[
1
].
dom_id
[
4
],
self
.
events
.
hits
[
3
:
5
][
1
]
[
4
]
.
dom_id
,
self
.
events
.
hits
[
3
:
5
][
1
].
dom_id
[
4
]
,
)
assert
np
.
allclose
(
self
.
events
.
hits
[
3
:
5
][
1
]
[
4
]
.
dom_id
.
tolist
()
,
self
.
events
[
3
:
5
][
1
]
[
4
]
.
hits
.
dom_id
.
tolist
()
,
self
.
events
.
hits
[
3
:
5
][
1
].
dom_id
[
4
]
,
self
.
events
[
3
:
5
][
1
].
hits
.
dom_id
[
4
]
,
)
def
test_fancy_indexing
(
self
):
...
...
@@ -210,12 +208,14 @@ class TestOfflineEvents(unittest.TestCase):
assert
8
==
len
(
first_tracks
.
rec_stages
)
assert
8
==
len
(
first_tracks
.
lik
)
@unittest.skip
def
test_iteration
(
self
):
i
=
0
for
event
in
self
.
events
:
i
+=
1
assert
10
==
i
@unittest.skip
def
test_iteration_2
(
self
):
n_hits
=
[
len
(
e
.
hits
.
id
)
for
e
in
self
.
events
]
assert
np
.
allclose
(
n_hits
,
ak
.
num
(
self
.
events
.
hits
.
id
,
axis
=
1
).
tolist
())
...
...
@@ -383,11 +383,10 @@ class TestOfflineTracks(unittest.TestCase):
def
test_repr
(
self
):
assert
"
10 *
"
in
repr
(
self
.
tracks
)
@unittest.skip
def
test_slicing
(
self
):
tracks
=
self
.
tracks
self
.
assertEqual
(
10
,
len
(
tracks
))
# 10 events
self
.
assertEqual
(
56
,
len
(
tracks
[
0
]))
# number of tracks in first event
self
.
assertEqual
(
56
,
len
(
tracks
[
0
]
.
id
))
# number of tracks in first event
track_selection
=
tracks
[
2
:
7
]
assert
5
==
len
(
track_selection
)
track_selection_2
=
tracks
[
1
:
3
]
...
...
@@ -403,7 +402,6 @@ class TestOfflineTracks(unittest.TestCase):
list
(
tracks
.
E
[:,
0
][
_slice
]),
list
(
tracks
[
_slice
].
E
[:,
0
])
)
@unittest.skip
def
test_nested_indexing
(
self
):
self
.
assertAlmostEqual
(
self
.
f
.
events
.
tracks
.
fitinf
[
3
:
5
][
1
][
9
][
2
],
...
...
@@ -411,15 +409,7 @@ class TestOfflineTracks(unittest.TestCase):
)
self
.
assertAlmostEqual
(
self
.
f
.
events
.
tracks
.
fitinf
[
3
:
5
][
1
][
9
][
2
],
self
.
f
.
events
[
3
:
5
][
1
][
9
][
2
].
tracks
.
fitinf
,
)
self
.
assertAlmostEqual
(
self
.
f
.
events
.
tracks
.
fitinf
[
3
:
5
][
1
][
9
][
2
],
self
.
f
.
events
[
3
:
5
][
1
].
tracks
[
9
][
2
].
fitinf
,
)
self
.
assertAlmostEqual
(
self
.
f
.
events
.
tracks
.
fitinf
[
3
:
5
][
1
][
9
][
2
],
self
.
f
.
events
[
3
:
5
][
1
].
tracks
[
9
].
fitinf
[
2
],
self
.
f
.
events
[
3
:
5
][
1
].
tracks
.
fitinf
[
9
][
2
],
)
...
...
@@ -437,11 +427,17 @@ class TestBranchIndexingMagic(unittest.TestCase):
self
.
events
.
tracks
.
pos_y
[
3
:
6
,
0
].
tolist
(),
)
@unittest.skip
def
test_selecting_specific_items_via_a_list
(
self
):
# test selecting with a list
self
.
assertEqual
(
3
,
len
(
self
.
events
[[
0
,
2
,
3
]]))
def
test_selecting_specific_items_via_a_numpy_array
(
self
):
# test selecting with a list
self
.
assertEqual
(
3
,
len
(
self
.
events
[
np
.
array
([
0
,
2
,
3
])]))
def
test_selecting_specific_items_via_a_awkward_array
(
self
):
# test selecting with a list
self
.
assertEqual
(
3
,
len
(
self
.
events
[
ak
.
Array
([
0
,
2
,
3
])]))
class
TestUsr
(
unittest
.
TestCase
):
def
setUp
(
self
):
...
...
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