You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to sympy
To get all function from an expression, one can do
```
from sympy import *
f = Function('f')
x = Symbol('x')
y = f(x) + 2 * sin(x)
for fun in y.atoms(Function):
print(fun.func)
```
which in this case will print out `f` and `sin`.
I would now like to distinguish between function that I defined myself (`f`) the ones that come from elsewhere. I though about subclassing `sympy.Function`, but apparently it's not exactly meant to be used that way [1].
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to sympy
I guess one thing I could do is taint the function class object as
```
f = Function('f')
f.my_custom_function = True
```
Aaron Meurer
unread,
Apr 13, 2016, 1:08:37 PM4/13/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to sy...@googlegroups.com
sympy.Function is absolutely designed to be subclassed.
If f = Function('f'), then f is a subclass of UndefinedFunction, and
f(x) is an instance of AppliedUndef (both can be imported from
sympy.core.function). You can find custom functions with
y.atoms(AppliedUndef).