Skip to content

Commit e00736f

Browse files
committed
full pep8 for modular/hecke
1 parent 80f6d77 commit e00736f

File tree

8 files changed

+83
-72
lines changed

8 files changed

+83
-72
lines changed

src/sage/modular/hecke/algebra.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343

4444
def is_HeckeAlgebra(x):
4545
r"""
46-
Return True if x is of type HeckeAlgebra.
46+
Return ``True`` if x is of type HeckeAlgebra.
4747
4848
EXAMPLES::
4949
@@ -210,7 +210,7 @@ def __call__(self, x, check=True):
210210
In the last case, the parameter ``check`` controls whether or
211211
not to check that this element really does lie in the
212212
appropriate algebra. At present, setting ``check=True`` raises
213-
a NotImplementedError unless x is a scalar (or a diagonal
213+
a :class:`NotImplementedError` unless x is a scalar (or a diagonal
214214
matrix).
215215
216216
EXAMPLES::
@@ -320,7 +320,7 @@ def ngens(self):
320320

321321
def is_noetherian(self):
322322
"""
323-
Return True if this Hecke algebra is Noetherian as a ring. This is true
323+
Return ``True`` if this Hecke algebra is Noetherian as a ring. This is true
324324
if and only if the base ring is Noetherian.
325325
326326
EXAMPLES::
@@ -649,7 +649,6 @@ def __richcmp__(self, other, op):
649649
False
650650
sage: A == A
651651
True
652-
653652
"""
654653
if not isinstance(other, HeckeAlgebra_anemic):
655654
return NotImplemented
@@ -675,9 +674,9 @@ def hecke_operator(self, n):
675674
raise IndexError("Hecke operator T_%s not defined in the anemic Hecke algebra" % n)
676675
return self.module()._hecke_operator_class()(self, n)
677676

678-
def is_anemic(self):
677+
def is_anemic(self) -> bool:
679678
"""
680-
Return True, since this is the anemic Hecke algebra.
679+
Return ``True``, since this is the anemic Hecke algebra.
681680
682681
EXAMPLES::
683682

src/sage/modular/hecke/ambient_module.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,12 +388,12 @@ def degeneracy_map(self, codomain, t=1):
388388
err = True
389389
if err:
390390
raise ValueError(("the level of self (=%s) must be a divisor or multiple of "
391-
"level (=%s) and t (=%s) must be a divisor of the quotient") % (self.level(), level, t))
391+
"level (=%s) and t (=%s) must be a divisor of the quotient") % (self.level(), level, t))
392392

393393
eps = self.character()
394394
if not (eps is None) and level % eps.conductor() != 0:
395395
raise ArithmeticError("the conductor of the character of this space "
396-
"(=%s) must be divisible by the level (=%s)" % (eps.conductor(), level))
396+
"(=%s) must be divisible by the level (=%s)" % (eps.conductor(), level))
397397

398398
if M is None:
399399
M = self.hecke_module_of_level(level)

src/sage/modular/hecke/degenmap.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Degeneracy maps
33
"""
44

5-
#*****************************************************************************
5+
# ****************************************************************************
66
# Sage: Open Source Mathematical Software
77
#
88
# Copyright (C) 2005 William Stein <[email protected]>
@@ -16,12 +16,11 @@
1616
#
1717
# The full text of the GPL is available at:
1818
#
19-
# http://www.gnu.org/licenses/
20-
#*****************************************************************************
21-
22-
19+
# https://www.gnu.org/licenses/
20+
# ****************************************************************************
2321
from . import morphism
2422

23+
2524
class DegeneracyMap(morphism.HeckeModuleMorphism_matrix):
2625
"""
2726
A degeneracy map between Hecke modules of different levels.
@@ -93,8 +92,8 @@ def __init__(self, matrix, domain, codomain, t):
9392
if t == 1:
9493
pow = ""
9594
else:
96-
pow = "^%s"%t
97-
name = "degeneracy map corresponding to f(q) |--> f(q%s)"%(pow)
95+
pow = "^%s" % t
96+
name = "degeneracy map corresponding to f(q) |--> f(q%s)" % (pow)
9897
morphism.HeckeModuleMorphism_matrix.__init__(self, H, matrix, name)
9998

10099
def t(self):

