He all,
I've read the posts. And the tutorial. And the code.
Still I'm having trouble defining my own functions.
Let's start with the very basics: I would like to define f(x) = 2 * x:
from sympy import *
from sympy.abc import x, y
import sympy
class Double(Function):
u"""A simple function that doubles the input."""
@classmethod
def eval(cls, arg):
return None
def fdiff(self, argindex = 1):
return Integer(2) * self.args[0]
def __new__(cls, *args, **kwargs):
return super(Double, cls).__new__(cls, *args, **kwargs)
def __init__(self, *args, **kwargs):
super(Double, self).__init__()
d = Double('d')
d(2)
When I run the code I get:
TypeError: 'Double' object is not callable
How can I pythonically/sympythonically define a Double inheriting from
function? Notice that this is just a first step in defining more 'complex'
functions (so don't tell me to use Lambda).
Grea work with the project! Thank you!
--
You received this message because you are subscribed to the Google Groups
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sympy.
To view this discussion on the web visit
https://groups.google.com/d/msgid/sympy/7cdffc27-8187-43af-a6be-68b15fbe9197%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.