@classmethod lets you call the method as my_function.eval() (as
opposed to my_function().eval). This is required for eval() because
that is how the superclass uses it to instantiate the class. Think of
it as a special SymPy version of __new__.

The derivative defines how the function behaves with respect to things
that use the derivative, including series expansion and integration.
It is not required (none of the methods are required), but if you want
those things to work, you need to define it. Otherwise, it will just
come out as an unevaluated Derivative when you take the derivative.

Aaron Meurer

On Fri, May 16, 2014 at 10:25 PM, Abhishek K Das
<[email protected]> wrote:
> class my_function(Function): nargs = 1 def fdiff(self, argindex = 1): return
> cos(self.args[0]) @classmethod def eval(cls, arg): arg = sympify(arg) if arg
> == 0: return sympify(0)
>
> On the website it is given this is how a function should be defined . Now my
> questions are why did you set argindex = 1 , where is it
> being used . And as for @classmethod it just signifies that the value of
> this function at 0 is 0 , am I right ? Why do we need to declare
> eval as @classmethod and does specifying the derivative define that function
> ( I know that is true mathematically , but how does it work for sympy ) ?
>
> --
> 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 http://groups.google.com/group/sympy.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/4332b4c0-c3f6-4d90-807b-42b6ecd9cdd0%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
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 http://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/CAKgW%3D6%2BvGkd15QtR_xgdSW_vEc7doB_fuLjB1eZc0p42yzPD5w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to