diff --git a/src/sage/categories/hecke_modules.py b/src/sage/categories/hecke_modules.py index c21e4e47823..a268e3babe8 100644 --- a/src/sage/categories/hecke_modules.py +++ b/src/sage/categories/hecke_modules.py @@ -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. @@ -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): @@ -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): """ @@ -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 diff --git a/src/sage/groups/free_group.py b/src/sage/groups/free_group.py index 6162f225857..9bc5ff4e7d3 100644 --- a/src/sage/groups/free_group.py +++ b/src/sage/groups/free_group.py @@ -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 @@ -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: @@ -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() @@ -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 @@ -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): """ diff --git a/src/sage/groups/matrix_gps/heisenberg.py b/src/sage/groups/matrix_gps/heisenberg.py index d113bcb8d2f..4fefcd47ebb 100644 --- a/src/sage/groups/matrix_gps/heisenberg.py +++ b/src/sage/groups/matrix_gps/heisenberg.py @@ -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()) @@ -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)