Permalink
Browse files

Make an anonymous Morphism equal to itself.

Previously, for a = Morphism(A, B), with A and B being Object's, a == a
was False, which would have been very inconvenient.  Now a == a is
correctly True.
  • Loading branch information...
1 parent fca51f2 commit 3b85a22f7ff13bd6973a8bee77e55a370eefedd1 @scolobb committed Jun 11, 2012
Showing with 7 additions and 0 deletions.
  1. +3 −0 sympy/categories/baseclasses.py
  2. +4 −0 sympy/categories/tests/test_baseclasses.py
@@ -312,6 +312,9 @@ def flatten(self, new_name=""):
return Morphism(self.domain, self.codomain, new_name)
def __eq__(self, other):
+ if other is self:
+ return True
+
if not isinstance(other, Morphism):
return False
@@ -103,6 +103,10 @@ def test_morphism():
raises(ValueError, lambda: Morphism(A, B, identity=True))
+ f = Morphism(A, B)
+ assert f != Morphism(A, B)
+ assert f == f
+
def test_diagram():
A = Object("A")
B = Object("B")

0 comments on commit 3b85a22

Please sign in to comment.