How do I use @interact with sage 8.0 jupyter notebook?

139 views
Skip to first unread message

Andy Howell

unread,
Oct 21, 2017, 11:18:41 PM10/21/17
to sage-support
I'm trying to learn how to use the @interact command.

The examples here: http://doc.sagemath.org/html/en/prep/Quickstarts/Interact.html do not work. I get a stack traces complaining about variable types etc.

Other examples I tried:


With that I get:

𝙸𝚗𝚝𝚎𝚛𝚊𝚌𝚝𝚒𝚟𝚎𝚏𝚞𝚗𝚌𝚝𝚒𝚘𝚗<𝚏𝚞𝚗𝚌𝚝𝚒𝚘𝚗𝚙𝚊𝚛𝚊𝚊𝚝𝟶𝚡𝟽𝚏𝚊𝚋𝟹𝟼𝚎𝟶𝟾𝚌𝚏𝟾>𝚠𝚒𝚝𝚑𝟻𝚠𝚒𝚍𝚐𝚎𝚝𝚜𝚗𝟷:𝙴𝚟𝚊𝚕𝚃𝚎𝚡𝚝(𝚟𝚊𝚕𝚞𝚎=𝚞'𝚂𝚕𝚒𝚍𝚎𝚛:𝙽𝚘𝚗𝚎[𝟷⎯⎯|𝟸|⎯⎯⎯𝟻]',𝚍𝚎𝚜𝚌𝚛𝚒𝚙𝚝𝚒𝚘𝚗=𝚞'𝚗𝟷')𝚗𝟸:𝙴𝚟𝚊𝚕𝚃𝚎𝚡𝚝(𝚟𝚊𝚕𝚞𝚎=𝚞'𝚂𝚕𝚒𝚍𝚎𝚛:𝙽𝚘𝚗𝚎[𝟷⎯⎯|𝟹|⎯⎯⎯𝟻]',𝚍𝚎𝚜𝚌𝚛𝚒𝚙𝚝𝚒𝚘𝚗=𝚞'𝚗𝟸')𝚊𝟷:𝙴𝚟𝚊𝚕𝚃𝚎𝚡𝚝(𝚟𝚊𝚕𝚞𝚎=𝚞'𝚂𝚕𝚒𝚍𝚎𝚛:𝙽𝚘𝚗𝚎[𝟷⎯⎯|𝟼/𝟻|⎯⎯⎯𝟷𝟶]',𝚍𝚎𝚜𝚌𝚛𝚒𝚙𝚝𝚒𝚘𝚗=𝚞'𝚊𝟷')𝚊𝟸:𝙴𝚟𝚊𝚕𝚃𝚎𝚡𝚝(𝚟𝚊𝚕𝚞𝚎=𝚞'𝚂𝚕𝚒𝚍𝚎𝚛:𝙽𝚘𝚗𝚎[𝟷⎯⎯|𝟼|⎯⎯⎯𝟷𝟶]',𝚍𝚎𝚜𝚌𝚛𝚒𝚙𝚝𝚒𝚘𝚗=𝚞'𝚊𝟸')𝚋:𝙴𝚟𝚊𝚕𝚃𝚎𝚡𝚝(𝚟𝚊𝚕𝚞𝚎=𝚞'𝚂𝚕𝚒𝚍𝚎𝚛:𝙽𝚘𝚗𝚎[𝟶⎯⎯|𝟶|⎯⎯⎯𝟸]',𝚍𝚎𝚜𝚌𝚛𝚒𝚙𝚝𝚒𝚘𝚗=𝚞'𝚋')

TypeError                                 Traceback (most recent call last)
<ipython-input-105-fc4092c2f8fe> in <module>()
      6     show(p, figsize = [Integer(5),Integer(5)], xmin = -Integer(2)-b, xmax = Integer(2)+b, ymin = -Integer(2)-b, ymax = Integer(2)+b, axes = False)
      7 
----> 8 para()

<ipython-input-105-fc4092c2f8fe> in para(n1, n2, a1, a2, b)
      2 def para(n1 = slider(Integer(1),Integer(5),Integer(1),default = Integer(2)), n2 = slider(Integer(1),Integer(5),Integer(1),default = Integer(3)), a1 = slider(Integer(1),Integer(10),Integer(1)/Integer(10),Integer(6)/Integer(5)), a2 = slider(Integer(1),Integer(10),Integer(1)/Integer(10),Integer(6)), b = slider(Integer(0),Integer(2),Integer(1)/Integer(50),Integer(0))):
      3     var('t')
----> 4     pretty_print(html('$r=' + latex(b+sin(a1*t)**n1 + cos(a2*t)**n2)+'$'))
      5     p = parametric_plot((cos(t)*(b+sin(a1*t)**n1 + cos(a2*t)**n2), sin(t)*(b+sin(a1*t)**n1 + cos(a2*t)**n2)), (t,Integer(0), Integer(20)*pi), plot_points = Integer(1024), rgbcolor = (Integer(0),Integer(0),Integer(0)))
      6     show(p, figsize = [Integer(5),Integer(5)], xmin = -Integer(2)-b, xmax = Integer(2)+b, ymin = -Integer(2)-b, ymax = Integer(2)+b, axes = False)

TypeError: unsupported operand type(s) for *: 'instance' and 'sage.symbolic.expression.Expression'

Any hints on how to make this work?

Thanks,

Andy

Henri Girard

unread,
Oct 22, 2017, 3:05:52 AM10/22/17
to sage-s...@googlegroups.com

I tried the web examples you show (only one per page) but everything works. I am with sagemath 8.1 beta8, I am not going to try all, but I think you have a problem with your sage installation, how did you get it ?

I am running xenial and I installed

sudo add-apt-repository ppa:chronitis/jupyter

To get all widgets, there though a problem because sagemath installation is 7.5.1, but as I said I compiled sage-develop version
regards
Henri
--
You received this message because you are subscribed to the Google Groups "sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sage-support...@googlegroups.com.
To post to this group, send email to sage-s...@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.

Andy Howell

unread,
Oct 22, 2017, 8:36:54 PM10/22/17
to sage-support
Henri,

I was running 8.0 from the tar file on sagemath downloads. Thinking that I may have messed up the notebook with previous commands, I restarted sage -n and tried the https://wiki.sagemath.org/interact/calculus#Some_polar_parametric_curves again. It did not work.

I checked out the development branch from git and built that. The example runs fine there. It looks like there is a bug in 8.0 that has since been fixed. I'll run the development version for now. Nothing I'm doing is critical. I'm re-learning the calculus I studied 35+ years ago, and exploring sage at the same time.

Thanks for your help,

Andy

kcrisman

unread,
Oct 23, 2017, 9:51:49 AM10/23/17
to sage-support
Dear Andy,
If you can reliably reproduce this in a more recent Sage version, please let us know.  We haven't had any other reports of this but there is always a possibility something went wrong.  Which exact tar did you downloads?
Thanks,
- kcrisman

Andy Howell

unread,
Oct 23, 2017, 10:35:26 AM10/23/17
to sage-support
Kcrisman,

I was having problems with the latest release: sage-8.0-Ubuntu_16.04-x86_64.tar.bz2. I verified the MD5 hash on it: 20d666b5284f1175b84ff5cb32e922eb

I grabbed it from:


If there is anything you would like me to try in 8.0 I'm happy do to it. Its possible there is something strange in my environment, though I don't think so. I simply untared it into a directory and made a symbolic link to the sage startup script. I just call that as 'sage -n'.
 
I'll continue on with the development version for now.

Thanks,

Andy


Reply all
Reply to author
Forward
0 new messages