Skip to content

Commit 14e9964

Browse files
author
Release Manager
committed
gh-39995: typing annotations for is_something in knots,quadratic_forms,quivers
add the annotation ` -> bool` where appropriate in the folders knots, quadratic_forms and quivers ### 📝 Checklist - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. URL: #39995 Reported by: Frédéric Chapoton Reviewer(s): Travis Scrimshaw
2 parents 8156226 + feb01b6 commit 14e9964

15 files changed

+70
-67
lines changed

build/pkgs/configure/checksums.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
tarball=configure-VERSION.tar.gz
2-
sha1=db1650ff7b9bb3d07adbf2c6c1d4be2e39c22920
3-
sha256=7998f8b4ce7b527248461f87b305752f18d07460792d157447bd31b45b0dbc3d
2+
sha1=2e6074ff61726a445d66964f794ee43f9082ce0e
3+
sha256=e93d25a29dd55079c84dd06dffac60a66daa7c4691bea662ac9ff2b2db779ff3
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
f5f628fca5c3bb985701204784f089d176a7caa6
1+
61d4cb41ea2e999bc68447f988cd0c7140456092

src/sage/knots/knotinfo.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ def matches(self, link):
448448
res.append(self.rev().mir())
449449
return res
450450

451-
def is_minimal(self, link):
451+
def is_minimal(self, link) -> bool:
452452
r"""
453453
Return whether ``self`` is minimal among its matching mutants.
454454
@@ -992,7 +992,7 @@ def signature(self):
992992
return knotinfo_int(self[self.items.signature])
993993

994994
@cached_method
995-
def is_knot(self):
995+
def is_knot(self) -> bool:
996996
r"""
997997
Return whether ``self`` is a knot or a proper link.
998998
@@ -1063,7 +1063,7 @@ class of an oriented pair, `K = (S_3, S_1)`, with `S_i`
10631063
return symmetry_type
10641064

10651065
@cached_method
1066-
def is_reversible(self):
1066+
def is_reversible(self) -> bool:
10671067
r"""
10681068
Return whether ``self`` is reversible.
10691069
@@ -1096,7 +1096,7 @@ def is_reversible(self):
10961096
return None
10971097

10981098
@cached_method
1099-
def is_amphicheiral(self, positive=False):
1099+
def is_amphicheiral(self, positive=False) -> bool:
11001100
r"""
11011101
Return whether ``self`` is amphicheiral.
11021102
@@ -1184,7 +1184,7 @@ def is_amphicheiral(self, positive=False):
11841184
return None
11851185

11861186
@cached_method
1187-
def is_hyperbolic(self):
1187+
def is_hyperbolic(self) -> bool:
11881188
r"""
11891189
Return whether ``self`` is hyperbolic.
11901190
@@ -1201,7 +1201,7 @@ def is_hyperbolic(self):
12011201
return False
12021202

12031203
@cached_method
1204-
def is_alternating(self):
1204+
def is_alternating(self) -> bool:
12051205
r"""
12061206
Return whether ``self`` is alternating.
12071207
@@ -1213,7 +1213,7 @@ def is_alternating(self):
12131213
return knotinfo_bool(self[self.items.alternating])
12141214

12151215
@cached_method
1216-
def is_almost_alternating(self):
1216+
def is_almost_alternating(self) -> bool:
12171217
r"""
12181218
Return whether ``self`` is almost alternating.
12191219
@@ -1226,7 +1226,7 @@ def is_almost_alternating(self):
12261226
return knotinfo_bool(self[self.items.almost_alternating])
12271227

12281228
@cached_method
1229-
def is_quasi_alternating(self):
1229+
def is_quasi_alternating(self) -> bool:
12301230
r"""
12311231
Return whether ``self`` is quasi alternating.
12321232
@@ -1239,7 +1239,7 @@ def is_quasi_alternating(self):
12391239
return knotinfo_bool(self[self.items.quasi_alternating])
12401240

12411241
@cached_method
1242-
def is_adequate(self):
1242+
def is_adequate(self) -> bool:
12431243
r"""
12441244
Return whether ``self`` is adequate.
12451245
@@ -1252,7 +1252,7 @@ def is_adequate(self):
12521252
return knotinfo_bool(self[self.items.adequate])
12531253

12541254
@cached_method
1255-
def is_positive(self):
1255+
def is_positive(self) -> bool:
12561256
r"""
12571257
Return whether ``self`` is positive.
12581258
@@ -1264,7 +1264,7 @@ def is_positive(self):
12641264
return knotinfo_bool(self[self.items.positive])
12651265

12661266
@cached_method
1267-
def is_quasipositive(self):
1267+
def is_quasipositive(self) -> bool:
12681268
r"""
12691269
Return whether ``self`` is quasi-positive.
12701270
@@ -1277,7 +1277,7 @@ def is_quasipositive(self):
12771277
return knotinfo_bool(self[self.items.quasipositive])
12781278

12791279
@cached_method
1280-
def is_strongly_quasipositive(self):
1280+
def is_strongly_quasipositive(self) -> bool:
12811281
r"""
12821282
Return whether ``self`` is strongly quasi-positive.
12831283
@@ -1290,7 +1290,7 @@ def is_strongly_quasipositive(self):
12901290
return knotinfo_bool(self[self.items.strongly_quasipositive])
12911291

