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

Commit d6feb97

Browse files
committed
better categories for some groups
1 parent 533fd5d commit d6feb97

File tree

3 files changed

+25
-14
lines changed

3 files changed

+25
-14
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/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/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)