src/sage/modular/hecke/element.py

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
- William Stein
77
"""
88

9-
#*****************************************************************************
9+
# ****************************************************************************
1010
# Sage: Open Source Mathematical Software
1111
#
1212
# Copyright (C) 2005 William Stein <[email protected]>
@@ -20,15 +20,16 @@
2020
#
2121
# The full text of the GPL is available at:
2222
#
23-
# http://www.gnu.org/licenses/
24-
#*****************************************************************************
23+
# https://www.gnu.org/licenses/
24+
# ****************************************************************************
2525

2626
from sage.structure.richcmp import richcmp, op_NE
2727
from sage.structure.element import ModuleElement
2828

29+
2930
def is_HeckeModuleElement(x):
3031
"""
31-
Return True if x is a Hecke module element, i.e., of type HeckeModuleElement.
32+
Return ``True`` if x is a Hecke module element, i.e., of type HeckeModuleElement.
3233
3334
EXAMPLES::
3435
@@ -39,6 +40,7 @@ def is_HeckeModuleElement(x):
3940
"""
4041
return isinstance(x, HeckeModuleElement)
4142

43+
4244
class HeckeModuleElement(ModuleElement):
4345
"""
4446
Element of a Hecke module.
@@ -180,7 +182,7 @@ def _lmul_(self, x):
180182
sage: BrandtModule(37)([0,1,-1])._lmul_(3)
181183
(0, 3, -3)
182184
"""
183-
return self.parent()(self.element()*x)
185+
return self.parent()(self.element() * x)
184186

185187
def _rmul_(self, x):
186188
"""
@@ -218,9 +220,9 @@ def _sub_(self, right):
218220
"""
219221
return self.parent()(self.element() - right.element())
220222

221-
def is_cuspidal(self):
223+
def is_cuspidal(self) -> bool:
222224
r"""
223-
Return True if this element is cuspidal.
225+
Return ``True`` if this element is cuspidal.
224226
225227
EXAMPLES::
226228
@@ -247,14 +249,14 @@ def is_cuspidal(self):
247249
sage: N = next(S for S in M.decomposition(anemic=False) if S.hecke_matrix(3).trace()==-128844)
248250
sage: [g.is_cuspidal() for g in N.gens()]
249251
[True, True]
250-
251252
"""
252-
return (self in self.parent().ambient().cuspidal_submodule())
253+
return self in self.parent().ambient().cuspidal_submodule()
253254

254-
def is_eisenstein(self):
255+
def is_eisenstein(self) -> bool:
255256
r"""
256-
Return True if this element is Eisenstein. This makes sense for both
257-
modular forms and modular symbols.
257+
Return ``True`` if this element is Eisenstein.
258+
259+
This makes sense for both modular forms and modular symbols.
258260
259261
EXAMPLES::
260262
@@ -269,12 +271,13 @@ def is_eisenstein(self):
269271
sage: EllipticCurve('37a1').newform().element().is_eisenstein()
270272
False
271273
"""
272-
return (self in self.parent().ambient().eisenstein_submodule())
274+
return self in self.parent().ambient().eisenstein_submodule()
273275

274-
def is_new(self, p=None):
276+
def is_new(self, p=None) -> bool:
275277
r"""
276-
Return True if this element is p-new. If p is None, return True if the
277-
element is new.
278+
Return ``True`` if this element is p-new.
279+
280+
If p is ``None``, return ``True`` if the element is new.
278281
279282
EXAMPLES::
280283
@@ -285,12 +288,13 @@ def is_new(self, p=None):
285288
sage: CuspForms(22, 2).0.is_new()
286289
False
287290
"""
288-
return (self in self.parent().new_submodule(p))
291+
return self in self.parent().new_submodule(p)
289292

290-
def is_old(self, p=None):
293+
def is_old(self, p=None) -> bool:
291294
r"""
292-
Return True if this element is p-old. If p is None, return True if the
293-
element is old.
295+
Return ``True`` if this element is p-old.
296+
297+
If p is ``None``, return ``True`` if the element is old.
294298
295299
EXAMPLES::
296300
@@ -305,4 +309,4 @@ def is_old(self, p=None):
305309
sage: EisensteinForms(144, 2).1.is_old(2) # not implemented
306310
False
307311
"""
308-
return (self in self.parent().old_submodule(p))
312+
return self in self.parent().old_submodule(p)

src/sage/modular/hecke/hecke_operator.py

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
def is_HeckeOperator(x):
2929
r"""
30-
Return True if x is of type HeckeOperator.
30+
Return ``True`` if x is of type HeckeOperator.
3131
3232
EXAMPLES::
3333
@@ -40,9 +40,10 @@ def is_HeckeOperator(x):
4040
"""
4141
return isinstance(x, HeckeOperator)
4242

43+
4344
def is_HeckeAlgebraElement(x):
4445
r"""
45-
Return True if x is of type HeckeAlgebraElement.
46+
Return ``True`` if x is of type HeckeAlgebraElement.
4647
4748
EXAMPLES::
4849
@@ -55,6 +56,7 @@ def is_HeckeAlgebraElement(x):
5556
"""
5657
return isinstance(x, HeckeAlgebraElement)
5758

59+
5860
class HeckeAlgebraElement(AlgebraElement):
5961
r"""
6062
Base class for elements of Hecke algebras.
@@ -70,7 +72,7 @@ def __init__(self, parent):
7072
Generic element of a structure
7173
"""
7274
if not algebra.is_HeckeAlgebra(parent):
73-
raise TypeError("parent (=%s) must be a Hecke algebra"%parent)
75+
raise TypeError("parent (=%s) must be a Hecke algebra" % parent)
7476
AlgebraElement.__init__(self, parent)
7577

7678
def domain(self):
@@ -138,7 +140,7 @@ def hecke_module_morphism(self):
138140
M = self.domain()
139141
H = End(M)
140142
if isinstance(self, HeckeOperator):
141-
name = "T_%s"%self.index()
143+
name = "T_%s" % self.index()
142144
else:
143145
name = ""
144146
self.__hecke_module_morphism = morphism.HeckeModuleMorphism_matrix(H, T, name)
@@ -244,7 +246,7 @@ def apply_sparse(self, x):
244246
24*(1,0) - 5*(1,9)
245247
"""
246248
if x not in self.domain():
247-
raise TypeError("x (=%s) must be in %s"%(x, self.domain()))
249+
raise TypeError("x (=%s) must be in %s" % (x, self.domain()))
248250
# Generic implementation which doesn't actually do anything
249251
# special regarding sparseness. Override this for speed.
250252
T = self.hecke_module_morphism()
@@ -300,7 +302,7 @@ def decomposition(self):
300302
except AttributeError:
301303
pass
302304
if isinstance(self, HeckeOperator) and \
303-
arith.gcd(self.index(), self.domain().level()) == 1:
305+
arith.gcd(self.index(), self.domain().level()) == 1:
304306
D = self.hecke_module_morphism().decomposition(is_diagonalizable=True)
305307
else:
306308
# TODO: There are other weaker hypotheses that imply diagonalizability.
@@ -463,7 +465,7 @@ def _richcmp_(self, other, op):
463465
if isinstance(other, HeckeOperator):
464466
return richcmp(self, other.matrix_form(), op)
465467
else:
466-
raise RuntimeError("Bug in coercion code") # can't get here
468+
raise RuntimeError("Bug in coercion code") # can't get here
467469

