iris-hep / func_adl_xAOD

Client interface to send a hierarchical SQL-like query to an xAOD backend
0 stars 5 forks source link

`First` needs to work with nested loops #226

Closed gordonwatts closed 4 months ago

gordonwatts commented 4 months ago

Fixes loops that occur after a .First() predicate. The below code now works.

We also normalized how we fetch the scope when accessing and filling the ntuple. This could introduce a bug, as it isn't clear how this should work in all contexts yet. Need a test to fail!

Fixes #225

pv_query = (
    ds
    .Select(lambda e: e.Vertices("PrimaryVertices"))
    .Select(lambda vtx: vtx.First())
)

track_query = (
    pv_query
    .Select(lambda v: v.trackParticleLinks().Where(lambda t: t.pt() > 500.0))
    .Select(lambda tracks: {
        "pt": tracks.Select(lambda t: t.pt()),
        "eta": tracks.Select(lambda t: t.eta()),
        "phi": tracks.Select(lambda t: t.phi()),
    })
)

tracks= track_query.AsAwkwardArray().value()
codecov[bot] commented 4 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 95.05%. Comparing base (7a7f9e4) to head (bd496c8).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #226 +/- ## ========================================== - Coverage 95.05% 95.05% -0.01% ========================================== Files 35 35 Lines 2003 2002 -1 Branches 265 265 ========================================== - Hits 1904 1903 -1 Misses 64 64 Partials 35 35 ``` | [Flag](https://app.codecov.io/gh/iris-hep/func_adl_xAOD/pull/226/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=iris-hep) | Coverage Δ | | |---|---|---| | [unittests](https://app.codecov.io/gh/iris-hep/func_adl_xAOD/pull/226/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=iris-hep) | `95.05% <100.00%> (-0.01%)` | :arrow_down: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=iris-hep#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.