Ask Your Question
2

Interact in standalone SageMath do not work as SageMathCell

asked 2016-08-17 21:41:20 +0200

Airton Granero gravatar image

updated 2016-08-18 23:13:46 +0200

I downloaded SageMath VM for Windows from sagemath
If I try an interact example:

@interact
def _(n=slider(1,20, step_size=1)):
     print(factorial(n))

it does not work unless I do first:

     from sagenb.notebook.interact import *

what is nowhere in the documentation by the way. Even so, I need to call the function first (what in SageMathCell is not needed):

     _()

I get the error:

TypeError
Traceback (most recent call last) <ipython-input-65-02a00410cc9d> in <module>() ----> 1 _()

<ipython-input-64-067de41a741b> in _(n) 1 @interact 2 def _(n=slider(Integer(1),Integer(20), step_size=Integer(1))): ----> 3 print(factorial(n))

/home/sage/sage-7.2/src/sage/symbolic/function.pyx in sage.symbolic.function.GinacFunction.__call__ (/home/sage/sage-7.2/src/build/cythonized/sage/symbolic/function.cpp:9536)() 819 (0, Integer Ring) 820 """ --> 821 res = super(GinacFunction, self).__call__(args, *kwds) 822 823 # Convert to Integer if the output was of type "int" and any of

/home/sage/sage-7.2/src/sage/symbolic/function.pyx in sage.symbolic.function.BuiltinFunction.__call__ (/home/sage/sage-7.2/src/build/cythonized/sage/symbolic/function.cpp:11161)() 970 res = self._evalf_try_(*args) 971 if res is None: --> 972 res = super(BuiltinFunction, self).__call__( 973 *args, coerce=coerce, hold=hold) 974

/home/sage/sage-7.2/src/sage/symbolic/function.pyx in sage.symbolic.function.Function.__call__ (/home/sage/sage-7.2/src/build/cythonized/sage/symbolic/function.cpp:6754)() 469 if callable(method): 470 return method() --> 471 raise TypeError("cannot coerce arguments: %s" % (err)) 472 473 else: # coerce == False

TypeError: cannot coerce arguments: no canonical coercion from <type 'instance'=""> to Symbolic Ring

But in SageMathCell it works.

If I change print(factorial(n)) for print(type(n)) when I call _() I get:

     <type 'instance'>

Again If I just call print(n) I get:

     Slider: None [1--|1|---20]

I understand that this means that n (the slider) is not a number. But again in SageMathCell it works.

UPDATE:

I am using Sage-7.2-ova virtual machine image for Windows (a dedicated CentOS machine) (unfortunately I have no karma to post links) in a Windows 10 VM under VMware Workstation 12. Player.

The machine has an integrated Chromium browser, the VM is completely off the shelf, just open the OVA and the machine is running. The only configs I did were: * for the keyboard (ABNT2 BR); * to access the web server from the host; * to install VMWare tools and get a shared folder with the host

but the error was there before all that.

And the error is not about the browser, the interpreter obviously do not accept the commands, the stack trace is very consistent about that, as the SageMathCell site (no links again because of my karma) was a different version (at least on the interact package).

IMPORTANT:

I am not using sage on command line. I am using on Sage Notebook on Jupyter via browser (not using aPython kernel, but Sage 7.2 kernel), by clicking New Notebook.

On command the line I have ... (more)

edit retag flag offensive close merge delete

Comments

This works for me in the sagenb in 7.3.beta7. Can you give a little more information about your setup (e.g. which version of Sage you are using, which browser)? This does seem odd, as it is fairly standard. You definitely shouldn't have to import anything to use it!

kcrisman gravatar imagekcrisman ( 2016-08-18 15:18:40 +0200 )edit

I had posted an update about that.

Airton Granero gravatar imageAirton Granero ( 2016-08-18 22:28:15 +0200 )edit

1 Answer

Sort by » oldest newest most voted
1

answered 2016-08-18 23:04:14 +0200

Airton Granero gravatar image

updated 2016-08-18 23:20:44 +0200

If on the command line I call

 sage

and inside sage command line I do:

 notebook()

another web interface is opened on localhost:8080/admin/1 (Sage notebook) instead of localhost:8000/tree# (Jupyter notebook), now I have and in this web interface it works.

The default home page on this VM is the Jupyter Notebook and in this one it does not work, but on sage notbook it works.

But it only works locally, on the host machine this interface is inaccessible even if you publish the worksheet, that will put it at ipaddress:8080/home/pub/0 (on the local machine it works as localhost:8080/home/pub/0).

edit flag offensive delete link more

Comments

Correct, the Jupyter notebook does NOT have interacts that work in the same way as the Sage notebook or Sage cell server. This is a problem, and is a good reason for the Jupyter notebook not to be the default in the virtual machine, but the VM image is made in a slightly different way than the other binaries to be set up to do this. There are some interactive capabilities in it but I am not very familiar with them.

kcrisman gravatar imagekcrisman ( 2016-08-19 02:17:21 +0200 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2016-08-17 21:38:47 +0200

Seen: 487 times

Last updated: Aug 18 '16