Skip to content
Snippets Groups Projects
Commit 97e65a40 authored by Zineb Aly's avatar Zineb Aly
Browse files

move monkey patch to patches.py

parent bc847734
No related branches found
No related tags found
No related merge requests found
import numpy as np
import awkward as ak
import awkward1 as ak1
from pkg_resources import get_distribution, DistributionNotFound
version = get_distribution(__name__).version
......@@ -9,18 +5,4 @@ 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
from . import patches
import awkward as ak
import awkward1 as ak1
# 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
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment