Skip to content

Commit 8156226

Browse files
author
Release Manager
committed
gh-39994: typing annotation for is_something in modules/ This is adding the annotation `-> bool` in appropriate places in `modules/` folder ### 📝 Checklist - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. URL: #39994 Reported by: Frédéric Chapoton Reviewer(s): Travis Scrimshaw
2 parents a5b9756 + 56ba45e commit 8156226

19 files changed

+58
-58
lines changed

src/sage/modules/fg_pid/fgp_module.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,7 @@ def has_canonical_map_to(self, A):
795795
return True
796796
return self.V().is_submodule(A.V()) and self.W().is_submodule(A.W())
797797

798-
def is_submodule(self, A):
798+
def is_submodule(self, A) -> bool:
799799
"""
800800
Return ``True`` if ``self`` is a submodule of ``A``.
801801
@@ -1864,7 +1864,7 @@ def construction(self):
18641864
from sage.modules.module_functors import QuotientModuleFunctor
18651865
return (QuotientModuleFunctor(self._W), self._V)
18661866

1867-
def is_finite(self):
1867+
def is_finite(self) -> bool:
18681868
"""
18691869
Return ``True`` if ``self`` is finite and ``False`` otherwise.
18701870

src/sage/modules/filtered_vector_space.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ def ambient_vector_space(self):
517517
return VectorSpace(self.base_ring(), self.dimension())
518518

519519
@cached_method
520-
def is_constant(self):
520+
def is_constant(self) -> bool:
521521
"""
522522
Return whether the filtration is constant.
523523
@@ -544,7 +544,7 @@ def is_constant(self):
544544
f = self._filt
545545
return (len(f) == 1) or (len(f) == 2 and f[1][0] == infinity)
546546

547-
def is_exhaustive(self):
547+
def is_exhaustive(self) -> bool:
548548
r"""
549549
Return whether the filtration is exhaustive.
550550
@@ -567,7 +567,7 @@ def is_exhaustive(self):
567567
return self.get_degree(minus_infinity).dimension() == \
568568
self.ambient_vector_space().dimension()
569569

570-
def is_separating(self):
570+
def is_separating(self) -> bool:
571571
r"""
572572
Return whether the filtration is separating.
573573

src/sage/modules/fp_graded/free_module.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ def generator_degrees(self):
501501
"""
502502
return self._generator_degrees
503503

504-
def is_trivial(self):
504+
def is_trivial(self) -> bool:
505505
r"""
506506
Return ``True`` if this module is trivial and ``False`` otherwise.
507507

src/sage/modules/fp_graded/module.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ def connectivity(self):
564564

565565
return infinity
566566

567-
def is_trivial(self):
567+
def is_trivial(self) -> bool:
568568
r"""
569569
Return ``True`` if ``self`` is isomorphic to the trivial module
570570
and ``False`` otherwise.
@@ -599,7 +599,7 @@ def is_trivial(self):
599599
"""
600600
return self.connectivity() == infinity
601601

602-
def has_relations(self):
602+
def has_relations(self) -> bool:
603603
r"""
604604
Return ``True`` if no relations are defined, and ``False``
605605
otherwise.

src/sage/modules/fp_graded/morphism.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ def __mul__(self, g):
611611
return homset([self(g(x)) for x in g.domain().generators()])
612612

613613
@cached_method
614-
def is_zero(self):
614+
def is_zero(self) -> bool:
615615
r"""
616616
Decide if ``self`` is the zero homomorphism.
617617
@@ -647,7 +647,7 @@ def is_zero(self):
647647
__bool__ = is_zero
648648

649649
@cached_method
650-
def is_identity(self):
650+
def is_identity(self) -> bool:
651651
r"""
652652
Decide if ``self`` is the identity endomorphism.
653653
@@ -1583,7 +1583,7 @@ def image(self, top_dim=None, verbose=False):
15831583
# its image equals im(self)
15841584
return Hom(I, j0.codomain())(j0._values)
15851585

1586-
def is_injective(self, top_dim=None, verbose=False):
1586+
def is_injective(self, top_dim=None, verbose=False) -> bool:
15871587
r"""
15881588
Return ``True`` if and only if ``self`` has a trivial kernel.
15891589
@@ -1614,7 +1614,7 @@ def is_injective(self, top_dim=None, verbose=False):
16141614
j0 = self._resolve_kernel(top_dim, verbose)
16151615
return j0.domain().is_trivial()
16161616

1617-
def is_surjective(self):
1617+
def is_surjective(self) -> bool:
16181618
r"""
16191619
Return ``True`` if and only if ``self`` has a trivial cokernel.
16201620

src/sage/modules/fp_graded/steenrod/morphism.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def _flatten(f):
9090
return enveloping_profile_elements(elements,
9191
char=self.base_ring().characteristic())
9292

93-
def is_injective(self, top_dim=None, verbose=False):
93+
def is_injective(self, top_dim=None, verbose=False) -> bool:
9494
r"""
9595
Return ``True`` if ``self`` is injective.
9696

src/sage/modules/free_module.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -984,7 +984,7 @@ def degree(self):
984984
"""
985985
return self.__degree
986986

987-
def is_sparse(self):
987+
def is_sparse(self) -> bool:
988988
"""
989989
Return ``True`` if the underlying representation of this module uses
990990
sparse vectors, and ``False`` otherwise.
@@ -998,7 +998,7 @@ def is_sparse(self):
998998
"""
999999
return self.__is_sparse
10001000

