On Tue, Feb 24, 2015 at 4:51 PM, John Peterson <[email protected]> wrote:
>
>
> On Tuesday, February 24, 2015 at 3:15:03 PM UTC-7, Aaron Meurer wrote:
>>
>> The problem is that assumptions on Function don't do anything
>> (https://github.com/sympy/sympy/issues/6494). If you want to create a
>> Function with assumptions, you'll need to subclass Function
>> explicitly, like
>>
>> class f(Function):
>> is_real = True
>
>
> Thanks for pointing out the real issue! I tried to implement your
> suggestion, but I'm not a particularly skillful python programmer, so my
> first attempt at subclassing Function in the way you described didn't
> work...
>
> Here's the code:
>
>> #!/usr/bin/env python
>> from sympy import *
>> class real_function(Function):
>> is_real=True
>> X = Symbol('X', real=True)
>> f = real_function('f')(X)
>> g = real_function('g')(X)
>> print diff (abs(f-g), X)
It would just be real_function(X).
"Function('f')" is (roughly) the same as "class f(Function): pass".
That is, it creates a subclass of Function called f. You will need to
create a new subclass for each function. Clearly, that's not super
easy to do if you want to create them on the fly, which is why we
should fix that issue.
Aaron Meurer
>
>
> And the error message:
>
>> Traceback (most recent call last):
>> File "testcase.py", line 10, in <module>
>> f = real_function('f')(X)
>> TypeError: 'real_function' object is not callable
>
>
> which I don't understand how to fix.
>
> --
> 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/2952c170-688e-4c2d-a61a-3063e7866c0e%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%2BtP6j4Oecm%3D7ajRiMAB6pkEMYSBM7nrOh-Sxqxs7LWfQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.