468470
return richcmp(self.__matrix, other.__matrix, op)
469471

@@ -636,7 +638,7 @@ def _richcmp_(self, other, op):
636638
if isinstance(other, HeckeAlgebraElement_matrix):
637639
return richcmp(self.matrix_form(), other, op)
638640
else:
639-
raise RuntimeError("Bug in coercion code") # can't get here
641+
raise RuntimeError("Bug in coercion code") # can't get here
640642

641643
if self.__n == other.__n:
642644
return rich_to_bool(op, 0)
@@ -651,7 +653,7 @@ def _repr_(self):
651653
sage: ModularSymbols(Gamma0(7), 4).hecke_operator(6)._repr_()
652654
'Hecke operator T_6 on Modular Symbols space of dimension 4 for Gamma_0(7) of weight 4 with sign 0 over Rational Field'
653655
"""
654-
return "Hecke operator T_%s on %s"%(self.__n, self.domain())
656+
return "Hecke operator T_%s on %s" % (self.__n, self.domain())
655657

656658
def _latex_(self):
657659
r"""
@@ -662,15 +664,17 @@ def _latex_(self):
662664
sage: ModularSymbols(Gamma0(7), 4).hecke_operator(6)._latex_()
663665
'T_{6}'
664666
"""
665-
return "T_{%s}"%self.__n
667+
return "T_{%s}" % self.__n
666668

667669
def _mul_(self, other):
668-
"""
669-
Multiply this Hecke operator by another element of the same algebra. If
670-
the other element is of the form `T_m` for some m, we check whether the
671-
product is equal to `T_{mn}` and return that; if the product is not
672-
(easily seen to be) of the form `T_{mn}`, then we calculate the product
673-
of the two matrices and return a Hecke algebra element defined by that.
670+
r"""
671+
Multiply this Hecke operator by another element of the same algebra.
672+
673+
If the other element is of the form `T_m` for some m, we check
674+
whether the product is equal to `T_{mn}` and return that; if
675+
the product is not (easily seen to be) of the form `T_{mn}`,
676+
then we calculate the product of the two matrices and return a
677+
Hecke algebra element defined by that.
674678
675679
EXAMPLES: We create the space of modular symbols of level
676680
`11` and weight `2`, then compute `T_2`

src/sage/modular/hecke/homspace.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
r"""
22
Hom spaces between Hecke modules
33
"""
4-
#*****************************************************************************
4+
# ****************************************************************************
55
# Copyright (C) 2005 William Stein <[email protected]>
66
#
77
# Distributed under the terms of the GNU General Public License (GPL)
@@ -13,9 +13,8 @@
1313
# See the GNU General Public License for more details; the full text
1414
# is available at:
1515
#
16-
# http://www.gnu.org/licenses/
17-
#*****************************************************************************
18-
16+
# https://www.gnu.org/licenses/
17+
# ****************************************************************************
1918
from sage.matrix.constructor import matrix
2019
from sage.matrix.matrix_space import MatrixSpace
2120
from sage.categories.homset import HomsetWithBase
@@ -25,7 +24,7 @@
2524

2625
def is_HeckeModuleHomspace(x):
2726
r"""
28-
Return True if x is a space of homomorphisms in the category of Hecke modules.
27+
Return ``True`` if x is a space of homomorphisms in the category of Hecke modules.
2928
3029
EXAMPLES::
3130

0 commit comments

Comments
 (0)