1001-
def is_exact(self):
1001+
def is_exact(self) -> bool:
10021002
"""
10031003
Test whether elements of this module are represented exactly.
10041004
@@ -1517,7 +1517,7 @@ def _eq(self, other):
15171517
# in the same ambient space
15181518
return self.is_submodule(other) and other.is_submodule(self)
15191519

1520-
def is_submodule(self, other):
1520+
def is_submodule(self, other) -> bool:
15211521
r"""
15221522
Return ``True`` if ``self`` is a submodule of ``other``.
15231523
@@ -2303,7 +2303,7 @@ def _eq(self, other):
23032303
return self.echelonized_basis_matrix() == other.echelonized_basis_matrix()
23042304
return self.is_submodule(other) and other.is_submodule(self)
23052305

2306-
def is_submodule(self, other):
2306+
def is_submodule(self, other) -> bool:
23072307
r"""
23082308
Return ``True`` if ``self`` is a submodule of ``other``.
23092309
@@ -3285,7 +3285,7 @@ def _inner_product_is_dot_product(self):
32853285
"""
32863286
return True
32873287

3288-
def is_ambient(self):
3288+
def is_ambient(self) -> bool:
32893289
"""
32903290
Return ``False`` since this is not an ambient free module.
32913291
@@ -3310,7 +3310,7 @@ def is_ambient(self):
33103310
"""
33113311
return False
33123312

3313-
def is_dense(self):
3313+
def is_dense(self) -> bool:
33143314
"""
33153315
Return ``True`` if the underlying representation of
33163316
this module uses dense vectors, and ``False`` otherwise.
@@ -3324,7 +3324,7 @@ def is_dense(self):
33243324
"""
33253325
return not self.is_sparse()
33263326

3327-
def is_full(self):
3327+
def is_full(self) -> bool:
33283328
"""
33293329
Return ``True`` if the rank of this module equals its
33303330
degree.
@@ -3339,7 +3339,7 @@ def is_full(self):
33393339
"""
33403340
return self.rank() == self.degree()
33413341

3342-
def is_finite(self):
3342+
def is_finite(self) -> bool:
33433343
"""
33443344
Return ``True`` if the underlying set of this free module is finite.
33453345
@@ -4754,7 +4754,7 @@ def intersection(self, other):
47544754
B = [A1.linear_combination_of_rows(v.list()[:n]) for v in K.basis()]
47554755
return self.ambient_vector_space().submodule(B, check=False)
47564756

4757-
def is_subspace(self, other):
4757+
def is_subspace(self, other) -> bool:
47584758
"""
47594759
``True`` if this vector space is a subspace of ``other``.
47604760
@@ -5800,7 +5800,7 @@ def _latex_(self):
58005800
t = "(%s)" % t
58015801
return "%s^{%s}" % (t, self.rank())
58025802

5803-
def is_ambient(self):
5803+
def is_ambient(self) -> bool:
58045804
"""
58055805
Return ``True`` since this module is an ambient
58065806
module.
@@ -8011,7 +8011,7 @@ def _echelonized_basis(self, ambient, basis):
80118011
# Return the first rank rows (i.e., the nonzero rows).
80128012
return E.rows()[:E.rank()]
80138013

8014-
def is_ambient(self):
8014+
def is_ambient(self) -> bool:
80158015
"""
80168016
Return ``False`` since this is not an ambient module.
80178017

src/sage/modules/free_module_element.pyx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3619,9 +3619,9 @@ cdef class FreeModuleElement(Vector): # abstract base class
36193619
...
36203620
ArithmeticError: degrees (1 and 2) must be the same
36213621
"""
3622-
return (self.conjugate()).dot_product(right)
3622+
return self.conjugate().dot_product(right)
36233623

3624-
def is_dense(self):
3624+
def is_dense(self) -> bool:
36253625
"""
36263626
Return ``True`` if this is a dense vector, which is just a
36273627
statement about the data structure, not the number of nonzero
@@ -3639,7 +3639,7 @@ cdef class FreeModuleElement(Vector): # abstract base class
36393639
cdef bint is_dense_c(self) noexcept:
36403640
return self.parent().is_dense()
36413641

3642-
def is_sparse(self):
3642+
def is_sparse(self) -> bool:
36433643
"""
36443644
Return ``True`` if this is a sparse vector, which is just a
36453645
statement about the data structure, not the number of nonzero
@@ -3657,7 +3657,7 @@ cdef class FreeModuleElement(Vector): # abstract base class
36573657
cdef bint is_sparse_c(self) noexcept:
36583658
return self.parent().is_sparse()
36593659

3660-
def is_vector(self):
3660+
def is_vector(self) -> bool:
36613661
"""
36623662
Return ``True``, since this is a vector.
36633663

src/sage/modules/free_module_integer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ def discriminant(self):
509509
return abs(self.gram_matrix().determinant())
510510

511511
@cached_method
512-
def is_unimodular(self):
512+
def is_unimodular(self) -> bool:
513513
"""
514514
Return ``True`` if this lattice is unimodular.
515515

src/sage/modules/free_module_morphism.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ class BaseIsomorphism1D(Morphism):
658658
Multivariate Polynomial Ring in x, y over Rational Field
659659
To: Multivariate Polynomial Ring in x, y over Rational Field
660660
"""
661-
def _repr_type(self):
661+
def _repr_type(self) -> str:
662662
r"""
663663
EXAMPLES::
664664
@@ -669,7 +669,7 @@ def _repr_type(self):
669669
"""
670670
return "Isomorphism"
671671

672-
def is_injective(self):
672+
def is_injective(self) -> bool:
673673
r"""
674674
EXAMPLES::
675675
@@ -680,7 +680,7 @@ def is_injective(self):
680680
"""
681681
return True
682682

683-
def is_surjective(self):
683+
def is_surjective(self) -> bool:
684684
r"""
685685
EXAMPLES::
686686

0 commit comments

Comments
 (0)