12921292
@cached_method
1293-
def is_positive_braid(self):
1293+
def is_positive_braid(self) -> bool:
12941294
r"""
12951295
Return whether ``self`` is a positive braid.
12961296
@@ -1303,7 +1303,7 @@ def is_positive_braid(self):
13031303
return knotinfo_bool(self[self.items.positive_braid])
13041304

13051305
@cached_method
1306-
def is_fibered(self):
1306+
def is_fibered(self) -> bool:
13071307
r"""
13081308
Return whether ``self`` is fibered.
13091309
@@ -1315,7 +1315,7 @@ def is_fibered(self):
13151315
return knotinfo_bool(self[self.items.fibered])
13161316

13171317
@cached_method
1318-
def is_oriented(self):
1318+
def is_oriented(self) -> bool:
13191319
r"""
13201320
Return whether ``self`` is oriented.
13211321
@@ -2229,7 +2229,7 @@ def link(self, use_item=db.columns().pd_notation, snappy=False):
22292229
raise ValueError('link construction using %s not possible' % use_item)
22302230

22312231
@cached_method
2232-
def is_unique(self):
2232+
def is_unique(self) -> bool:
22332233
r"""
22342234
Return whether there is no other isotopic link in the database or not.
22352235
@@ -2275,7 +2275,7 @@ def is_unique(self):
22752275
return None
22762276

22772277
@cached_method
2278-
def is_recoverable(self, unique=True):
2278+
def is_recoverable(self, unique=True) -> bool:
22792279
r"""
22802280
Return if ``self`` can be recovered from its conversion to Sage links
22812281
using the ``pd_notation`` and the ``braid_notation`` and their
@@ -2788,7 +2788,7 @@ def _name(self):
27882788
res = 'L%s%s' % (cross_nr, alt)
27892789
return res
27902790

2791-
def is_recoverable(self, unique=True, max_samples=8):
2791+
def is_recoverable(self, unique=True, max_samples=8) -> bool:
27922792
r"""
27932793
Return if all items of ``self`` can be recovered from its conversion to
27942794
Sage links using the ``pd_notation`` and the ``braid_notation`` and their

src/sage/knots/link.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1777,7 +1777,7 @@ def number_of_components(self):
17771777
G.add_edge(c[3], c[1])
17781778
return G.connected_components_number()
17791779

1780-
def is_knot(self):
1780+
def is_knot(self) -> bool:
17811781
r"""
17821782
Return ``True`` if ``self`` is a knot.
17831783
@@ -2147,7 +2147,7 @@ def determinant(self):
21472147
m = V + V.transpose()
21482148
return Integer(abs(m.det()))
21492149

2150-
def is_alternating(self):
2150+
def is_alternating(self) -> bool:
21512151
r"""
21522152
Return whether the given knot diagram is alternating.
21532153
@@ -3200,7 +3200,7 @@ def _coloring_matrix(self, n=None):
32003200
M[i, j] -= 1
32013201
return M
32023202

3203-
def is_colorable(self, n=None):
3203+
def is_colorable(self, n=None) -> bool:
32043204
r"""
32053205
Return whether the link is ``n``-colorable.
32063206
@@ -4517,7 +4517,7 @@ def answer_list(l):
45174517

45184518
return answer_list(l)
45194519

4520-
def is_isotopic(self, other):
4520+
def is_isotopic(self, other) -> bool:
45214521
r"""
45224522
Check whether ``self`` is isotopic to ``other``.
45234523

src/sage/quadratic_forms/binary_qf.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,7 +1214,7 @@ def cycle(self, proper=False):
12141214
self._cycle_list = C
12151215
return self._cycle_list
12161216

1217-
def is_positive_definite(self):
1217+
def is_positive_definite(self) -> bool:
12181218
"""
12191219
Return ``True`` if ``self`` is positive definite, i.e., has
12201220
negative discriminant with `a > 0`.
@@ -1232,7 +1232,7 @@ def is_positive_definite(self):
12321232

12331233
is_posdef = is_positive_definite
12341234

1235-
def is_negative_definite(self):
1235+
def is_negative_definite(self) -> bool:
12361236
"""
12371237
Return ``True`` if ``self`` is negative definite, i.e., has
12381238
negative discriminant with `a < 0`.
@@ -1249,7 +1249,7 @@ def is_negative_definite(self):
12491249

12501250
is_negdef = is_negative_definite
12511251

