I'm trying to create a subclass of Symbol that returns a subclass of 
Function when called.   The only reason is to customize the is_commutative 
property so that an expression like P(A)/P(Eq(x,1)) will output with the 
P(x=1) in the denominator rather than as P^-1(x=1), which might confuse my 
students.

However, if I create a unmodified Function subclass, the resulting function 
is not callable.

In [7]: class Function2(Function):
   ...:     pass
   ...: 

In [8]: P=Function2('P')

In [9]: P(x)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-9-49600f79dd99> in <module>()
----> 1 P(x)

TypeError: 'Function2' object is not callable


The problem is due to __new__ of Function

    def __new__(cls, *args, **options):
        # Handle calls like Function('f')
        if cls is Function:
            return UndefinedFunction(*args, **options)

but, I can't change the condition to issubclass(cls,Function), as that 
makes it always true and messes up the function of Function.

Or, the specific question I'm actually struggling with is:
Can I create a 
P=Function('P')
so that

In [4]: P(A)/P(Eq(x,1))
Out[4]: 
      -1       
P(A)⋅P  (x = 1)

outputs with latex with the P(x=1) in the denomiator.

Thanks,
Duane

-- 
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/aa0c8473-f7f3-4e3e-bd87-9cc3757ad6d3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to