Comment #22 on issue 1932 by [email protected]: Relationals do not work with any methods of Expr
http://code.google.com/p/sympy/issues/detail?id=1932

OK, here a slightly modified `do` function that doesn't use the applyfunc.

def do(self, e, i=None):
    """do `e` to both sides of self using function given or
    model expression with a variable representing each side:
    >> eq.do(i + 2)  # add 2 to both sides of Equality
>> eq.do(i + a, i) # add `a` to both sides; 3rd parameter identifies `i`
    >> eq.do(lambda i: i + a)  # modification given as a function
    """
    if isinstance(e, (FunctionClass, Lambda, type(lambda:1))):
        return self.applyfunc(e)
    e = S(e)
    i = (set([i]) if i else e.free_symbols) - self.free_symbols
    if len(i) != 1:
raise ValueError('not sure what symbol is being used to represent a side')
    i = i.pop()
    f = lambda side: e.subs(i, side)
    return self.func(*[f(side) for side in self.args])

from sympy.core.relational import Equality
Equality.do = do


--
You received this message because this project is configured to send all issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

--
You received this message because you are subscribed to the Google Groups 
"sympy-issues" 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-issues.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to