How does @interact work in Sage 7.3 Jupiter notebook?

63 views
Skip to first unread message

ahaus...@umassd.edu

unread,
Sep 12, 2016, 9:36:19 PM9/12/16
to sage-support
Hi,

the Interact command does not seem to be working in Sage 7.3 Jupyer Notebook!


Here is the code from a notebook cell:
-----------------------------------------------------------------
from ipywidgets import interact, interactive, fixed
import ipywidgets as widgets


def plotNthRoots(n):
    # Create a unit circle
    c = circle((0,0), radius=1, rgbcolor=(1,0,0))
    # Combine the circle with points on the circle representing the roots of unity
    theta = 2.0*pi/float(n)
    p = c + point([(cos(t), sin(t)) for t in srange(0, 2.0*pi, theta)],frame=True,size=60)
    # Add in vectors from the origin to the roots of unity.
    p = p + sum([arrow2d( (0,0), (cos(t),sin(t)) ) for t in srange(0, 2.0*pi, theta)])
    show(p)
    print("The Principle %d-Root: (%5.3f)+(%5.3f)I"%(n,cos(theta), sin(theta)) )

    
@interact
def _(n=(1,20)):
    plotNthRoots(n)
---------------------------------------------------------

Rather than creating a slider, it generates a plot for the case n=20.

Any suggestions?

Adam Hausknecht

Emmanuel Charpentier

unread,
Sep 20, 2016, 10:15:50 AM9/20/16
to sage-support
This post might help... Note that this solution is different of Sage's (@)interact function(s).

HTH,

--
Emmanuel Charpentier
Reply all
Reply to author
Forward
0 new messages