Skip to content

Correctly make Zip type following work #150

@gordonwatts

Description

@gordonwatts

The Zip predicate can be used in various places in an uproot call:

def test_dictionary_Zip_key():
    "Check that type follow from a dictionary through a Zip works"

    s = ast_lambda(
        """({
        'jet_pt':  e.Jets().Select(lambda j: j.pt()),
        'jet_eta': e.Jets().Select(lambda j: j.eta())}
        .Zip()
        .Select(lambda j: j.pt()))"""
    )
    objs = ObjectStream[Event](ast.Name(id="e", ctx=ast.Load()))

    new_objs, new_s, expr_type = remap_by_types(objs, "e", Event, s)

    assert expr_type == Any

Here it is taking a dictionary of two List[float]'s and turning it into a List[Dict[str, float]] - or, rather, internally, as the temp dataclass that a dict becomes.

The code for Zip to type follow should be added. It would have to be added in the process_method_call code, and probably some reasonably major surgery would be needed here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions