Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

moving modular stuff to "CommutativeRing" class #37163

Merged
merged 1 commit into from
Feb 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
39 changes: 22 additions & 17 deletions src/sage/modular/hecke/algebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,16 @@
#
# https://www.gnu.org/licenses/
# ****************************************************************************
from typing import Iterator

import sage.rings.infinity
from sage.rings.infinity import infinity
from sage.categories.algebras import Algebras
from sage.matrix.constructor import matrix
from sage.arith.functions import lcm
from sage.arith.misc import gcd
from sage.misc.latex import latex
from sage.matrix.matrix_space import MatrixSpace
from sage.rings.ring import CommutativeAlgebra
from sage.rings.ring import CommutativeRing
from sage.rings.integer_ring import ZZ
from sage.rings.rational_field import QQ
from sage.structure.element import Element
Expand All @@ -42,7 +44,7 @@
from sage.structure.richcmp import richcmp_method, richcmp


def is_HeckeAlgebra(x):
def is_HeckeAlgebra(x) -> bool:
r"""
Return ``True`` if x is of type HeckeAlgebra.

Expand Down Expand Up @@ -105,7 +107,7 @@ def _heckebasis(M):


@richcmp_method
class HeckeAlgebra_base(CachedRepresentation, CommutativeAlgebra):
class HeckeAlgebra_base(CachedRepresentation, CommutativeRing):
"""
Base class for algebras of Hecke operators on a fixed Hecke module.

Expand Down Expand Up @@ -163,7 +165,7 @@ def __classcall__(cls, M):
pass
return super().__classcall__(cls, M)

def __init__(self, M):
def __init__(self, M) -> None:
"""
Initialization.

Expand All @@ -179,7 +181,9 @@ def __init__(self, M):
if not module.is_HeckeModule(M):
raise TypeError("M (=%s) must be a HeckeModule" % M)
self.__M = M
CommutativeAlgebra.__init__(self, M.base_ring())
cat = Algebras(M.base_ring()).Commutative()
CommutativeRing.__init__(self, base_ring=M.base_ring(),
category=cat)

def _an_element_(self):
r"""
Expand Down Expand Up @@ -319,12 +323,13 @@ def ngens(self):
sage: CuspForms(1, 12).anemic_hecke_algebra().ngens()
+Infinity
"""
return sage.rings.infinity.infinity
return infinity

def is_noetherian(self):
def is_noetherian(self) -> bool:
"""
Return ``True`` if this Hecke algebra is Noetherian as a ring. This is true
if and only if the base ring is Noetherian.
Return ``True`` if this Hecke algebra is Noetherian as a ring.

This is true if and only if the base ring is Noetherian.

EXAMPLES::

Expand All @@ -343,9 +348,9 @@ def matrix_space(self):
sage: CuspForms(3, 24, base_ring=Qp(5)).anemic_hecke_algebra().matrix_space()
Full MatrixSpace of 7 by 7 dense matrices over 5-adic Field with capped relative precision 20
"""
return sage.matrix.matrix_space.MatrixSpace(self.base_ring(), self.module().rank())
return MatrixSpace(self.base_ring(), self.module().rank())

def _latex_(self):
def _latex_(self) -> str:
r"""
LaTeX representation of self.

Expand Down Expand Up @@ -569,7 +574,7 @@ class HeckeAlgebra_full(HeckeAlgebra_base):
A full Hecke algebra (including the operators `T_n` where `n` is not
assumed to be coprime to the level).
"""
def _repr_(self):
def _repr_(self) -> str:
r"""
String representation of self.

Expand All @@ -580,7 +585,7 @@ def _repr_(self):
"""
return "Full Hecke algebra acting on %s" % self.module()

def __richcmp__(self, other, op):
def __richcmp__(self, other, op) -> bool:
r"""
Compare self to other.

Expand Down Expand Up @@ -631,15 +636,15 @@ class HeckeAlgebra_anemic(HeckeAlgebra_base):
r"""
An anemic Hecke algebra, generated by Hecke operators with index coprime to the level.
"""
def _repr_(self):
def _repr_(self) -> str:
r"""
EXAMPLES::

sage: H = CuspForms(3, 12).anemic_hecke_algebra()._repr_()
"""
return "Anemic Hecke algebra acting on %s" % self.module()

def __richcmp__(self, other, op):
def __richcmp__(self, other, op) -> bool:
r"""
Compare self to other.

Expand Down Expand Up @@ -689,7 +694,7 @@ def is_anemic(self) -> bool:
"""
return True

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