Yes, exactly. In Python, __eq__ really means equality, and things like sets
and lists will assume objects that return True with __eq__ can be
interchanged with one another. SymPy follows this convention. If a == b,
any SymPy algorithm might interchange a with b and consider it to be valid.

Also take a read of
https://github.com/sympy/sympy/wiki/Automatic-Simplification. It's best to
allow different things ways of writing mathematically the same thing to be
written down differently, and deal with them being mathematically equal in
algorithms.

Aaron Meurer


On Sun, Mar 30, 2014 at 9:09 AM, Stefan Krastanov <stefan.krasta...@yale.edu
> wrote:

> Here is an example why `__eq__` should correspond to structural equality:
>
> >>> class a(object):
> ...     def __eq__(self, other):
> ...         raise NotImplementedError()
> ...
>
> >>> i = a()
>
> >>> list = [1,2,3,i]
>
> >>> list.index(i)
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
>   File "<stdin>", line 3, in __eq__
> NotImplementedError
>
>
>
> __eq__ is part of basic python protocols, we should not  make it do
> other things.
>
> --
> 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 sympy+unsubscr...@googlegroups.com.
> To post to this group, send email to sympy@googlegroups.com.
> 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/CAD8szLxfMiWvhFxkELqSwFdJTauce8jr0%3DHz-AmiCA3UnGs%2BSw%40mail.gmail.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 sympy+unsubscr...@googlegroups.com.
To post to this group, send email to sympy@googlegroups.com.
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%2BgqarEy8QxC9bfXckFpUWO0rfpTERZdeDKf%3DTBFyHG6Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to