Skip to content

Commit 8acc127

Browse files
committed
moving modular stuff to "CommutativeRing" class
1 parent 3dd953c commit 8acc127

File tree

1 file changed

+22
-17
lines changed

1 file changed

+22
-17
lines changed

src/sage/modular/hecke/algebra.py

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,16 @@
2626
#
2727
# https://www.gnu.org/licenses/
2828
# ****************************************************************************
29+
from typing import Iterator
2930

30-
import sage.rings.infinity
31+
from sage.rings.infinity import infinity
32+
from sage.categories.algebras import Algebras
3133
from sage.matrix.constructor import matrix
3234
from sage.arith.functions import lcm
3335
from sage.arith.misc import gcd
3436
from sage.misc.latex import latex
3537
from sage.matrix.matrix_space import MatrixSpace
36-
from sage.rings.ring import CommutativeAlgebra
38+
from sage.rings.ring import CommutativeRing
3739
from sage.rings.integer_ring import ZZ
3840
from sage.rings.rational_field import QQ
3941
from sage.structure.element import Element
@@ -42,7 +44,7 @@
4244
from sage.structure.richcmp import richcmp_method, richcmp
4345

4446

45-
def is_HeckeAlgebra(x):
47+
def is_HeckeAlgebra(x) -> bool:
4648
r"""
4749
Return ``True`` if x is of type HeckeAlgebra.
4850
@@ -105,7 +107,7 @@ def _heckebasis(M):
105107

106108

107109
@richcmp_method
108-
class HeckeAlgebra_base(CachedRepresentation, CommutativeAlgebra):
110+
class HeckeAlgebra_base(CachedRepresentation, CommutativeRing):
109111
"""
110112
Base class for algebras of Hecke operators on a fixed Hecke module.
111113
@@ -163,7 +165,7 @@ def __classcall__(cls, M):
163165
pass
164166
return super().__classcall__(cls, M)
165167

166-
def __init__(self, M):
168+
def __init__(self, M) -> None:
167169
"""
168170
Initialization.
169171
@@ -179,7 +181,9 @@ def __init__(self, M):
179181
if not module.is_HeckeModule(M):
180182
raise TypeError("M (=%s) must be a HeckeModule" % M)
181183
self.__M = M
182-
CommutativeAlgebra.__init__(self, M.base_ring())
184+
cat = Algebras(M.base_ring()).Commutative()
185+
CommutativeRing.__init__(self, base_ring=M.base_ring(),
186+
category=cat)
183187

184188
def _an_element_(self):
185189
r"""
@@ -319,12 +323,13 @@ def ngens(self):
319323
sage: CuspForms(1, 12).anemic_hecke_algebra().ngens()
320324
+Infinity
321325
"""
322-
return sage.rings.infinity.infinity
326+
return infinity
323327

324-
def is_noetherian(self):
328+
def is_noetherian(self) -> bool:
325329
"""
326-
Return ``True`` if this Hecke algebra is Noetherian as a ring. This is true
327-
if and only if the base ring is Noetherian.
330+
Return ``True`` if this Hecke algebra is Noetherian as a ring.
331+
332+
This is true if and only if the base ring is Noetherian.
328333
329334
EXAMPLES::
330335
@@ -343,9 +348,9 @@ def matrix_space(self):
343348
sage: CuspForms(3, 24, base_ring=Qp(5)).anemic_hecke_algebra().matrix_space()
344349
Full MatrixSpace of 7 by 7 dense matrices over 5-adic Field with capped relative precision 20
345350
"""
346-
return sage.matrix.matrix_space.MatrixSpace(self.base_ring(), self.module().rank())
351+
return MatrixSpace(self.base_ring(), self.module().rank())
347352

348-
def _latex_(self):
353+
def _latex_(self) -> str:
349354
r"""
350355
LaTeX representation of self.
351356
@@ -569,7 +574,7 @@ class HeckeAlgebra_full(HeckeAlgebra_base):
569574
A full Hecke algebra (including the operators `T_n` where `n` is not
570575
assumed to be coprime to the level).
571576
"""
572-
def _repr_(self):
577+
def _repr_(self) -> str:
573578
r"""
574579
String representation of self.
575580
@@ -580,7 +585,7 @@ def _repr_(self):
580585
"""
581586
return "Full Hecke algebra acting on %s" % self.module()
582587

583-
def __richcmp__(self, other, op):
588+
def __richcmp__(self, other, op) -> bool:
584589
r"""
585590
Compare self to other.
586591
@@ -631,15 +636,15 @@ class HeckeAlgebra_anemic(HeckeAlgebra_base):
631636
r"""
632637
An anemic Hecke algebra, generated by Hecke operators with index coprime to the level.
633638
"""
634-
def _repr_(self):
639+
def _repr_(self) -> str:
635640
r"""
636641
EXAMPLES::
637642
638643
sage: H = CuspForms(3, 12).anemic_hecke_algebra()._repr_()
639644
"""
640645
return "Anemic Hecke algebra acting on %s" % self.module()
641646

642-
def __richcmp__(self, other, op):
647+
def __richcmp__(self, other, op) -> bool:
643648
r"""
644649
Compare self to other.
645650
@@ -689,7 +694,7 @@ def is_anemic(self) -> bool:
689694
"""
690695
return True
691696

692-
def gens(self):
697+
def gens(self) -> Iterator:
693698
r"""
694699
Return a generator over all Hecke operator `T_n` for
695700
`n = 1, 2, 3, \ldots`, with `n` coprime to the

0 commit comments

Comments
 (0)