Le jeudi 16 juin 2011 à 08:34 -0400, Alan Bromborsky a écrit :
> I defined a user function by -
> 
> def dot(x,y):
>      return(sympy.Function('dot')(*(x,y)))

That's not really a user function in the sympy sense, just an ordinary
Python function that happens to return an expression containing a
symbolic function.
> 
> I want the _print_Function in str.py to handle this in a special way so 
> I modified it to
> 
> def _print_Function(self, expr):
>          if expr.func.__name__ == 'dot':
>              return '(%s|%s)' % (expr.args[0],expr.args[1])
>          else:
>              return expr.func.__name__ + 
> "(%s)"%self.stringify(expr.args, ", ")
> 
Patching core sympy code isn't the recommended way to implement your
custom logic. It would be better to do something like:

class dot(Function):
    nargs = 2
    def _sympystr(self):
        return '(%s|%s)' % self.args

> but for example if "dot(a1,a2)" is in an expression then "dot(a1,a2)" 
> prints and not "(a1|a2)".
> What am I doing wrong?

What you did should have worked, I think. Can you give examples of wrong
output?

-- 
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.

Reply via email to