How to use the awkward1._util.recursively_apply function in awkward1

To help you get started, we’ve selected a few awkward1 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github CoffeaTeam / coffea / coffea / nanoevents / methods / util.py View on Github external
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)
github CoffeaTeam / coffea / coffea / nanoevents / methods / base.py View on Github external
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)