Interact slider with values vmin=0 vmax=2, stepsize=1 seems to have problems

57 views
Skip to first unread message

Nils Bruin

unread,
Jul 27, 2012, 4:39:18 PM7/27/12
to sage-devel
I ran into this when trying to use the amazing debug() in the sage
notebook on a particularly shallow traceback. However, the problem
seems to be for interact sliders in general. This is on sage 5.0
notebook using Firefox 13.0 (the present standard with Fedora 16). It
may be browser dependent, but I don't know.

With the following fragment:

N=2
@interact
def F(frame = slider(vmin=0, vmax=N, step_size=1, default=1,
label='stack frame')):
pass

I'm unable to select "frame=1". Only "frame=0" and "frame=2" work. If
I increase N, things work as expected as far as I've tested.

If this a problem in firefox's javascript? Does it occur on other
browsers? Does someone know a workaround?

Cheers,

Nils

Nils Bruin

unread,
Jul 27, 2012, 5:01:02 PM7/27/12
to sage-devel
OK, I figured it out myself. It is indeed a problem in how sliders are
defined. See

devel/sagenb/sagenb/notebook/interact.py line 3078

if num_steps <= 2:
vals = [self.__vmin, self.__vmax]
else:
vals = srange(self.__vmin, self.__vmax,
self.__step_size, include_endpoint=True)

The include_endpoint suggests that this should be " num_steps <= 1 ".
I don't know how to submit patches to sagenb, so can someone please
format an appropriate patch?

In addition, we could save some work by giving "debug" immediately a
list of integers, avoiding dodgy float operations to compute num_steps
(things being integers):

devel/sage/sage/interacts/debugger.py line 226

def dbg(frame = slider(range(len(self._stack)-1-4),
default=len(self._stack)-1-5, label='stack frame'),
lines = slider(range(3,100,2), default=11, label='lines of
context'),
command = input_box("", label="", type=str),
button = selector(['Evaluate'], label='', buttons=True)

so give ranges right away rather than vmin,vmax,step_size

Jason Grout

unread,
Jul 27, 2012, 11:45:05 PM7/27/12
to sage-...@googlegroups.com
Indeed, that fix seems to work on aleph (I just pushed your fix [1])

To format a "patch", log into github, go to the file:
https://github.com/sagemath/sagenb/blob/master/sagenb/notebook/interact.py

Click on "edit in the upper right of the file listing

Make the change in the browser editor, then click "Submit pull request"

Thanks for tracking this down!

Jason



Nils Bruin

unread,
Jul 28, 2012, 4:53:31 PM7/28/12
to sage-devel
On Jul 27, 8:45 pm, Jason Grout <jason-s...@creativetrax.com> wrote:
> To format a "patch", log into github, go to the file:https://github.com/sagemath/sagenb/blob/master/sagenb/notebook/intera...
>
> Click on "edit in the upper right of the file listing
>
> Make the change in the browser editor, then click "Submit pull request"

Thanks! The amazing thing is that you describe the full process! I
didn't use github before. Sage's trac submission process is a long
string of tedium interspersed with boredom and administrative red tape
by comparison (especially for a 1 character patch).

Keshav Kini

unread,
Jul 28, 2012, 7:49:38 PM7/28/12
to sage-...@googlegroups.com
Yup, that's a really nice thing about github's online editor. It's great
for typo fixes and other trivial edits.

Of course, if your patch was a bit more complicated, or touched multiple
files, you'd have needed to do a bit more footwork - forking the
repository on github, cloning your fork to your local computer,
committing your changes, pushing them to a branch on your github fork,
and then creating a pull request from your fork's new branch to the
sagemath user's fork's master branch.

So, not that much easier than Sage's trac submission process on first
glance, though IMO once you get used to it it's really nice to not have
to deal with patch files bitrotting and such.

-Keshav

----
Join us in #sagemath on irc.freenode.net !

Reply all
Reply to author
Forward
0 new messages