1252-
def is_indefinite(self):
1252+
def is_indefinite(self) -> bool:
12531253
"""
12541254
Return whether ``self`` is indefinite, i.e., has positive discriminant.
12551255
@@ -1263,7 +1263,7 @@ def is_indefinite(self):
12631263

12641264
is_indef = is_indefinite
12651265

1266-
def is_singular(self):
1266+
def is_singular(self) -> bool:
12671267
"""
12681268
Return whether ``self`` is singular, i.e., has zero discriminant.
12691269
@@ -1278,7 +1278,7 @@ def is_singular(self):
12781278
"""
12791279
return self.discriminant().is_zero()
12801280

1281-
def is_nonsingular(self):
1281+
def is_nonsingular(self) -> bool:
12821282
"""
12831283
Return whether this form is nonsingular, i.e., has nonzero discriminant.
12841284
@@ -1293,7 +1293,7 @@ def is_nonsingular(self):
12931293
"""
12941294
return not self.discriminant().is_zero()
12951295

1296-
def is_equivalent(self, other, proper=True):
1296+
def is_equivalent(self, other, proper=True) -> bool:
12971297
"""
12981298
Return whether ``self`` is equivalent to ``other``.
12991299
@@ -1423,7 +1423,7 @@ def is_equivalent(self, other, proper=True):
14231423
return False
14241424

14251425
@cached_method
1426-
def is_reduced(self):
1426+
def is_reduced(self) -> bool:
14271427
r"""
14281428
Return whether ``self`` is reduced.
14291429

src/sage/quadratic_forms/bqf_class_group.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ def __lt__(self, other):
569569
"""
570570
return self._form < other._form
571571

572-
def __bool__(self):
572+
def __bool__(self) -> bool:
573573
r"""
574574
Return ``True`` if this form class is *not* the principal class
575575
and ``False`` otherwise.
@@ -584,7 +584,7 @@ def __bool__(self):
584584
"""
585585
return self != self.parent().zero()
586586

587-
def is_zero(self):
587+
def is_zero(self) -> bool:
588588
r"""
589589
Return ``True`` if this form class is the principal class and
590590
``False`` otherwise.
@@ -599,7 +599,7 @@ def is_zero(self):
599599
"""
600600
return not self
601601

602-
def __repr__(self):
602+
def __repr__(self) -> str:
603603
r"""
604604
Return a string representation of this form class.
605605

src/sage/quadratic_forms/extras.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from sage.rings.integer_ring import ZZ
99

1010

11-
def is_triangular_number(n, return_value=False):
11+
def is_triangular_number(n, return_value=False) -> bool | tuple:
1212
"""
1313
Return whether ``n`` is a triangular number.
1414

src/sage/quadratic_forms/genera/genus.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -942,9 +942,9 @@ def p_adic_symbol(A, p, val):
942942
return [[s[0]+m0] + s[1:] for s in sym + p_adic_symbol(A, p, val)]
943943

944944

945-
def is_even_matrix(A):
945+
def is_even_matrix(A) -> tuple[bool, int]:
946946
r"""
947-
Determines if the integral symmetric matrix `A` is even
947+
Determine if the integral symmetric matrix `A` is even
948948
(i.e. represents only even numbers). If not, then it returns the
949949
index of an odd diagonal entry. If it is even, then we return the
950950
index `-1`.
@@ -1914,7 +1914,7 @@ def prime(self):
19141914
"""
19151915
return self._prime
19161916

1917-
def is_even(self):
1917+
def is_even(self) -> bool:
19181918
r"""
19191919
Return if the underlying `p`-adic lattice is even.
19201920

src/sage/quadratic_forms/quadratic_form__equivalence_testing.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
66
- Anna Haensch (2014-12-01): added test for rational isometry
77
"""
8+
from typing import Any
9+
810
from sage.arith.misc import (hilbert_symbol,
911
GCD,
1012
is_prime,
@@ -20,7 +22,7 @@
2022
# (For now, we require both forms to be positive definite.) #
2123
##############################################################################
2224

23-
def is_globally_equivalent_to(self, other, return_matrix=False):
25+
def is_globally_equivalent_to(self, other, return_matrix=False) -> bool | Any:
2426
r"""
2527
Determine if the current quadratic form is equivalent to the
2628
given form over `\ZZ`.
@@ -114,7 +116,8 @@ def is_globally_equivalent_to(self, other, return_matrix=False):
114116
return True
115117

116118

117-
def is_locally_equivalent_to(self, other, check_primes_only=False, force_jordan_equivalence_test=False):
119+
def is_locally_equivalent_to(self, other, check_primes_only=False,
120+
force_jordan_equivalence_test=False) -> bool:
118121
r"""
119122
Determine if the current quadratic form (defined over `\ZZ`) is
120123
locally equivalent to the given form over the real numbers and the
@@ -298,7 +301,7 @@ def has_equivalent_Jordan_decomposition_at_prime(self, other, p):
298301
raise TypeError("this should not have happened")
299302

300303

301-
def is_rationally_isometric(self, other, return_matrix=False):
304+
def is_rationally_isometric(self, other, return_matrix=False) -> bool | Any:
302305
"""
303306
Determine if two regular quadratic forms over a number field are isometric.
304307

0 commit comments

Comments
 (0)