Add gallery of example analysis methods and plots
For the future, maybe a small gallery of typical analyses you might do with pyhf as a toolbar: clicking on an image of a Brazil band plot fills and evaluates a code cell that makes the Brazil band plot, which the user can then interact with in subsequent evaluations? pyhf needs data to be useful: there should be exploratory-clickable ways of inserting data to play with.
Originally posted by @jpivarski in https://github.com/scikit-hep/pyhf/issues/1820#issuecomment-1077900921
This is probably also a good idea for cabintery as well. Once we get something that looks nice we could make it easier for Alex to port over.
Actually, I just noticed that this page has examples on it with discussion around each. A more organic way to add this feature (than a gallery/toolbar) would be for each of those examples to have a prominent "Try it out!" button that loads the example into the JupyterLite and scrolls to it.
If you have this, then maybe you'd want to put the JupyterLite thing down on the bottom of the page, but still have "Try it out!" buttons that fill and scroll to it. The reason is because this JupyterLite thing, cool as it is, doesn't convey anything about pyhf until you have an example to put in it. Therefore, the pyhf examples should come first (sequentially and in priority) and just get this ability to interact with them as an add-on.
If you can make the widget appear in an expanding <div>, then you could even do it without scrolling (breaking the reader's place in the text). The "Try it out!" button would make the widget appear wherever they are, and it should be evident from the log that it's the same interactive session for all of the examples. (Important because you don't want to start loading it after they press "Try it out!")
I've been looking forward to this kind of thing for a long time. Here's an attempt from 2013:
http://augustusdocs.appspot.com/docs/v06/plotting/introduction.html
It worked a few years ago, but now something's broken. Maybe AppSpot doesn't support Python 2 anymore.
Yeah, at the moment we do have the examples tab in the docs. There are pre-rendered notebooks, but I agree that having the ability to run them in JupyterLite would be a much better scenario.
Actually, I was referring to the examples on the page itself:
All of the notebooks in the examples tab look too involved to be inserted into a JupyterLite cell—they're better as Binder because the reader has already committed to spending some time before looking at them.
The one-bin and two-bin examples are literally single cells (yellow blocks in the readthedocs), though the hello world looks like two cells ("basic inference" and "from JSON").
Actually, I was referring to the examples on the page itself:
Ah yeah. That would indeed be a good idea. I was thinking it would be nice if possible to do something similar with what I'm doing with the RST injection in PR #1820 to see if we can also get the ability to toggle between the static code example view and the JupyterLite interactive view with sphinx-togglebutton like they demo here in the docs.
This would be in addition to a gallery view or something.
All of the notebooks in the examples tab look too involved to be inserted into a JupyterLite cell—they're better as Binder because the reader has already committed to spending some time before looking at them.
The one-bin and two-bin examples are literally single cells (yellow blocks in the readthedocs), though the hello world looks like two cells ("basic inference" and "from JSON").
Yeah that makes sense. The "from JSON" example that you mention actually won't work until the next release of Pyodide, which should happen soon (c.f. https://github.com/scikit-hep/pyhf/issues/1775#issuecomment-1068530540).