Let me try again:
class Double(Function):
u"""A simple function that doubles the input."""
nargs = 1
@classmethod
def eval(cls, arg):
pass
if arg.is_Number:
return sympy.Mul(2, arg)
def fdiff(self, argindex = 1):
return sympy.Integer(2)
This generates:
In [47]: Double(x)
Out[47]: Double(x)
In [48]: Double(2*x)
Out[48]: Double(2*x)
In [49]: Double(2*x).fdiff()
Out[49]: 2
In [50]: Double(2*x).diff()
Out[50]: 4
So now it looks like it is working as expected.
I thought the same way I could do: f = Function('f') I could also do d =
Double('d') then d(2).
As mentioned above, is this the expected way of doing things?
--
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/ac199e4a-62cf-4635-80fb-d45a5a828613%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.