scolobb/sympy forked from sympy/sympy

Don't automatically construct the name of the composed morphism.

```This also concerns flattened morphisms.  While initially it seemed to be
a good idea to automatically construct new morphism names, it proved
later that trying to be clever when it's not necessary is never good.```
• Loading branch information...
1 parent bab67ea commit ff0432910bdd1308c67112d9171c3184df7e76fe committed Jun 2, 2012
Showing with 4 additions and 26 deletions.
1. +1 −23 sympy/categories/baseclasses.py
2. +3 −3 sympy/categories/tests/test_baseclasses.py
 @@ -53,11 +53,6 @@ def compose(self, g, new_name=""): concatenation of g.components and self.components, in this order. - If new_name is not an empty string, the new morphism will have - the name new_name. Otherwise the name of the new morphism - will the juxtaposition of the names of morphisms in the - components list, in reversed order, interspersed with '*'. - Examples ======== TODO: Add examples. @@ -68,11 +63,6 @@ def compose(self, g, new_name=""): composite = Morphism(g.domain, self.codomain, new_name) composite.components = g.components + self.components - if not new_name: - for component in reversed(composite.components): - composite.name += component.name + "*" - composite.name = composite.name[:-1] - return composite def __mul__(self, g): @@ -98,11 +88,6 @@ def flatten(self, new_name=""): Note that comparing self with the new morphism need NOT return True. - If new_name is not an empty string, the new morphism will have - the name new_name. Otherwise the name of the new morphism - will be the juxtaposition of the names of morphisms in - self.components, in reversed order, interspersed with *. - Examples ======== TODO: Add examples. @@ -111,11 +96,4 @@ def flatten(self, new_name=""): ======== compose """ - flattened = Morphism(self.domain, self.codomain, new_name) - - if not new_name: - for component in reversed(self.components): - flattened.name += component.name + "*" - flattened.name = flattened.name[:-1] - - return flattened + return Morphism(self.domain, self.codomain, new_name)
 @@ -36,22 +36,22 @@ def test_morphism(): assert k.domain == A assert k.codomain == C - assert k.name == "g*f" + assert k.name == "" assert k.components == [f, g] assert h * k == u assert p * f == u assert u.domain == A assert u.codomain == D - assert u.name == "h*g*f" + assert u.name == "" assert u.components == [f, g, h] u1 = u.flatten() assert u1.domain == A assert u1.codomain == D - assert u1.name == "h*g*f" + assert u1.name == "" assert u1.components == [u1] u1 = u.flatten("u")

0 comments on commit `ff04329`

Please sign in to comment.