Skip to content
This repository was archived by the owner on Feb 1, 2023. It is now read-only.

Commit 12f94b6

Browse files
author
Release Manager
committed
Trac #28594: better categories for some groups
and another little change in Hecke modules URL: https://trac.sagemath.org/28594 Reported by: chapoton Ticket author(s): Frédéric Chapoton Reviewer(s): Vincent Delecroix
2 parents 56920d5 + 34cd475 commit 12f94b6

File tree

5 files changed

+31
-20
lines changed

5 files changed

+31
-20
lines changed

src/sage/categories/hecke_modules.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from sage.categories.homsets import HomsetsCategory
1616
from sage.categories.modules_with_basis import ModulesWithBasis
1717

18+
1819
class HeckeModules(Category_module):
1920
r"""
2021
The category of Hecke modules.
@@ -71,7 +72,7 @@ def __init__(self, R):
7172
"""
7273
from .commutative_rings import CommutativeRings
7374
if R not in CommutativeRings():
74-
raise TypeError("R (=%s) must be a commutative ring"%R)
75+
raise TypeError("R (=%s) must be a commutative ring" % R)
7576
Category_module.__init__(self, R)
7677

7778
def super_categories(self):
@@ -156,16 +157,10 @@ class Homsets(HomsetsCategory):
156157
TESTS::
157158
158159
sage: TestSuite(HeckeModules(ZZ).Homsets()).run()
159-
"""
160160
161-
def base_ring(self):
162-
"""
163-
EXAMPLES::
164-
165-
sage: HeckeModules(QQ).Homsets().base_ring()
166-
Rational Field
167-
"""
168-
return self.base_category().base_ring()
161+
sage: HeckeModules(QQ).Homsets().base_ring()
162+
Rational Field
163+
"""
169164

170165
def extra_super_categories(self):
171166
"""
@@ -180,7 +175,7 @@ def extra_super_categories(self):
180175
[Category of vector spaces over Rational Field, Category of homsets]
181176
"""
182177
from sage.categories.modules import Modules
183-
return [Modules(self.base_ring())]
178+
return [Modules(self.base_category().base_ring())]
184179

185180
class ParentMethods:
186181
pass

src/sage/categories/homset.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
4848
- Simon King (2013-02): added examples
4949
"""
50-
#*****************************************************************************
50+
# ****************************************************************************
5151
# Copyright (C) 2005 David Kohel <[email protected]>, William Stein <[email protected]>
5252
#
5353
# Distributed under the terms of the GNU General Public License (GPL)
@@ -59,8 +59,8 @@
5959
# See the GNU General Public License for more details; the full text
6060
# is available at:
6161
#
62-
# http://www.gnu.org/licenses/
63-
#*****************************************************************************
62+
# https://www.gnu.org/licenses/
63+
# ****************************************************************************
6464

6565
from __future__ import absolute_import, print_function
6666

@@ -897,13 +897,13 @@ def _element_constructor_(self, x, check=None, **options):
897897
...
898898
TypeError: unable to convert 0 to an element of
899899
Set of Morphisms from Free Group on generators {x, y, z}
900-
to Free Group on generators {x, y, z} in Category of groups
900+
to Free Group on generators {x, y, z} in Category of infinite groups
901901
sage: H("whatever")
902902
Traceback (most recent call last):
903903
...
904904
TypeError: unable to convert 'whatever' to an element of
905905
Set of Morphisms from Free Group on generators {x, y, z}
906-
to Free Group on generators {x, y, z} in Category of groups
906+
to Free Group on generators {x, y, z} in Category of infinite groups
907907
sage: HH = Hom(H, H)
908908
sage: HH(HH.identity(), foo="bar")
909909
Traceback (most recent call last):

src/sage/groups/free_group.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
# ****************************************************************************
6262

6363
import six
64+
from sage.categories.groups import Groups
6465
from sage.groups.group import Group
6566
from sage.groups.libgap_wrapper import ParentLibGAP, ElementLibGAP
6667
from sage.structure.unique_representation import UniqueRepresentation
@@ -444,7 +445,7 @@ def fox_derivative(self, gen, im_gens=None, ring=None):
444445
sage: a.fox_derivative(F([1]),[t,t,t])
445446
0
446447
"""
447-
if not gen in self.parent().generators():
448+
if gen not in self.parent().generators():
448449
raise ValueError("Fox derivative can only be computed with respect to generators of the group")
449450
l = list(self.Tietze())
450451
if im_gens is None:
@@ -467,7 +468,7 @@ def fox_derivative(self, gen, im_gens=None, ring=None):
467468
# generator of the free group.
468469
a = R.zero()
469470
coef = R.one()
470-
while len(l) > 0:
471+
while l:
471472
b = l.pop(0)
472473
if b == i:
473474
a += coef * R.one()
@@ -743,6 +744,8 @@ class FreeGroup_class(UniqueRepresentation, Group, ParentLibGAP):
743744
744745
sage: G = FreeGroup('a, b')
745746
sage: TestSuite(G).run()
747+
sage: G.category()
748+
Category of infinite groups
746749
"""
747750
Element = FreeGroupElement
748751

@@ -771,7 +774,11 @@ def __init__(self, generator_names, libgap_free_group=None):
771774
if libgap_free_group is None:
772775
libgap_free_group = libgap.FreeGroup(generator_names)
773776
ParentLibGAP.__init__(self, libgap_free_group)
774-
Group.__init__(self)
777+
if not generator_names:
778+
cat = Groups().Finite()
779+
else:
780+
cat = Groups().Infinite()
781+
Group.__init__(self, category=cat)
775782

776783
def _repr_(self):
777784
"""

src/sage/groups/libgap_wrapper.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ class ParentLibGAP(SageObject):
189189
sage: F.<a,b> = FreeGroup()
190190
sage: F.Hom(F)
191191
Set of Morphisms from Free Group on generators {a, b}
192-
to Free Group on generators {a, b} in Category of groups
192+
to Free Group on generators {a, b} in Category of infinite groups
193193
"""
194194
from sage.groups.libgap_morphism import GroupHomset_libgap
195195
return GroupHomset_libgap(self, G, category=category, check=check)

src/sage/groups/matrix_gps/heisenberg.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,19 @@ def __init__(self, n=1, R=0):
116116
117117
sage: H = groups.matrix.Heisenberg(n=2, R=5)
118118
sage: TestSuite(H).run() # long time
119+
sage: H.category()
120+
Category of finitely generated finite enumerated groups
119121
sage: H = groups.matrix.Heisenberg(n=2, R=4)
120122
sage: TestSuite(H).run() # long time
121123
sage: H = groups.matrix.Heisenberg(n=3)
122124
sage: TestSuite(H).run(max_runs=30, skip="_test_elements") # long time
123125
sage: H = groups.matrix.Heisenberg(n=2, R=GF(4))
124126
sage: TestSuite(H).run() # long time
127+
128+
TESTS::
129+
130+
sage: groups.matrix.Heisenberg(n=2, R=ZZ).category()
131+
Category of finitely generated infinite enumerated groups
125132
"""
126133
def elementary_matrix(i, j, val, MS):
127134
elm = copy(MS.one())
@@ -158,6 +165,8 @@ def elementary_matrix(i, j, val, MS):
158165
cat = Groups().FinitelyGenerated()
159166
if self._ring in Rings().Finite():
160167
cat = cat.Finite()
168+
else:
169+
cat = cat.Infinite()
161170

162171
FinitelyGeneratedMatrixGroup_gap.__init__(self, ZZ(dim), self._ring,
163172
gap_group, category=cat)

0 commit comments

Comments
 (0)