Skip to content

Commit edf324e

Browse files
author
Release Manager
committed
gh-39987: add some typing annotations in modular folder This is adding the `-> bool` annotation to many functions and methods in the modular folder. ### 📝 Checklist - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. URL: #39987 Reported by: Frédéric Chapoton Reviewer(s): Vincent Macri
2 parents 0ab46d1 + e12041c commit edf324e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+165
-167
lines changed

src/sage/modular/abvar/abvar.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1609,7 +1609,7 @@ def project_to_factor(self, n):
16091609

16101610
return H(Morphism(H, mat))
16111611

1612-
def is_subvariety_of_ambient_jacobian(self):
1612+
def is_subvariety_of_ambient_jacobian(self) -> bool:
16131613
"""
16141614
Return ``True`` if ``self`` is (presented as) a subvariety of the ambient
16151615
product Jacobian.
@@ -3230,10 +3230,11 @@ def isogeny_number(self, none_if_not_known=False):
32303230
else:
32313231
raise ValueError("self must be simple")
32323232

3233-
def is_simple(self, none_if_not_known=False):
3233+
def is_simple(self, none_if_not_known=False) -> bool:
32343234
"""
3235-
Return whether or not this modular abelian variety is simple, i.e.,
3236-
has no proper nonzero abelian subvarieties.
3235+
Return whether or not this modular abelian variety is simple.
3236+
3237+
This means that it has no proper nonzero abelian subvarieties.
32373238
32383239
INPUT:
32393240
@@ -4241,7 +4242,7 @@ def group(self):
42414242
"""
42424243
return self.modular_symbols().group()
42434244

4244-
def is_subvariety(self, other):
4245+
def is_subvariety(self, other) -> bool:
42454246
"""
42464247
Return ``True`` if ``self`` is a subvariety of ``other``.
42474248
@@ -4294,7 +4295,7 @@ def is_subvariety(self, other):
42944295
return ModularAbelianVariety_abstract.is_subvariety(self, other)
42954296
return self.modular_symbols().is_submodule(other.modular_symbols())
42964297

4297-
def is_ambient(self):
4298+
def is_ambient(self) -> bool:
42984299
"""
42994300
Return ``True`` if this abelian variety attached to a modular symbols
43004301
space is attached to the cuspidal subspace of the ambient

src/sage/modular/abvar/cuspidal_subgroup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ def lattice(self):
337337
return lattice
338338

339339

340-
def is_rational_cusp_gamma0(c, N, data):
340+
def is_rational_cusp_gamma0(c, N, data) -> bool:
341341
"""
342342
Return ``True`` if the rational number c is a rational cusp of level N.
343343

src/sage/modular/abvar/finite_subgroup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,10 +263,10 @@ def __richcmp__(self, other, op):
263263
# order gets reversed in passing to lattices.
264264
return lx._echelon_matrix_richcmp(rx, op)
265265

266-
def is_subgroup(self, other):
266+
def is_subgroup(self, other) -> bool:
267267
"""
268-
Return ``True`` exactly if ``self`` is a subgroup of ``other``, and both are
269-
defined as subgroups of the same ambient abelian variety.
268+
Return ``True`` exactly if ``self`` is a subgroup of ``other``,
269+
and both are defined as subgroups of the same ambient abelian variety.
270270
271271
EXAMPLES::
272272

src/sage/modular/abvar/morphism.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def complementary_isogeny(self):
117117
iM, denom = iM._clear_denom()
118118
return Morphism(self.parent().reversed(), iM)
119119

120-
def is_isogeny(self):
120+
def is_isogeny(self) -> bool:
121121
"""
122122
Return ``True`` if this morphism is an isogeny of abelian varieties.
123123

src/sage/modular/arithgroup/arithgroup_perm.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,7 +1116,7 @@ def permutation_action(self, x):
11161116
# Group stuff
11171117
#
11181118

