Updates:
        Labels: EasyToFix

Comment #5 on issue 3743 by smi...@gmail.com: dummy_eq fails with Sum
http://code.google.com/p/sympy/issues/detail?id=3743

I think this will work

    def dummy_eq(self, other):
        """
        Compare two expressions and handle dummy symbols.

        Examples
        ========

        >>> from sympy import Dummy
        >>> from sympy.abc import x, y

        >>> u = Dummy('u')

        >>> (u**2 + 1).dummy_eq(x**2 + 1)
        True
        >>> (u**2 + 1) == (x**2 + 1)
        False

        >>> (u**2 + y).dummy_eq(x**2 + y, x)
        True
        >>> (u**2 + y).dummy_eq(x**2 + y, y)
        False

        """
        def not_free(eq):
            free = eq.free_symbols
            return [a for a in preorder_traversal(eq)
                if isinstance(a, C.Symbol) and a not in free]
        s = not_free(self)
        o = not_free(other)
        if not s:
            return self == other
        if len(s) != len(o):
            return False
        return self.xreplace(dict(zip(s, o))) == other


--
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 sympy-issues+unsubscr...@googlegroups.com.
To post to this group, send email to sympy-issues@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy-issues?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to