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
7fb23f0e
Commit
7fb23f0e
authored
4 years ago
by
Zineb Aly
Browse files
Options
Downloads
Patches
Plain Diff
monkey patch chunckedArray gititem
parent
fe189ffc
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
km3io/__init__.py
+19
-0
19 additions, 0 deletions
km3io/__init__.py
with
19 additions
and
0 deletions
km3io/__init__.py
+
19
−
0
View file @
7fb23f0e
import
numpy
as
np
import
awkward
as
ak
import
awkward1
as
ak1
from
pkg_resources
import
get_distribution
,
DistributionNotFound
version
=
get_distribution
(
__name__
).
version
...
...
@@ -5,3 +9,18 @@ version = get_distribution(__name__).version
from
.offline
import
OfflineReader
from
.online
import
OnlineReader
from
.gseagen
import
GSGReader
# to avoid infinite recursion
old_getitem
=
ak
.
ChunkedArray
.
__getitem__
def
new_getitem
(
self
,
item
):
"""
Monkey patch the getitem in awkward.ChunkedArray to apply
awkward1.Array masks on awkward.ChunkedArray
"""
if
isinstance
(
item
,
(
ak1
.
Array
,
ak
.
ChunkedArray
)):
return
ak1
.
Array
(
self
)[
item
]
else
:
return
old_getitem
(
self
,
item
)
ak
.
ChunkedArray
.
__getitem__
=
new_getitem
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