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
578d908e
Commit
578d908e
authored
5 years ago
by
Tamas Gal
Browse files
Options
Downloads
Patches
Plain Diff
Cleanup and more tests
parent
2762369c
No related branches found
No related tags found
1 merge request
!27
Refactor offline I/O
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
km3io/offline.py
+2
-0
2 additions, 0 deletions
km3io/offline.py
tests/test_offline.py
+6
-39
6 additions, 39 deletions
tests/test_offline.py
with
8 additions
and
39 deletions
km3io/offline.py
+
2
−
0
View file @
578d908e
...
...
@@ -137,6 +137,8 @@ class Usr:
basketcache
=
BASKET_CACHE
)[
0
]
]
except
(
KeyError
,
IndexError
):
# e.g. old aanet files
print
(
"
The `usr` fields could not be parsed for the
'
{}
'
branch.
"
.
format
(
name
))
self
.
_usr_names
=
[]
else
:
self
.
_usr_idx_lookup
=
{
...
...
This diff is collapsed.
Click to expand it.
tests/test_offline.py
+
6
−
39
View file @
578d908e
...
...
@@ -173,53 +173,20 @@ class TestOfflineHits(unittest.TestCase):
class
TestOfflineTracks
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
tracks
=
OFFLINE_FILE
.
events
.
tracks
self
.
r_mc
=
OFFLINE_NUMUCC
self
.
Nevents
=
10
self
.
tracks_numucc
=
OFFLINE_NUMUCC
self
.
n_events
=
10
def
test_attributes_available
(
self
):
for
key
in
self
.
tracks
.
_keymap
.
keys
():
getattr
(
self
.
tracks
,
key
)
@unittest.skip
def
test_item_selection
(
self
):
self
.
assertListEqual
(
list
(
self
.
tracks
[
0
].
dir_z
[:
2
]),
[
-
0.872885221293917
,
-
0.872885221293917
])
@unittest.skip
def
test_IndexError
(
self
):
# test handling IndexError with empty lists/arrays
self
.
assertEqual
(
len
(
OfflineTracks
([
'
whatever
'
],
[])),
0
)
@unittest.skip
def
test_repr
(
self
):
assert
"
10
"
in
repr
(
self
.
tracks
)
@unittest.skip
def
test_str
(
self
):
assert
str
(
self
.
tracks
).
endswith
(
"
10
"
)
@unittest.skip
def
test_reading_tracks_dir_z
(
self
):
dir_z
=
self
.
tracks
.
dir_z
tracks_dir_z
=
{
0
:
56
,
1
:
55
,
8
:
54
}
for
track_id
,
n_dir
in
tracks_dir_z
.
items
():
self
.
assertEqual
(
n_dir
,
len
(
dir_z
[
track_id
]))
# check that there are 10 arrays of tracks.dir_z info
self
.
assertEqual
(
len
(
dir_z
),
self
.
Nevents
)
@unittest.skip
def
test_reading_mc_tracks_dir_z
(
self
):
dir_z
=
self
.
r_mc
.
mc_tracks
.
dir_z
tracks_dir_z
=
{
0
:
11
,
1
:
25
,
8
:
13
}
for
track_id
,
n_dir
in
tracks_dir_z
.
items
():
self
.
assertEqual
(
n_dir
,
len
(
dir_z
[
track_id
]))
# check that there are 10 arrays of tracks.dir_z info
self
.
assertEqual
(
len
(
dir_z
),
self
.
Nevents
)
self
.
assertListEqual
([
0.230189
,
0.230189
,
0.218663
],
list
(
dir_z
[
0
][:
3
]))
@unittest.skip
def
test_slicing
(
self
):
tracks
=
self
.
tracks
assert
10
==
len
(
tracks
)
...
...
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