Yes, unfortunately, Function acts differently when subclassed.

What you want to do, I believe, is create a custom subclass of Function
with the metaclass UndefinedFunction.  It's worth taking a look at the
source code of Function to see how it works.

Aaron Meurer

On Thu, Jul 16, 2015 at 4:31 AM, Nico <[email protected]> wrote:

> Got it:
> As outlined in [1], what is mathematically perceived as a "function" is a
> class in terms of sympy, not an instance thereof.
>
> --Nico
>
>
> [1] http://docs.sympy.org/latest/modules/functions/index.html
>
> On Thursday, July 16, 2015 at 9:53:17 AM UTC+2, Nico wrote:
>>
>> Following up on question [1], I'm wondering how one can derive from
>> sympy.Function in a way that keeps all the original functionality in place.
>> Something as naive as
>> ```
>> import sympy
>>
>> x = sympy.Symbol('x')
>>
>> a = sympy.Function('a')
>> a(x)  # no problem
>>
>> class MyTest(sympy.Function):
>>     pass
>> b = MyTest('b')
>> b(x)  # object is not callable
>> ```
>> doesn't work: `b` is reported not to be callable here.
>>
>> Any hints why this might be and how to fix it?
>>
>> Cheers,
>> Nico
>>
>>
>> [1] https://groups.google.com/forum/#!topic/sympy/5mLEq4Gbyfk
>>
>  --
> 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/57e9ce21-26d0-4bee-a505-7480ed4fd506%40googlegroups.com
> <https://groups.google.com/d/msgid/sympy/57e9ce21-26d0-4bee-a505-7480ed4fd506%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> 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%3D6L-%2BPPFfyPBduJxF8xWheCKz3sg%3D0NYHfyq3LTZZzbdkg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to