default interact widget for single value

16 views
Skip to first unread message

kcrisman

unread,
Mar 29, 2022, 3:02:59 PM3/29/22
to sage-devel
Thanks to a lot of good work a few years back, we have fairly close alignment between historic @interact behavior on the Jupyter notebook (from ipywidgets) and the previous sagenb behavior.  Sage cell server and CoCalc Sage worksheets are very close indeed.

One fairly glaring difference I'm noting is the default for a single integer or real value.  In the past (and on Sage cell) this would uniformly give a text box which would allow for the user to input different values - not a slider or drop-down list, for which we have other syntax.  See https://sagecell.sagemath.org/?z=eJxzyMwrSS1KTC7h5UpJTVOI10i0NdW04uVSAILijPxyjcQ4I00A0wwKWA==&lang=sage&interacts=eJyLjgUAARUAuQ==

However, at the time that support was given to have single objects like matrices and colors (again, awesome!), apparently this fell through the cracks.  At https://github.com/sagemath/sage/blob/develop/src/sage/repl/ipython_kernel/interact.py#L150 after those cases are handled, then they are sent to ipywidget defaults, which are pretty ad-hoc - see this, which has things like 
        elif value > 0:
            vrange = (-value, 3*value)
        else:
            vrange = (3*value, -value)

I think it would be pretty easy to restore previous behavior by simply removing the attempt at existing ipywidgets here.  However, it's probably been long enough now that there are too many different implementations to do so without at least asking on sage-devel.  I would definitely be in favor of making the behavior as similar on all outputs as possible (note: I have not used Jupyterlab yet, so I haven't a clue what will happen there, hopefully same as Jupyter proper w/ipywidgets).  I probably could even dust off my git skillz enough to send a branch to Trac.  

Any thoughts, including from Andrey and/or William as caretakers of Sage cell and CoCalc implementations, would be most welcome.  Thanks!
- crisman
Reply all
Reply to author
Forward
0 new messages