Skip to content

Commit

Permalink
Trac #34493: Make TrivialFamily.map return a TrivialFamily
Browse files Browse the repository at this point in the history
calling the `map` method of a `TrivialFamily` should give a
`TrivialFamily` again.

URL: https://trac.sagemath.org/34493
Reported by: mkoeppe
Ticket author(s): Matthias Koeppe
Reviewer(s): Travis Scrimshaw
  • Loading branch information
Release Manager committed Sep 27, 2022
2 parents c036ccc + 60b1d54 commit cb5e1af
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/sage/categories/additive_magmas.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ def algebra_generators(self):
An example of a commutative semigroup: the free commutative semigroup generated by ('a', 'b', 'c', 'd')
sage: A = S.algebra(QQ)
sage: A.algebra_generators()
Finite family {0: B[a], 1: B[b], 2: B[c], 3: B[d]}
Family (B[a], B[b], B[c], B[d])
.. TODO::
Expand Down
2 changes: 1 addition & 1 deletion src/sage/categories/additive_semigroups.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def algebra_generators(self):
An example of a commutative semigroup: the free commutative semigroup generated by ('a', 'b', 'c', 'd')
sage: A = S.algebra(QQ)
sage: A.algebra_generators()
Finite family {0: B[a], 1: B[b], 2: B[c], 3: B[d]}
Family (B[a], B[b], B[c], B[d])
"""
return self.basis().keys().additive_semigroup_generators().map(self.monomial)

Expand Down
7 changes: 3 additions & 4 deletions src/sage/categories/monoids.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,18 +556,17 @@ def algebra_generators(self):
sage: Z12.semigroup_generators()
Family (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)
sage: Z12.algebra(QQ).algebra_generators()
Finite family {0: B[0], 1: B[1], 2: B[2], 3: B[3], 4: B[4], 5: B[5],
6: B[6], 7: B[7], 8: B[8], 9: B[9], 10: B[10], 11: B[11]}
Family (B[0], B[1], B[2], B[3], B[4], B[5], B[6], B[7], B[8], B[9], B[10], B[11])
sage: GroupAlgebras(QQ).example(AlternatingGroup(10)).algebra_generators()
Finite family {0: (8,9,10), 1: (1,2,3,4,5,6,7,8,9)}
Family ((8,9,10), (1,2,3,4,5,6,7,8,9))
sage: A = DihedralGroup(3).algebra(QQ); A
Algebra of Dihedral group of order 6 as a permutation group
over Rational Field
sage: A.algebra_generators()
Finite family {0: (1,2,3), 1: (1,3)}
Family ((1,2,3), (1,3))
"""
monoid = self.basis().keys()
try:
Expand Down
2 changes: 1 addition & 1 deletion src/sage/categories/semigroups.py
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,7 @@ def algebra_generators(self):
sage: M.semigroup_generators()
Family ('a', 'b', 'c', 'd')
sage: M.algebra(ZZ).algebra_generators()
Finite family {0: B['a'], 1: B['b'], 2: B['c'], 3: B['d']}
Family (B['a'], B['b'], B['c'], B['d'])
"""
return self.basis().keys().semigroup_generators().map(self.monomial)

Expand Down
17 changes: 17 additions & 0 deletions src/sage/sets/family.py
Original file line number Diff line number Diff line change
Expand Up @@ -1380,6 +1380,23 @@ def __setstate__(self, state):
"""
self.__init__(state['_enumeration'])

def map(self, f, name=None):
r"""
Return the family `( f(\mathtt{self}[i]) )_{i \in I}`,
where `I` is the index set of ``self``.
The result is again a :class:`TrivialFamily`.
EXAMPLES::
sage: from sage.sets.family import TrivialFamily
sage: f = TrivialFamily(['a', 'b', 'd'])
sage: g = f.map(lambda x: x + '1'); g
Family ('a1', 'b1', 'd1')
"""
# tuple([... for ...]) is faster than tuple(... for ...)
return Family(tuple([f(x) for x in self._enumeration]), name=name)


from sage.sets.non_negative_integers import NonNegativeIntegers
from sage.rings.infinity import Infinity
Expand Down

0 comments on commit cb5e1af

Please sign in to comment.