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
1ca7ac06
Commit
1ca7ac06
authored
5 years ago
by
Zineb Aly
Browse files
Options
Downloads
Patches
Plain Diff
add tests with 100% conv
parent
c400a3e5
No related branches found
No related tags found
1 merge request
!8
outsource reconstruction data in separate arrays
Pipeline
#8133
passed with warnings
5 years ago
Stage: test
Stage: coverage
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
km3io/offline.py
+6
-5
6 additions, 5 deletions
km3io/offline.py
tests/test_offline.py
+53
-8
53 additions, 8 deletions
tests/test_offline.py
with
59 additions
and
13 deletions
km3io/offline.py
+
6
−
5
View file @
1ca7ac06
...
...
@@ -179,7 +179,7 @@ class OfflineKeys:
'
JSTART_NPE_MIP
'
,
'
JSTART_NPE_MIP_TOTAL
'
,
'
JSTART_LENGTH_METRES
'
,
'
JVETO_NPE
'
,
'
JVETO_NUMBER_OF_HITS
'
,
'
JENERGY_MUON_RANGE_METRES
'
,
'
JENERGY_NOISE_LIKELIHOOD
'
,
'
JENERGY_NDF
'
,
'
JENERGY_NUMBER_OF_HITS
'
]
#
'JCOPY_Z_M'
not anymore in Jpp
'
JENERGY_NDF
'
,
'
JENERGY_NUMBER_OF_HITS
'
,
'
JCOPY_Z_M
'
]
return
self
.
_fit_keys
@property
...
...
@@ -432,7 +432,7 @@ class OfflineReader:
a recarray of the best track fit data (reconstruction data).
"""
if
self
.
_best_reco
is
None
:
keys
=
"
,
"
.
join
(
self
.
keys
.
fit_keys
)
keys
=
"
,
"
.
join
(
self
.
keys
.
fit_keys
[:
-
1
]
)
empty_fit_info
=
np
.
array
([
match
for
match
in
self
.
_find_empty
(
self
.
tracks
.
fitinf
)])
fit_info
=
[
i
for
i
,
j
in
zip
(
self
.
tracks
.
fitinf
,
...
...
@@ -495,7 +495,7 @@ class OfflineReader:
ValueError raised when the reconstruction stages of interest
are not found in the file.
"""
keys
=
"
,
"
.
join
(
self
.
keys
.
fit_keys
)
keys
=
"
,
"
.
join
(
self
.
keys
.
fit_keys
[:
-
1
]
)
fit_info
=
self
.
tracks
.
fitinf
rec_stages
=
np
.
array
([
match
for
match
in
self
.
_find_rec_stages
(
stages
)])
...
...
@@ -520,7 +520,7 @@ class OfflineReader:
list of reconstruction stages of interest. for example
[1, 2, 3, 4, 5].
Yields
Yields
ma
------
generator
the track id and the index of the reconstruction stages of
...
...
@@ -544,7 +544,8 @@ class OfflineReader:
Parameters
----------
chunk_arr : Chunked array
Chunked array or jagged array of data of interest.
Chunked array or jagged array of data of interest. For example:
km3io.OfflineReader(my_file).tracks.fitinf .
Yields
------
...
...
This diff is collapsed.
Click to expand it.
tests/test_offline.py
+
53
−
8
View file @
1ca7ac06
import
unittest
import
numpy
as
np
from
pathlib
import
Path
from
km3io.offline
import
Reader
,
OfflineEvents
,
OfflineHits
,
OfflineTracks
...
...
@@ -115,6 +116,7 @@ class TestReader(unittest.TestCase):
class
TestOfflineReader
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
r
=
OfflineReader
(
OFFLINE_FILE
)
self
.
nu
=
OfflineReader
(
OFFLINE_NUMUCC
)
self
.
Nevents
=
10
self
.
selected_data
=
OfflineReader
(
OFFLINE_FILE
,
data
=
self
.
r
.
_data
[
0
]).
_data
...
...
@@ -132,6 +134,57 @@ class TestOfflineReader(unittest.TestCase):
# check that there are 10 events
self
.
assertEqual
(
Nevents
,
self
.
Nevents
)
def
test_find_empty
(
self
):
fitinf
=
self
.
nu
.
tracks
.
fitinf
rec_stages
=
self
.
nu
.
tracks
.
rec_stages
empty_fitinf
=
np
.
array
([
match
for
match
in
self
.
nu
.
_find_empty
(
fitinf
)])
empty_stages
=
np
.
array
([
match
for
match
in
self
.
nu
.
_find_empty
(
rec_stages
)])
self
.
assertListEqual
(
empty_fitinf
[:
5
,
1
].
tolist
(),
[
23
,
14
,
14
,
4
,
None
])
self
.
assertListEqual
(
empty_stages
[:
5
,
1
].
tolist
(),
[
False
,
False
,
False
,
False
,
None
])
def
test_find_rec_stages
(
self
):
stages
=
np
.
array
([
match
for
match
in
self
.
nu
.
_find_rec_stages
([
1
,
2
,
3
,
4
,
5
])])
self
.
assertListEqual
(
stages
[:
5
,
1
].
tolist
(),
[
0
,
0
,
0
,
0
,
None
])
def
test_get_reco_fit
(
self
):
JGANDALF_BETA0_RAD
=
[
0.0020367251782607574
,
0.003306725805622178
,
0.0057877124222254885
,
0.015581698352185896
]
reco_fit
=
self
.
nu
.
get_reco_fit
([
1
,
2
,
3
,
4
,
5
])[
'
JGANDALF_BETA0_RAD
'
]
self
.
assertListEqual
(
JGANDALF_BETA0_RAD
,
reco_fit
[:
4
].
tolist
())
with
self
.
assertRaises
(
ValueError
):
self
.
nu
.
get_reco_fit
([
1000
,
4512
,
5625
])
def
test_get_max_reco_stages
(
self
):
rec_stages
=
self
.
nu
.
tracks
.
rec_stages
max_reco
=
self
.
nu
.
_get_max_reco_stages
(
rec_stages
)
self
.
assertEqual
(
len
(
max_reco
.
tolist
()),
9
)
self
.
assertListEqual
(
max_reco
[
0
].
tolist
(),
[[
1
,
2
,
3
,
4
,
5
],
5
,
0
])
def
test_best_reco
(
self
):
JGANDALF_BETA1_RAD
=
[
0.0014177681261476852
,
0.002094094517471032
,
0.003923368624980349
,
0.009491461076780453
]
best
=
self
.
nu
.
best_reco
self
.
assertEqual
(
best
.
size
,
9
)
self
.
assertEqual
(
best
[
'
JGANDALF_BETA1_RAD
'
][:
4
].
tolist
(),
JGANDALF_BETA1_RAD
)
class
TestOfflineEvents
(
unittest
.
TestCase
):
def
setUp
(
self
):
...
...
@@ -325,14 +378,6 @@ class TestOfflineTracks(unittest.TestCase):
list
(
tracks
[
_slice
].
E
[:,
0
])
)
def
test_reco_data
(
self
):
reco
=
self
.
tracks
.
reco
self
.
assertEqual
(
10
,
reco
.
size
)
E
=
reco
[
'
JENERGY_ENERGY
'
]
self
.
assertListEqual
([
99.10458562488608
,
99.10458562488608
,
99.10458562488608
],
E
[:
3
].
tolist
())
class
TestOfflineTrack
(
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