You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be nice to use more python idioms in func_adl. A complete set in python 3.10.2 can be found here. A lot of them (filter, map, etc.) could be useful. A stretch goal would be enumerate which would allow you to do object pairing when you had a symmetric pairing function. This last perhaps does not belong here as it will require backend modifications.
The text was updated successfully, but these errors were encountered:
Another useful feature would be support for list comprehensions. When Selecting many columns without the need to change names, there is a risk for typos (and lots of duplicate text) that could be avoided in that manner.
fromfunc_adl_uprootimportUprootDatasetdataset_opendata="https://xrootd-local.unl.edu:1094//store/user/AGC/nanoAOD/TT_TuneCUETP8M1_13TeV-powheg-pythia8/"\
"cmsopendata2015_ttbar_19980_PU25nsData2015v1_76X_mcRun2_asymptotic_v12_ext3-v1_00000_0000.root"ds=UprootDataset(dataset_opendata, "Events")
# jet_query = ds.Select(lambda e: {"jet_pt": e["Jet_pt"], "jet_eta": e.Jet_eta}) # this worksjet_query=ds.Select(lambdae: {branch: getattr(e, branch) forbranchin ["Jet_pt", "Jet_eta"]}) # does not work# jet_query = ds.Select("lambda e: {" + ",".join(f"{repr(branch)}: e[{repr(branch)}]" for branch in ["Jet_pt", "Jet_eta"]) + "}") # works via stringsprint(jet_query.value())
The example above result in NameError: Unknown id: branch. @masonproffitt suggested the string-based approach as a workaround, which does work, but suffers from not being too readable (and no syntax highlighting in strings). Instead of getattr, another way to do this would be e[branch], but runs into the same problem.
I am not sure if there is any way to make this work with func_adl.func_adl_callable instead.
It would be nice to use more python idioms in
func_adl
. A complete set in python 3.10.2 can be found here. A lot of them (filter
,map
, etc.) could be useful. A stretch goal would beenumerate
which would allow you to do object pairing when you had a symmetric pairing function. This last perhaps does not belong here as it will require backend modifications.The text was updated successfully, but these errors were encountered: