scikit-hep / uproot-browser

A TUI viewer for ROOT files
BSD 3-Clause "New" or "Revised" License
70 stars 7 forks source link

fix: Note branch empty on panel instead of traceback #82

Closed matthewfeickert closed 1 year ago

matthewfeickert commented 1 year ago

Resolves #53.

In the event that a branch is empty, instead of catching the Exception and displaying the frames in the panel, raise a ValueError and catch that to display in the panel that the branch is 'EMPTY'.

Before

uproot-browser browse /tmp/data_A.2lep.root

When opening a branch that is empty get a traceback from the caught exception.

before

After

uproot-browser browse /tmp/data_A.2lep.root

When opening a branch that is empty get text of "{branch name} is EMPTY" (e.g. "largeRjet_D2 is EMPTY").

after

matthewfeickert commented 1 year ago

Hm @amangoel185 I'm seeing different behavior than you (the opposite actually). For my "*before" I'm using my pipx install

$ pipx upgrade uproot-browser
uproot-browser is already at latest version 0.4.0 (location: /home/feickert/.local/pipx/venvs/uproot-browser)
$ /home/feickert/.local/pipx/venvs/uproot-browser/bin/uproot-browser browse ~/.local/skhepdata/uproot-Event.root

and getting a ValueError: range of axis is zero being raised from NumPy for your fBits example.

before-ValueError

My "after" is my local build

$ python -m pip install --upgrade -e .
$ pyenv which uproot-browser
/home/feickert/.pyenv/versions/uproot-browser-dev/bin/uproot-browser
$ uproot-browser browse ~/.local/skhepdata/uproot-Event.root

which is actually showing a plot for fBits

fBits-after

amangoel185 commented 1 year ago

Ah curious, I think it was the cached dependencies. I built it from scratch and now it's working!

henryiii commented 1 year ago

Thanks!