Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

When composing morphisms, intersperse morphism names with '*'.

The initial approach to use spaces to separate morphisms names proved
inconsistent with the later idea to use '*' when printing morphism
composition.
  • Loading branch information...
commit 1ee252db38ce4e66d6351669d2bc1dcb1afd68f6 1 parent 631cb3d
Sergiu Ivanov authored
8 sympy/categories/baseclasses.py
@@ -56,7 +56,7 @@ def compose(self, g, new_name=""):
56 56 If new_name is not an empty string, the new morphism will have
57 57 the name new_name. Otherwise the name of the new morphism
58 58 will the juxtaposition of the names of morphisms in the
59   - components list, in reversed order.
  59 + components list, in reversed order, interspersed with '*'.
60 60
61 61 Examples
62 62 ========
@@ -70,7 +70,7 @@ def compose(self, g, new_name=""):
70 70
71 71 if not new_name:
72 72 for component in reversed(composite.components):
73   - composite.name += component.name + " "
  73 + composite.name += component.name + "*"
74 74 composite.name = composite.name[:-1]
75 75
76 76 return composite
@@ -101,7 +101,7 @@ def flatten(self, new_name=""):
101 101 If new_name is not an empty string, the new morphism will have
102 102 the name new_name. Otherwise the name of the new morphism
103 103 will be the juxtaposition of the names of morphisms in
104   - self.components, in reversed order.
  104 + self.components, in reversed order, interspersed with *.
105 105
106 106 Examples
107 107 ========
@@ -115,7 +115,7 @@ def flatten(self, new_name=""):
115 115
116 116 if not new_name:
117 117 for component in reversed(self.components):
118   - flattened.name += component.name + " "
  118 + flattened.name += component.name + "*"
119 119 flattened.name = flattened.name[:-1]
120 120
121 121 return flattened
6 sympy/categories/tests/test_baseclasses.py
@@ -36,7 +36,7 @@ def test_morphism():
36 36
37 37 assert k.domain == A
38 38 assert k.codomain == C
39   - assert k.name == "g f"
  39 + assert k.name == "g*f"
40 40 assert k.components == [f, g]
41 41
42 42 assert h * k == u
@@ -44,14 +44,14 @@ def test_morphism():
44 44
45 45 assert u.domain == A
46 46 assert u.codomain == D
47   - assert u.name == "h g f"
  47 + assert u.name == "h*g*f"
48 48 assert u.components == [f, g, h]
49 49
50 50 u1 = u.flatten()
51 51
52 52 assert u1.domain == A
53 53 assert u1.codomain == D
54   - assert u1.name == "h g f"
  54 + assert u1.name == "h*g*f"
55 55 assert u1.components == [u1]
56 56
57 57 u1 = u.flatten("u")

0 comments on commit 1ee252d

Please sign in to comment.
Something went wrong with that request. Please try again.