Skip to content

Commit

Permalink
Trac #12879: TestSuite failures for HeckeModule Homsets
Browse files Browse the repository at this point in the history
Adding a Testsuite run in #12876 in the documentation of
sage.categories.hecke_modules.HeckeModules.ParentMethods._Hom_
revealed the following bug:
{{{
sage: M = ModularForms(Gamma0(7), 4)
sage: H = Hom(M); H
sage: H.zero()
Traceback (most recent call last):
  File "<ipython console>", line 1, in <module>
  File "cachefunc.pyx", line 1397, in
sage.misc.cachefunc.CachedMethodCallerNoArgs.__call__
(sage/misc/cachefunc.c:7026)
  File "/opt/sage-5.0.beta11/local/lib/python2.7/site-
packages/sage/categories/modules.py", line 221, in zero
    From: Free module generated by {1, 2, 3} over Integer Ring
  File "/opt/sage-5.0.beta11/local/lib/python2.7/site-
packages/sage/modular/hecke/homspace.py", line 111, in __call__
    return morphism.HeckeModuleMorphism_matrix(self, A, name)
  File "/opt/sage-5.0.beta11/local/lib/python2.7/site-
packages/sage/modular/hecke/morphism.py", line 116, in __init__
    MatrixMorphism.__init__(self, parent, A)
  File "/opt/sage-5.0.beta11/local/lib/python2.7/site-
packages/sage/modules/matrix_morphism.py", line 1191, in __init__
    parent.codomain().rank())(A)
  File "/opt/sage-5.0.beta11/local/lib/python2.7/site-
packages/sage/matrix/matrix_space.py", line 543, in __call__
    return self.matrix(entries, copy=copy, coerce=coerce, rows=rows)
  File "/opt/sage-5.0.beta11/local/lib/python2.7/site-
packages/sage/matrix/matrix_space.py", line 1372, in matrix
    return self.__matrix_class(self, entries=x, copy=copy,
coerce=coerce)
  File "matrix_rational_dense.pyx", line 205, in
sage.matrix.matrix_rational_dense.Matrix_rational_dense.__init__
(sage/matrix/matrix_rational_dense.c:5788)
TypeError: entries must be coercible to a list or integer
}}}

{{{TestSuite(H).run()}}} also fails for "_test_elements".

URL: https://trac.sagemath.org/12879
Reported by: nthiery
Ticket author(s): Frédéric Chapoton
Reviewer(s): Travis Scrimshaw, Maarten Derickx
  • Loading branch information
Release Manager authored and vbraun committed Aug 21, 2017
2 parents 035aa9f + 761ac1d commit ddf46df
Showing 1 changed file with 61 additions and 13 deletions.
74 changes: 61 additions & 13 deletions src/sage/modular/hecke/homspace.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
r"""
Hom spaces between Hecke modules
"""
from __future__ import absolute_import

#*****************************************************************************
# Copyright (C) 2005 William Stein <[email protected]>
#
Expand All @@ -17,10 +15,14 @@
#
# http://www.gnu.org/licenses/
#*****************************************************************************
from __future__ import absolute_import

from sage.matrix.constructor import matrix
from sage.matrix.matrix_space import MatrixSpace
from sage.categories.homset import HomsetWithBase
from .morphism import HeckeModuleMorphism_matrix
from .module import is_HeckeModule

import sage.categories.homset
from . import morphism
from . import module

def is_HeckeModuleHomspace(x):
r"""
Expand All @@ -36,12 +38,13 @@ def is_HeckeModuleHomspace(x):
"""
return isinstance(x, HeckeModuleHomspace)

class HeckeModuleHomspace(sage.categories.homset.HomsetWithBase):

class HeckeModuleHomspace(HomsetWithBase):
r"""
A space of homomorphisms between two objects in the category of Hecke
modules over a given base ring.
"""
def __init__(self, X, Y, category = None):
def __init__(self, X, Y, category=None):
r"""
Create the space of homomorphisms between X and Y, which must have the
same base ring.
Expand All @@ -57,14 +60,20 @@ def __init__(self, X, Y, category = None):
TypeError: X and Y must have the same base ring
sage: M.Hom(M) == loads(dumps(M.Hom(M)))
True
TESTS::
sage: M = ModularForms(Gamma0(7), 4)
sage: H = M.Hom(M)
sage: TestSuite(H).run(skip='_test_elements')
"""
if not module.is_HeckeModule(X) or not module.is_HeckeModule(Y):
if not is_HeckeModule(X) or not is_HeckeModule(Y):
raise TypeError("X and Y must be Hecke modules")
if X.base_ring() != Y.base_ring():
raise TypeError("X and Y must have the same base ring")
if category is None:
category = X.category()
sage.categories.homset.HomsetWithBase.__init__(self, X, Y, category = category)
HomsetWithBase.__init__(self, X, Y, category=category)

def __call__(self, A, name=''):
r"""
Expand Down Expand Up @@ -116,7 +125,8 @@ def __call__(self, A, name=''):
sage: M = ModularSymbols(Gamma0(3),weight=22,sign=1)
sage: S = M.cuspidal_subspace()
sage: S.Hom(S)(S.gens())
sage: H = S.Hom(S)
sage: H(S.gens())
Hecke module morphism defined by the matrix
[1 0 0 0 0 0]
[0 1 0 0 0 0]
Expand All @@ -126,6 +136,11 @@ def __call__(self, A, name=''):
[0 0 0 0 0 1]
Domain: Modular Symbols subspace of dimension 6 of Modular Symbols space ...
Codomain: Modular Symbols subspace of dimension 6 of Modular Symbols space ...
sage: H.zero() in H
True
sage: H.one() in H
True
"""
try:
if A.parent() == self:
Expand All @@ -139,7 +154,40 @@ def __call__(self, A, name=''):
raise TypeError("unable to coerce A to self")
except AttributeError:
pass
if isinstance(A, (list, tuple)):
from sage.matrix.constructor import matrix
if A in self.base_ring():
dim_dom = self.domain().rank()
dim_codom = self.codomain().rank()
MS = MatrixSpace(self.base_ring(), dim_dom, dim_codom)
if self.domain() == self.codomain():
A = A * MS.identity_matrix()
elif A == 0:
A = MS.zero()
else:
raise ValueError('scalars do not coerce to this homspace')
elif isinstance(A, (list, tuple)):
A = matrix([self.codomain().coordinate_vector(f) for f in A])
return morphism.HeckeModuleMorphism_matrix(self, A, name)
return HeckeModuleMorphism_matrix(self, A, name)

def _an_element_(self):
"""
Return an element.
If the domain is equal to the codomain, this returns the
action of the Hecke operator of index 2. Otherwise, this returns zero.
EXAMPLES::
sage: M = ModularSymbols(Gamma0(2), weight=12, sign=1)
sage: S = M.cuspidal_subspace()
sage: S.Hom(S).an_element()
Hecke module morphism defined by the matrix
[ 260 -2108/135]
[ 4860 -284]
Domain: Modular Symbols subspace of dimension 2 of Modular Symbols space ...
Codomain: Modular Symbols subspace of dimension 2 of Modular Symbols space ...
"""
if self.domain() != self.codomain():
return self.zero()
else:
A = self.domain().hecke_operator(2).matrix()
return HeckeModuleMorphism_matrix(self, A)

0 comments on commit ddf46df

Please sign in to comment.