Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Miscellaneous feedback #33

Open
5 of 12 tasks
chrisburr opened this issue Mar 17, 2022 · 3 comments
Open
5 of 12 tasks

Miscellaneous feedback #33

chrisburr opened this issue Mar 17, 2022 · 3 comments

Comments

@chrisburr
Copy link
Member

chrisburr commented Mar 17, 2022

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

  • The footer shows B Toggle sidebar and Q Quit. Seeing the uppercase makes me thing I should type shit+B/shift+Q which doesn't work at all
  • 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
  • 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."
  • --iterm isn'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 browse could support --iterm
  • Page up/down should jump a page's worth of entries when scrolling rather than just moving the view
@henryiii
Copy link
Member

henryiii commented Mar 17, 2022

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.

@henryiii
Copy link
Member

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.

@amangoel185
Copy link
Collaborator

amangoel185 commented Mar 19, 2022

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants