This is similar to something else you have posted here before. There is a
difference between, Function('f'), Function('f')(x), and Function('f')(x)(x).
Function('f') is an unapplied function, which can still be used as an object
for various reasons (for example, exp in the syntax cos(x).rewrite(exp)).
Function('f')(x) is f(x), which is of type f, just as exp(x) is of type exp.
This is because of the way that functions work as a class. Calling f(x)
creates an instance of f (see the docstring and comments in
sympy/core/functions.py). f(x)(x) does not make any sense and is not allowed,
hence the TypeError.
I hope that makes at least a little sense.
Aaron Meurer
On Jun 19, 2010, at 10:50 AM, Alan Bromborsky wrote:
> >>> from sympy import Symbol,Function
> >>> x = Symbol('x')
> >>> f = Function('f')(x)
> >>> f
> f(x)
> >>> type(f)
> f
> >>> type(f(x))
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> File
> "/usr/local/lib/python2.6/dist-packages/sympy-0.6.7_git-py2.6.egg/sympy/core/basic.py",
> line 1310, in __call__
> raise TypeError("argument must be a dictionary")
> TypeError: argument must be a dictionary
> >>> f
> f(x)
> >>> type(x)
> <class 'sympy.core.symbol.Symbol'>
> >>> f = Function('f')
> >>> type(f)
> <class 'sympy.core.function.FunctionClass'>
> >>>
>
>
> The question is why on line 7 is type(f) = f while on line 19 type returns
> something sensible.
>
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/sympy?hl=en.
>
--
You received this message because you are subscribed to the Google Groups
"sympy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sympy?hl=en.