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
4d80f759
Commit
4d80f759
authored
5 months ago
by
Tamas Gal
Browse files
Options
Downloads
Plain Diff
Merge branch 'improve_ak.Record_indexing' into 'master'
Improve ak.record indexing See merge request
!88
parents
eefed662
2fc5789d
No related branches found
Branches containing commit
Tags
v1.2.3
Tags containing commit
1 merge request
!88
Improve ak.record indexing
Pipeline
#62151
passed
3 weeks ago
Stage: test
Stage: coverage
Stage: doc
Changes
1
Pipelines
146
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/km3io/tools.py
+13
-2
13 additions, 2 deletions
src/km3io/tools.py
with
13 additions
and
2 deletions
src/km3io/tools.py
+
13
−
2
View file @
4d80f759
...
...
@@ -263,8 +263,7 @@ def best_track(tracks, startend=None, minmax=None, stages=None):
out
=
apply_mask
(
tracks
,
m3
)
if
original_ndim
==
1
:
if
isinstance
(
out
,
ak
.
Record
):
first_and_only_element_mask
=
ak
.
Array
([
True
])
return
apply_mask
(
out
,
first_and_only_element_mask
)
return
select_first_entry_from_record
(
out
)
return
out
[
0
]
return
out
[:,
0
]
...
...
@@ -280,6 +279,18 @@ def apply_mask(record, mask):
return
record
[
mask
]
def
select_first_entry_from_record
(
record
):
assert
isinstance
(
record
,
ak
.
Record
),
f
"
Input has to be ak.Record, but is
{
type
(
record
)
}
"
first_entry_data
=
{}
for
field
in
record
.
fields
:
value
=
record
[
field
]
first_entry_data
[
field
]
=
value
[
0
]
return
ak
.
Record
(
first_entry_data
)
def
mask
(
arr
,
sequence
=
None
,
startend
=
None
,
minmax
=
None
,
atleast
=
None
):
"""
Return a boolean mask which mask each nested sub-array for a condition.
...
...
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