understandin the basic test interface

41 views
Skip to first unread message

utpal kumar Jha

unread,
Dec 27, 2014, 8:07:01 AM12/27/14
to sy...@googlegroups.com
i went through all of the docs and then found a link to test interface which i am unable to figure out as to how the test_function_series(1/2/3) are implementing sin,cos and tan functions respectively . if someone could provide an insight of fdiff() and eval() functions i would appreciate it .

https://github.com/sympy/sympy/blob/master/sympy/functions/elementary/tests/test_interface.py


Aaron Meurer

unread,
Dec 27, 2014, 2:55:24 PM12/27/14
to sy...@googlegroups.com
Both are special methods defined of subclasses of Function. eval is a
classmethod that tells what explicit values should be evaluated. If
eval is undefined, or returns None, the function will remain
unevaluated. For instance, with

class MyFunc(Function):
@classmethod
def eval(cls, arg):
if arg == 0:
return 0

then MyFunc(0) will return 0, but any other argument, like MyFunc(1),
will remain unevaluated. eval also tells Function how many arguments
the function takes.

fdiff is the derivative of *just* the function, without using the
chain rule. According to a comment in the code for
Function._eval_derivative, f(x).diff(s) -> x.diff(s) * f.fdiff(1)(s).
In fact, if you read the code for that method you should completely
understand how fdiff works. I believe the argindex argument handles
the case when the function has multiple arguments (like atan2).

Aaron Meurer
> --
> 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 sympy+un...@googlegroups.com.
> To post to this group, send email to sy...@googlegroups.com.
> 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/95df166a-d742-4544-a098-5551c109f5ec%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

utpal kumar Jha

unread,
Dec 28, 2014, 12:40:27 AM12/28/14
to sy...@googlegroups.com
I don't understand when fdiff() is being called ?

Reply all
Reply to author
Forward
0 new messages