Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
better categories for some groups
Browse files Browse the repository at this point in the history
  • Loading branch information
fchapoton committed Oct 12, 2019
1 parent 533fd5d commit d6feb97
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 14 deletions.
17 changes: 6 additions & 11 deletions src/sage/categories/hecke_modules.py
Expand Up @@ -15,6 +15,7 @@
from sage.categories.homsets import HomsetsCategory
from sage.categories.modules_with_basis import ModulesWithBasis


class HeckeModules(Category_module):
r"""
The category of Hecke modules.
Expand Down Expand Up @@ -71,7 +72,7 @@ def __init__(self, R):
"""
from .commutative_rings import CommutativeRings
if R not in CommutativeRings():
raise TypeError("R (=%s) must be a commutative ring"%R)
raise TypeError("R (=%s) must be a commutative ring" % R)
Category_module.__init__(self, R)

def super_categories(self):
Expand Down Expand Up @@ -156,16 +157,10 @@ class Homsets(HomsetsCategory):
TESTS::
sage: TestSuite(HeckeModules(ZZ).Homsets()).run()
"""
def base_ring(self):
"""
EXAMPLES::
sage: HeckeModules(QQ).Homsets().base_ring()
Rational Field
"""
return self.base_category().base_ring()
sage: HeckeModules(QQ).Homsets().base_ring()
Rational Field
"""

def extra_super_categories(self):
"""
Expand All @@ -180,7 +175,7 @@ def extra_super_categories(self):
[Category of vector spaces over Rational Field, Category of homsets]
"""
from sage.categories.modules import Modules
return [Modules(self.base_ring())]
return [Modules(self.base_category().base_ring())]

class ParentMethods:
pass
13 changes: 10 additions & 3 deletions src/sage/groups/free_group.py
Expand Up @@ -61,6 +61,7 @@
# ****************************************************************************

import six
from sage.categories.groups import Groups
from sage.groups.group import Group
from sage.groups.libgap_wrapper import ParentLibGAP, ElementLibGAP
from sage.structure.unique_representation import UniqueRepresentation
Expand Down Expand Up @@ -444,7 +445,7 @@ def fox_derivative(self, gen, im_gens=None, ring=None):
sage: a.fox_derivative(F([1]),[t,t,t])
0
"""
if not gen in self.parent().generators():
if gen not in self.parent().generators():
raise ValueError("Fox derivative can only be computed with respect to generators of the group")
l = list(self.Tietze())
if im_gens is None:
Expand All @@ -467,7 +468,7 @@ def fox_derivative(self, gen, im_gens=None, ring=None):
# generator of the free group.
a = R.zero()
coef = R.one()
while len(l) > 0:
while l:
b = l.pop(0)
if b == i:
a += coef * R.one()
Expand Down Expand Up @@ -743,6 +744,8 @@ class FreeGroup_class(UniqueRepresentation, Group, ParentLibGAP):
sage: G = FreeGroup('a, b')
sage: TestSuite(G).run()
sage: G.category()
Category of infinite groups
"""
Element = FreeGroupElement

Expand Down Expand Up @@ -771,7 +774,11 @@ def __init__(self, generator_names, libgap_free_group=None):
if libgap_free_group is None:
libgap_free_group = libgap.FreeGroup(generator_names)
ParentLibGAP.__init__(self, libgap_free_group)
Group.__init__(self)
if not generator_names:
cat = Groups().Finite()
else:
cat = Groups().Infinite()
Group.__init__(self, category=cat)

def _repr_(self):
"""
Expand Down
9 changes: 9 additions & 0 deletions src/sage/groups/matrix_gps/heisenberg.py
Expand Up @@ -116,12 +116,19 @@ def __init__(self, n=1, R=0):
sage: H = groups.matrix.Heisenberg(n=2, R=5)
sage: TestSuite(H).run() # long time
sage: H.category()
Category of finitely generated finite enumerated groups
sage: H = groups.matrix.Heisenberg(n=2, R=4)
sage: TestSuite(H).run() # long time
sage: H = groups.matrix.Heisenberg(n=3)
sage: TestSuite(H).run(max_runs=30, skip="_test_elements") # long time
sage: H = groups.matrix.Heisenberg(n=2, R=GF(4))
sage: TestSuite(H).run() # long time
TESTS::
sage: groups.matrix.Heisenberg(n=2, R=ZZ).category()
Category of finitely generated infinite enumerated groups
"""
def elementary_matrix(i, j, val, MS):
elm = copy(MS.one())
Expand Down Expand Up @@ -158,6 +165,8 @@ def elementary_matrix(i, j, val, MS):
cat = Groups().FinitelyGenerated()
if self._ring in Rings().Finite():
cat = cat.Finite()
else:
cat = cat.Infinite()

FinitelyGeneratedMatrixGroup_gap.__init__(self, ZZ(dim), self._ring,
gap_group, category=cat)
Expand Down

0 comments on commit d6feb97

Please sign in to comment.