iris-hep / func_adl_uproot

Uproot-based backend for FuncADL
MIT License
0 stars 0 forks source link

Integer indexing in query operators should not be by row/event #27

Closed masonproffitt closed 3 years ago

masonproffitt commented 4 years ago

If you do something like .Select(lambda row: [row.column_a, row.column_b]).Select(lambda row: [row[0], row[1]]), the second Select should effectively be an identity operation, but right now it will actually pick out the first two rows/events instead of the two columns.

gordonwatts commented 3 years ago

I have some code that will go through and do its best to unwrap all tuple operations (and I think list operations, but it would be an easy modification). It also does things like try to combine multiple Selects, push Where's together. It operates only at the ast level.

In this case- it would take the above code and remove the second Select, and then resolve the index operations on the first - so by the time your translation code got to it, it wouldn't have to deal with that case.

You can find it in the func_adl.ast package.

One thing I really want to add there is something similar for dictionaries (that you already have at some level in your code).