Hi,
I am not able to understand why the following should not work (in notebook)
-
#################### cell 1 ##################
%cython
from sage.all import ode_solver, random
cdef class A:
cdef double mu
def __init__(self, double mu=1.):
self.mu = mu
def func(self, x):
return self.mu*x[0], self.mu*x[1]
def func1():
a = A()
trajectory = ode_solver()
trajectory.algorithm = "rkf45"
trajectory.function = lambda t, y: a.func(y)
trajectory.ode_solve(y_0=[random(), random()], t_span=[0,10],
num_points=100)
u1 = trajectory.interpolate_solution(0)
return u1
############## end of cell 1 ###################
This compiles without any problem, but when I do -
#################### cell 2 ##################
u1 = func1()
plot(u1, (0,10))
############## end of cell 2 ###################
I get the following error -
TypeError: arg is not a Python function
If I define func1 outside the cython cell then everything works fine. This
is just a toy problem but captures the behavior I encountered. I hope
someone can explain.
Rajeev
--
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org