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
6f08c38b
Commit
6f08c38b
authored
4 years ago
by
Zineb Aly
Browse files
Options
Downloads
Patches
Plain Diff
debug fitinf + tests
parent
dab68908
No related branches found
No related tags found
No related merge requests found
Pipeline
#14992
passed with warnings
4 years ago
Stage: test
Stage: coverage
Stage: doc
Stage: release
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
km3io/tools.py
+14
-6
14 additions, 6 deletions
km3io/tools.py
tests/test_tools.py
+12
-5
12 additions, 5 deletions
tests/test_tools.py
with
26 additions
and
11 deletions
km3io/tools.py
+
14
−
6
View file @
6f08c38b
...
@@ -145,14 +145,22 @@ def fitinf(fitparam, tracks):
...
@@ -145,14 +145,22 @@ def fitinf(fitparam, tracks):
"""
"""
fit
=
tracks
.
fitinf
fit
=
tracks
.
fitinf
index
=
fitparam
index
=
fitparam
try
:
if
tracks
.
is_single
and
len
(
tracks
)
!=
1
:
params
=
fit
[
count_nested
(
fit
,
axis
=
2
)
>
index
]
return
ak1
.
Array
([
i
[:,
index
]
for
i
in
params
])
except
ValueError
:
# This is the case for tracks[:, 0] or any other selection.
params
=
fit
[
count_nested
(
fit
,
axis
=
1
)
>
index
]
params
=
fit
[
count_nested
(
fit
,
axis
=
1
)
>
index
]
return
params
[:,
index
]
out
=
params
[:,
index
]
if
tracks
.
is_single
and
len
(
tracks
)
==
1
:
out
=
fit
[
index
]
else
:
if
len
(
tracks
[
0
])
==
1
:
# case of tracks slice with 1 track per event.
params
=
fit
[
count_nested
(
fit
,
axis
=
1
)
>
index
]
out
=
params
[:,
index
]
else
:
params
=
fit
[
count_nested
(
fit
,
axis
=
2
)
>
index
]
out
=
ak1
.
Array
([
i
[:,
index
]
for
i
in
params
])
return
out
def
count_nested
(
arr
,
axis
=
0
):
def
count_nested
(
arr
,
axis
=
0
):
"""
Count elements in a nested awkward Array.
"""
Count elements in a nested awkward Array.
...
...
This diff is collapsed.
Click to expand it.
tests/test_tools.py
+
12
−
5
View file @
6f08c38b
...
@@ -39,17 +39,24 @@ class TestFitinf(unittest.TestCase):
...
@@ -39,17 +39,24 @@ class TestFitinf(unittest.TestCase):
self
.
best
=
self
.
tracks
[:,
0
]
self
.
best
=
self
.
tracks
[:,
0
]
self
.
best_fit
=
self
.
best
.
fitinf
self
.
best_fit
=
self
.
best
.
fitinf
def
test_fitinf
(
self
):
def
test_fitinf
_from_all_events
(
self
):
beta
=
fitinf
(
kfit
.
JGANDALF_BETA0_RAD
,
self
.
tracks
)
beta
=
fitinf
(
kfit
.
JGANDALF_BETA0_RAD
,
self
.
tracks
)
best_beta
=
fitinf
(
kfit
.
JGANDALF_BETA0_RAD
,
self
.
best
)
assert
beta
[
0
][
0
]
==
self
.
fit
[
0
][
0
][
0
]
assert
beta
[
0
][
0
]
==
self
.
fit
[
0
][
0
][
0
]
assert
beta
[
0
][
1
]
==
self
.
fit
[
0
][
1
][
0
]
assert
beta
[
0
][
1
]
==
self
.
fit
[
0
][
1
][
0
]
assert
beta
[
0
][
2
]
==
self
.
fit
[
0
][
2
][
0
]
assert
beta
[
0
][
2
]
==
self
.
fit
[
0
][
2
][
0
]
assert
best_beta
[
0
]
==
self
.
best_fit
[
0
][
0
]
def
test_fitinf_from_one_event
(
self
):
assert
best_beta
[
1
]
==
self
.
best_fit
[
1
][
0
]
beta
=
fitinf
(
kfit
.
JGANDALF_BETA0_RAD
,
self
.
best
)
assert
best_beta
[
2
]
==
self
.
best_fit
[
2
][
0
]
assert
beta
[
0
]
==
self
.
best_fit
[
0
][
0
]
assert
beta
[
1
]
==
self
.
best_fit
[
1
][
0
]
assert
beta
[
2
]
==
self
.
best_fit
[
2
][
0
]
def
test_fitinf_from_one_event_and_one_track
(
self
):
beta
=
fitinf
(
kfit
.
JGANDALF_BETA0_RAD
,
self
.
tracks
[
0
][
0
])
assert
beta
==
self
.
tracks
[
0
][
0
].
fitinf
[
0
]
class
TestBestTrackSelection
(
unittest
.
TestCase
):
class
TestBestTrackSelection
(
unittest
.
TestCase
):
...
...
This diff is collapsed.
Click to expand it.
Zineb Aly
@zaly
mentioned in issue
#67 (closed)
·
4 years ago
mentioned in issue
#67 (closed)
mentioned in issue #67
Toggle commit list
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