scikit-hep / uproot5

ROOT I/O in pure Python and NumPy.
https://uproot.readthedocs.io
BSD 3-Clause "New" or "Revised" License
238 stars 77 forks source link

`'Model_ROOT_3a3a_Experimental_3a3a_RNTuple' object is not subscriptable` error while accessing event keys #1260

Open giedrius2020 opened 3 months ago

giedrius2020 commented 3 months ago

Uproot version: 5.3.10

We compared data loading for TTree and RNTuple structures.

We tried to use method:

# Loading the file:
with uproot.open(file) as f: # Remote TTree
    events = f["Events"]
# Getting array:
array = events["Electron_pt"].array()

Accessing "Electron_pt" key worked with TTree, but did not work with RNTuple. In RNTuple case we got this error: 'Model_ROOT_3a3a_Experimental_3a3a_RNTuple' object is not subscriptable

For now as a workaround we used this approach: events.arrays()["Electron_pt"], (NOTE: this approach is really slow when used with TTree).

If possible, we would like to :

giedrius2020 commented 3 months ago

Tags: @davidlange6, @ariostas

alexander-held commented 3 months ago

Does events.arrays(["Electron_pt"])["Electron_pt"] work? I imagine events.arrays()["Electron_pt"] is slow because it will read the full file.

giedrius2020 commented 3 months ago

Does events.arrays(["Electron_pt"])["Electron_pt"] work? I imagine events.arrays()["Electron_pt"] is slow because it will read the full file.

I checked it. Yes it works and is way faster. Thanks, I will use this approach for loading from now.