Skip to content

Commit

Permalink
Rename Morphism.identity to is_identity.
Browse files Browse the repository at this point in the history
This name expresses the idea better.
  • Loading branch information
scolobb committed Jun 15, 2012
1 parent 3b85a22 commit 8dedae3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
18 changes: 9 additions & 9 deletions sympy/categories/baseclasses.py
Expand Up @@ -181,7 +181,7 @@ def name(self):
return self.args[2].name return self.args[2].name


@property @property
def identity(self): def is_identity(self):
""" """
Is ``True`` if this morphism is known to be an identity Is ``True`` if this morphism is known to be an identity
morphism. morphism.
Expand All @@ -193,10 +193,10 @@ def identity(self):
>>> A = Object("A") >>> A = Object("A")
>>> B = Object("B") >>> B = Object("B")
>>> f = Morphism(A, B, "f") >>> f = Morphism(A, B, "f")
>>> f.identity >>> f.is_identity
False False
>>> id_A = Morphism(A, A, identity=True) >>> id_A = Morphism(A, A, identity=True)
>>> id_A.identity >>> id_A.is_identity
True True
""" """
Expand Down Expand Up @@ -259,7 +259,7 @@ def compose(self, g, new_name=""):
if g.codomain != self.domain: if g.codomain != self.domain:
raise ValueError("Uncomponsable morphisms.") raise ValueError("Uncomponsable morphisms.")


if g.identity: if g.is_identity:
return self return self


# We don't really know whether the new morphism is an identity # We don't really know whether the new morphism is an identity
Expand Down Expand Up @@ -318,10 +318,10 @@ def __eq__(self, other):
if not isinstance(other, Morphism): if not isinstance(other, Morphism):
return False return False


if self.identity and other.identity: if self.is_identity and other.is_identity:
# All identities are equal. # All identities are equal.
return self.domain == other.domain return self.domain == other.domain
elif self.identity or other.identity: elif self.is_identity or other.is_identity:
# One of the morphisms is an identity, but not both. # One of the morphisms is an identity, but not both.
return False return False


Expand Down Expand Up @@ -422,7 +422,7 @@ def name(self):
return self.args[1].name return self.args[1].name


@property @property
def identity(self): def is_identity(self):
""" """
Is ``True`` if this morphism is known to be an identity Is ``True`` if this morphism is known to be an identity
morphism. morphism.
Expand All @@ -433,7 +433,7 @@ def identity(self):
>>> from sympy.categories import Object, IdentityMorphism >>> from sympy.categories import Object, IdentityMorphism
>>> A = Object("A") >>> A = Object("A")
>>> id_A = IdentityMorphism(A) >>> id_A = IdentityMorphism(A)
>>> id_A.identity >>> id_A.is_identity
True True
""" """
Expand Down Expand Up @@ -686,7 +686,7 @@ def _add_morphism(morphisms, morphism, props, add_identities=True):
if Diagram._set_dict_union(morphisms, morphism, props) == False: if Diagram._set_dict_union(morphisms, morphism, props) == False:
# We have just added a new morphism. # We have just added a new morphism.


if morphism.identity: if morphism.is_identity:
return return


if add_identities: if add_identities:
Expand Down
2 changes: 1 addition & 1 deletion sympy/categories/tests/test_baseclasses.py
Expand Up @@ -90,7 +90,7 @@ def test_morphism():
assert type(id_A) == IdentityMorphism assert type(id_A) == IdentityMorphism
assert id_A == IdentityMorphism(A, "id_A") assert id_A == IdentityMorphism(A, "id_A")


assert id_A.identity == True assert id_A.is_identity == True
assert id_A.components == Tuple(id_A) assert id_A.components == Tuple(id_A)
assert id_A == Morphism(A, A, name="f", identity=True) assert id_A == Morphism(A, A, name="f", identity=True)
assert hash(id_A) == hash(Morphism(A, A, name="f", identity=True)) assert hash(id_A) == hash(Morphism(A, A, name="f", identity=True))
Expand Down

0 comments on commit 8dedae3

Please sign in to comment.