[sage-support] Re: Integrating python functions

2011-06-28 Thread Simon King
Hi! The most straight forward way does not work: sage: def bla(x): : print "here I am" : return x**2 : sage: foo = function("foo", nargs=1, eval_func = bla) sage: foo(5) --- TypeError

[sage-support] Re: Integrating python functions

2011-06-28 Thread Simon King
Hi! On 28 Jun., 16:47, Michael Orlitzky wrote: > > @symbolicfunction > > def f(x): > >    return some_expression_in_x(x) > > > Others have ideas whether this is good/feasible? > > I'll vote for good, and have no idea re: feasibility. Certainly it is a good idea. Concerning feasibility: I am not

[sage-support] Re: Integrating python functions

2011-06-28 Thread Nils Bruin
On Jun 28, 7:57 am, Jason Grout wrote: > sage: preparse('a(x)=2*x') > '__tmp__=var("x"); a = symbolic_expression(Integer(2)*x).function(x)' And, as we know now, if we do this in the notebook, we can even change the value of 2 afterwards: def f(x): return 2*x print f(3) _sage_const_2=3 print f

[sage-support] Re: Integrating python functions

2011-06-28 Thread Jason Grout
On 6/28/11 9:47 AM, Michael Orlitzky wrote: On 06/28/11 09:12, kcrisman wrote: Here you probably mean something else. Are you getting a deprecation warning? It's better to define a(x) = x b(x) = 2*x I know this for the Sage prompt, but it doesn't work in a Python file because without the

Re: [sage-support] Re: Integrating python functions

2011-06-28 Thread Michael Orlitzky
On 06/28/11 09:12, kcrisman wrote: > > Here you probably mean something else. Are you getting a deprecation > warning? > > It's better to define > > a(x) = x > b(x) = 2*x > I know this for the Sage prompt, but it doesn't work in a Python file because without the preprocessing it tries to eval

[sage-support] Re: Integrating python functions

2011-06-28 Thread kcrisman
On Jun 27, 3:22 pm, Michael Orlitzky wrote: > I'll take a simple example. I'd like to integrate (or differentiate, or > whatever) the following function, > >   x = var('x') > >   a = x >   b = 2*x Here you probably mean something else. Are you getting a deprecation warning? It's better to de