@interact

52 views
Skip to first unread message

William Stein

unread,
Apr 26, 2019, 6:54:17 PM4/26/19
to sage-support
Hi,

I decided to try just a single random example of @interact in Jupyter
with the sage kernel, since I guess Jereon (?) built
an implementation of interact on top of ipywidgets, and I was
surprised that it failed pretty badly. If you give this as input,

@interact
def f(A = matrix([[1,1],[-1,1]])):
print(A)
print(type(A))

# the output is:
(1, 1)
<type 'sage.modules.vector_integer_dense.Vector_integer_dense'>

So it thinks that matrix is a vector...

I don't think ipywidgets even has a matrix input control, so I'm
curious what the plan was here? In any case, I guess @interact is
still maybe missing some things compared to what is in sagenb? I
couldn't find anything in trac about this.

-- William

https://trac.sagemath.org/search?q=%40interact+matrix+jupyter


--
William (http://wstein.org)

Kwankyu

unread,
Apr 27, 2019, 4:31:51 AM4/27/19
to sage-support
This gets a grid input in Jupyter. Is this close to what you want?

@interact
def _(A=input_grid(2,2, default=[[1,2],[3,4]])):
    A = matrix(A)
    print(A)

William

unread,
Apr 27, 2019, 1:15:20 PM4/27/19
to sage-support
Thanks!   I see Jereon also created https://trac.sagemath.org/ticket/27735

kcrisman

unread,
Apr 27, 2019, 2:51:04 PM4/27/19
to sage-support
Reply all
Reply to author
Forward
0 new messages