Interact in standalone SageMath do not work as SageMathCell
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 ...
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!
I had posted an update about that.