Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def apply_global_index(index, target):
def flat_take(layout):
idx = awkward1.Array(layout)
return target._content()[idx.mask[idx >= 0]]
def descend(layout, depth):
if layout.purelist_depth == 1:
return lambda: flat_take(layout)
(index,) = awkward1.broadcast_arrays(index)
out = awkward1._util.recursively_apply(index.layout, descend)
return awkward1._util.wrap(out, target.behavior)
def _getlistarray(self):
"""Do some digging to find the initial listarray"""
def descend(layout, depth):
islistarray = isinstance(
layout,
(awkward1.layout.ListOffsetArray32, awkward1.layout.ListOffsetArray64,),
)
if islistarray and layout.content.parameter("collection_name") is not None:
return lambda: layout
return awkward1._util.recursively_apply(self.layout, descend)