Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Rename Morphism.identity to is_identity.

This name expresses the idea better.
  • Loading branch information...
commit 8dedae3f36b1e0049e5d3cdbf3c3eea66e6bb238 1 parent 3b85a22
@scolobb authored
View
18 sympy/categories/baseclasses.py
@@ -181,7 +181,7 @@ def name(self):
return self.args[2].name
@property
- def identity(self):
+ def is_identity(self):
"""
Is ``True`` if this morphism is known to be an identity
morphism.
@@ -193,10 +193,10 @@ def identity(self):
>>> A = Object("A")
>>> B = Object("B")
>>> f = Morphism(A, B, "f")
- >>> f.identity
+ >>> f.is_identity
False
>>> id_A = Morphism(A, A, identity=True)
- >>> id_A.identity
+ >>> id_A.is_identity
True
"""
@@ -259,7 +259,7 @@ def compose(self, g, new_name=""):
if g.codomain != self.domain:
raise ValueError("Uncomponsable morphisms.")
- if g.identity:
+ if g.is_identity:
return self
# We don't really know whether the new morphism is an identity
@@ -318,10 +318,10 @@ def __eq__(self, other):
if not isinstance(other, Morphism):
return False
- if self.identity and other.identity:
+ if self.is_identity and other.is_identity:
# All identities are equal.
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.
return False
@@ -422,7 +422,7 @@ def name(self):
return self.args[1].name
@property
- def identity(self):
+ def is_identity(self):
"""
Is ``True`` if this morphism is known to be an identity
morphism.
@@ -433,7 +433,7 @@ def identity(self):
>>> from sympy.categories import Object, IdentityMorphism
>>> A = Object("A")
>>> id_A = IdentityMorphism(A)
- >>> id_A.identity
+ >>> id_A.is_identity
True
"""
@@ -686,7 +686,7 @@ def _add_morphism(morphisms, morphism, props, add_identities=True):
if Diagram._set_dict_union(morphisms, morphism, props) == False:
# We have just added a new morphism.
- if morphism.identity:
+ if morphism.is_identity:
return
if add_identities:
View
2  sympy/categories/tests/test_baseclasses.py
@@ -90,7 +90,7 @@ def test_morphism():
assert type(id_A) == IdentityMorphism
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 == Morphism(A, A, name="f", identity=True)
assert hash(id_A) == hash(Morphism(A, A, name="f", identity=True))
Please sign in to comment.
Something went wrong with that request. Please try again.