1119-
def is_normal(self):
1119+
def is_normal(self) -> bool:
11201120
r"""
11211121
Test whether the group is normal.
11221122
@@ -1134,9 +1134,9 @@ def is_normal(self):
11341134
G = self.relabel(inplace=False)
11351135
s2 = G._S2
11361136
s3 = G._S3
1137-
ss2 = [None]*N
1138-
ss3 = [None]*N
1139-
for j in [s2[0],s3[0]]:
1137+
ss2 = [None] * N
1138+
ss3 = [None] * N
1139+
for j in [s2[0], s3[0]]:
11401140
m = G._canonical_rooted_labels(j)
11411141
for i in range(N):
11421142
ss2[m[i]] = m[s2[i]]
@@ -1332,7 +1332,7 @@ def congruence_closure(self):
13321332
from .congroup_generic import CongruenceSubgroup_constructor as CS
13331333
return CS(N, [x.matrix() for x in self.gens()])
13341334

1335-
def is_congruence(self):
1335+
def is_congruence(self) -> bool:
13361336
r"""
13371337
Return ``True`` if this is a congruence subgroup, and ``False``
13381338
otherwise.
@@ -1433,14 +1433,14 @@ def is_congruence(self):
14331433
True
14341434
"""
14351435
from sage.misc.verbose import verbose
1436-
if self.index() == 1: # the group is SL2Z (trivial case)
1436+
if self.index() == 1: # the group is SL2Z (trivial case)
14371437
return True
14381438

1439-
L = self.L() # action of L
1440-
R = self.R() # action of R
1439+
L = self.L() # action of L
1440+
R = self.R() # action of R
14411441

14421442
if self.is_even():
1443-
N = L.order() # generalised level of the group
1443+
N = L.order() # generalised level of the group
14441444
else:
14451445
N = 2 * L.order()
14461446

@@ -1451,13 +1451,13 @@ def is_congruence(self):
14511451
if e == 1:
14521452
# N is odd
14531453
# this only gets called if self is even
1454-
onehalf = ZZ(2).inverse_mod(N) # i.e. 2^(-1) mod N
1454+
onehalf = ZZ(2).inverse_mod(N) # i.e. 2^(-1) mod N
14551455
rel = (R*R*L**(-onehalf))**3
14561456
return rel.is_one()
14571457

14581458
elif m == 1:
14591459
# N is a power of 2
1460-
onefifth = ZZ(5).inverse_mod(N) # i.e. 5^(-1) mod N
1460+
onefifth = ZZ(5).inverse_mod(N) # i.e. 5^(-1) mod N
14611461
S = L**20*R**onefifth*L**(-4)*~R
14621462

14631463
# congruence if the three below permutations are trivial
@@ -1630,7 +1630,7 @@ def __reduce__(self):
16301630
return (OddArithmeticSubgroup_Permutation,
16311631
(self._S2,self._S3,self._L,self._R,canonical_labels))
16321632

1633-
def is_odd(self):
1633+
def is_odd(self) -> bool:
16341634
r"""
16351635
Test whether the group is odd.
16361636
@@ -1642,7 +1642,7 @@ def is_odd(self):
16421642
"""
16431643
return True
16441644

1645-
def is_even(self):
1645+
def is_even(self) -> bool:
16461646
r"""
16471647
Test whether the group is even.
16481648
@@ -1947,7 +1947,7 @@ def __reduce__(self):
19471947
return (EvenArithmeticSubgroup_Permutation,
19481948
(self._S2, self._S3, self._L, self._R, canonical_labels))
19491949

1950-
def is_odd(self):
1950+
def is_odd(self) -> bool:
19511951
r"""
19521952
Return ``True`` if this subgroup does not contain the matrix `-Id`.
19531953
@@ -1959,7 +1959,7 @@ def is_odd(self):
19591959
"""
19601960
return False
19611961

