uproot-browser
uproot-browser copied to clipboard
Miscellaneous feedback
Firstly and most importantly, I love this! So much that I have a bunch of feedback 😅
At least some of these should probably be separate issues but with GitHub being down at the moment I've ended up with a single dump of thoughts.
Bugs and peculiarities
- [x] The footer shows
B Toggle sidebarandQ Quit. Seeing the uppercase makes me thing I should typeshit+B/shift+Qwhich doesn't work at all - [x] Up/down doesn't do anything after running
uproot-browser browse uproot-Event.root. It seems like I have to click on the sidebar before I can use the keyboard to navigate - [x] If I click on the plot I loose the ability to nagiviate with the keyboard again
- [ ] In the browser tracebacks don't show the actual error message if I try to plot something like
uproot-Event.root:event. I also think this should show a message like "Something went wrong, this probably means the branch's type isn't supported. If you think it should work the traceback below may hint at the cause of the problem." - [x]
--itermisn't usable with dark mode as the plot background is transparent making the black lines invisible
Features
- [ ] Add the ability to filter what is displayed in the sidebar
- [ ] Plot multiple variables on the same axis
- [ ] Apply cuts like
tree->Draw("MyVar", "PT>1000") - [ ] Set axis range/binning
- [ ] Draw expressions rather than just variables
- [ ] It would be amazing if
browsecould support--iterm - [x] Page up/down should jump a page's worth of entries when scrolling rather than just moving the view
Nice, thanks! The scrolling behavior (especially using the mouse after using the keyboard) is a bit weird too (also mentioned in #32). I'm not sure how to set / lock the focus to the tree view (currently the plot doesn't have any reason to be in focus). Tab to move focus would be nice.
I played with getting --iterm working in the browser - the main issue is I couldn't pipe through binary blobs to Rich/Textual, and everything I could find had to be str. It can be a preset-size, so I think it might work if I could do that. Not sure about the performance, and if iTerm would care about putting stuff around the inline image. @willmcgugan, is this something Rich/Textual possibly could support? I can open an issue if you think it's possible. I tried to implement this (and you can see the byte code sequence) in:
from __future__ import annotations
import io
import sys
import matplotlib.pyplot as plt
from base64 import b64encode
import rich.console
import rich.ansi
import rich.panel
from typing import Any
def imgcat(data: bytes, fn: bytes = b"plot.pdf", *, width: str | int = "auto", height: str | int = "auto") -> bytes:
"""Output the image data to the iTerm2 console."""
osc = b"\033]"
st = b"\a"
csi = b"\033["
buf = b""
buf += osc
dims = f"width={width};height={height}"
buf += b"1337;File=name=" + b64encode(fn)
buf += f";size={len(data)};inline=1;{dims}:".encode("utf-8")
buf += b64encode(data) + st
return buf
class Plot:
def __init__(self) -> None:
self.decoder = rich.ansi.AnsiDecoder()
def __rich_console__(
self, console: rich.console.Console, options: rich.console.ConsoleOptions
) -> rich.console.RenderResult:
width = options.max_width or console.width
height = options.height or console.height
plt.figure(figsize=(width,height))
plt.plot([1, 2])
plt.title("test")
buf = io.BytesIO()
plt.savefig(buf, format='png')
buf.seek(0)
canvas = imgcat(buf.read(), width=width, height=height)
yield canvas
rich.print(rich.panel.Panel(Plot(), height=20))
But this rich.errors.NotRenderableError, since bytes is not supported.
For some of the other features, I think we are waiting on more features in Textual, like text entry boxes. Though I've seen libraries that add widgets, and we could possibly use those (or make our own) if we are ready to add them before textual does. We plan to use the beautiful tabs feature to toggle several views, like plot, info, table.
In the browser tracebacks don't show the actual error message if I try to plot something like
uproot-Event.root:event. I also think this should show a message like "Something went wrong, this probably means the branch's type isn't supported. If you think it should work the traceback below may hint at the cause of the problem."
@chrisburr, could you confirm what did you try to plot? I believe uproot-Event.root:event does not exist. (Available keys: 'T;1', 'htime;1', 'hstat;1', 'ProcessID0;1')
Are you talking about the traceback under the browse command or the plot command?