ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 12 Apr 2021 01:35:24 +0200interact: different behavior concerning **kwargs in SageCell an Jupyter notebookhttps://ask.sagemath.org/question/56620/interact-different-behavior-concerning-kwargs-in-sagecell-an-jupyter-notebook/I'm trying to use the output of one interact as the input for number of control elements in a second interact. The following examle code works in Sage Jupyter notebook but fails in SageCell (Unfortunately I can't post a link to SageCell due to my low karma).
I don't understand why it fails and how I can make the code run in SageCell.
@interact
def f(s=slider([1,2], default=1)):
kwargs = { f"C_{i}": checkbox() for i in range(s)}
print(kwargs)
@interact(**kwargs)
def f2(**kwargs):
for key, value in kwargs.items():
print(f"{key} is {value}")
VittMon, 12 Apr 2021 01:35:24 +0200https://ask.sagemath.org/question/56620/Mixing GP and @interact in one cellhttps://ask.sagemath.org/question/49508/mixing-gp-and-interact-in-one-cell/ What's wrong with my code? It doesn't work inside Sage Cell.
gp("""
square(x)=x^2;
""")
@interact
def _(x=2):
print(square(x))
When I press evaluate button code runs forever with no output at all. I can't figure out what is the problem.PedjaSat, 11 Jan 2020 19:03:01 +0100https://ask.sagemath.org/question/49508/Mixing %cython and @interact in one cellhttps://ask.sagemath.org/question/40417/mixing-cython-and-interact-in-one-cell/I'm trying to make an interactive applet to visualize the Mandelbrot Set, much in the way of the implementation of interactive fractals (wiki.sagemath.org/interact/fractal#Exploring_Mandelbrot - cannot copy full link because of not enough karma ;-))
But I'd like to embed the applet in a webpage using SageMathCell, and for this all the code must be encapsulated in just one cell, something in the following scheme
%cython
def function(...)
...
@interact
...
Unfortunately, `%cython` and `@interact` behave badly together, because the latter is unknown to the former (just try to join the code in the two cells of the example above or try the following minimal working example
%cython
def square(float x0):
return x0*x0
@interact
def _(x0=-2.5):
print(square(x0))
which, surprisingly enough, raises different errors in a online Sage Cell and in a Sage Notebook Cell)
Which would be the smartest way to mix everything up? Any suggestion is highly appreciated.jepstraMon, 01 Jan 2018 14:03:14 +0100https://ask.sagemath.org/question/40417/How to use matrices with @interacthttps://ask.sagemath.org/question/30156/how-to-use-matrices-with-interact/ I found the following example [here](http://doc.sagemath.org/html/en/prep/Quickstarts/Interact.html).
@interact
def _(m=('matrix', identity_matrix(2))):
print m.eigenvalues()
Unlike the other examples I've tried, this one does not work [when evaluated in SageMathCell](https://sagecell.sagemath.org/?z=eJxzyMwrSS1KTC7h5UpJTVOI18i11VDPTSwpyqxQ11HITEnNK8ksqYyHiGgYaWpqWvFyKQBBQRFQp0KuXmpmempeWWJOaWqxhiYA8OgZXg==&lang=sage). But it works well in a SageMathCloud Worksheet.
What am I supposed to do to produce such a matrix interact that works [when I embed it in html pages](https://github.com/sagemath/sagecell/blob/master/doc/embedding.rst)?JulienTue, 20 Oct 2015 22:50:23 +0200https://ask.sagemath.org/question/30156/