iris-hep / func_adl

Construct hierarchical data queries using SQL-like concepts in python
MIT License
7 stars 4 forks source link

Specify leaves programtically #124

Open gordonwatts opened 1 year ago

gordonwatts commented 1 year ago

This was brought up in an iris-hep slack conversation by @alexander-held :

Is there a built-in way to do a shorthand if I want to Select a ton of columns at the same time and they relate in a straightforward way to my input file? Imagine something like this

Select(lambda e: {"el_pt": e.el_pt, "el_eta": e.el_eta, "el_phi": e.el_phi, ...})

which might keep going for another few tens of columns. I haven’t tried it, but perhaps some kind of

lambda e: {branch: getattr(e, branch) for branch in ["el_pt", "el_eta", "el_phi"]}

construction could do that? And if so, would it perhaps make sense to streamline this into something convenient?