1962-
def is_even(self):
1962+
def is_even(self) -> bool:
19631963
r"""
19641964
Return ``True`` if this subgroup contains the matrix `-Id`.
19651965

src/sage/modular/arithgroup/congroup_gamma0.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ def divisor_subgroups(self):
244244
"""
245245
return [Gamma0_constructor(M) for M in self.level().divisors()]
246246

247-
def is_even(self):
247+
def is_even(self) -> bool:
248248
r"""
249249
Return ``True`` precisely if this subgroup contains the matrix -1.
250250
@@ -260,7 +260,7 @@ def is_even(self):
260260
"""
261261
return True
262262

263-
def is_subgroup(self, right):
263+
def is_subgroup(self, right) -> bool:
264264
"""
265265
Return ``True`` if ``self`` is a subgroup of ``right``.
266266

src/sage/modular/arithgroup/congroup_gamma1.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def __reduce__(self):
136136
"""
137137
return Gamma1_constructor, (self.level(),)
138138

139-
def _latex_(self):
139+
def _latex_(self) -> str:
140140
r"""
141141
Return the \LaTeX representation of ``self``.
142142
@@ -149,7 +149,7 @@ def _latex_(self):
149149
"""
150150
return "\\Gamma_1(%s)" % self.level()
151151

152-
def is_even(self):
152+
def is_even(self) -> bool:
153153
"""
154154
Return ``True`` precisely if this subgroup contains the matrix -1.
155155
@@ -162,9 +162,9 @@ def is_even(self):
162162
sage: Gamma1(15).is_even()
163163
False
164164
"""
165-
return self.level() in [1,2]
165+
return self.level() in [1, 2]
166166

167-
def is_subgroup(self, right):
167+
def is_subgroup(self, right) -> bool:
168168
"""
169169
Return ``True`` if ``self`` is a subgroup of ``right``.
170170

src/sage/modular/arithgroup/congroup_gammaH.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ def _list_of_elements_in_H(self):
434434
"""
435435
return self.__Hlist
436436

437-
def is_even(self):
437+
def is_even(self) -> bool:
438438
"""
439439
Return ``True`` precisely if this subgroup contains the matrix -1.
440440
@@ -1001,7 +1001,7 @@ def coset_reps(self):
10011001
for t in reps2:
10021002
yield SL2Z(t) * r
10031003

1004-
def is_subgroup(self, other):
1004+
def is_subgroup(self, other) -> bool:
10051005
r"""
10061006
Return ``True`` if ``self`` is a subgroup of ``right``, and ``False``
10071007
otherwise.

src/sage/modular/arithgroup/congroup_generic.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ def _an_element_(self):
180180
N = self.level()
181181
return self([1-N, -N, N, 1+N])
182182

183-
def is_congruence(self):
183+
def is_congruence(self) -> bool:
184184
r"""
185185
Return ``True``, since this is a congruence subgroup.
186186
@@ -189,7 +189,6 @@ def is_congruence(self):
189189
sage: Gamma0(7).is_congruence()
190190
True
191191
"""
192-
193192
return True
194193

195194
def level(self):

src/sage/modular/arithgroup/congroup_sl2z.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#
1515
# The full text of the GPL is available at:
1616
#
17-
# http://www.gnu.org/licenses/
17+
# https://www.gnu.org/licenses/
1818
#
1919
################################################################################
2020

@@ -140,7 +140,7 @@ def _repr_(self):
140140
"""
141141
return "Modular Group SL(2,Z)"
142142

143-
def _latex_(self):
143+
def _latex_(self) -> str:
144144
r"""
145145
Return the \LaTeX representation of ``self``.
146146
@@ -153,7 +153,7 @@ def _latex_(self):
153153
"""
154154
return "\\mbox{\\rm SL}_2(%s)" % (ZZ._latex_())
155155

156-
def is_subgroup(self, right):
156+
def is_subgroup(self, right) -> bool:
157157
"""
158158
Return ``True`` if ``self`` is a subgroup of ``right``.
159159

0 commit comments

Comments
 (0)