# Revision history [back]

### 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)

Which would be the smartest way to mix everything up? Any suggestion is highly appreciated.

### 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)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.