Skip to content

typing annotation for is_something in modules/ #39994

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 29, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/sage/modules/fg_pid/fgp_module.py
Original file line number Diff line number Diff line change
@@ -795,7 +795,7 @@ def has_canonical_map_to(self, A):
return True
return self.V().is_submodule(A.V()) and self.W().is_submodule(A.W())

def is_submodule(self, A):
def is_submodule(self, A) -> bool:
"""
Return ``True`` if ``self`` is a submodule of ``A``.

@@ -1864,7 +1864,7 @@ def construction(self):
from sage.modules.module_functors import QuotientModuleFunctor
return (QuotientModuleFunctor(self._W), self._V)

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

6 changes: 3 additions & 3 deletions src/sage/modules/filtered_vector_space.py
Original file line number Diff line number Diff line change
@@ -517,7 +517,7 @@ def ambient_vector_space(self):
return VectorSpace(self.base_ring(), self.dimension())

@cached_method
def is_constant(self):
def is_constant(self) -> bool:
"""
Return whether the filtration is constant.

@@ -544,7 +544,7 @@ def is_constant(self):
f = self._filt
return (len(f) == 1) or (len(f) == 2 and f[1][0] == infinity)

def is_exhaustive(self):
def is_exhaustive(self) -> bool:
r"""
Return whether the filtration is exhaustive.

@@ -567,7 +567,7 @@ def is_exhaustive(self):
return self.get_degree(minus_infinity).dimension() == \
self.ambient_vector_space().dimension()

def is_separating(self):
def is_separating(self) -> bool:
r"""
Return whether the filtration is separating.

2 changes: 1 addition & 1 deletion src/sage/modules/fp_graded/free_module.py
Original file line number Diff line number Diff line change
@@ -501,7 +501,7 @@ def generator_degrees(self):
"""
return self._generator_degrees

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

4 changes: 2 additions & 2 deletions src/sage/modules/fp_graded/module.py
Original file line number Diff line number Diff line change
@@ -564,7 +564,7 @@ def connectivity(self):

return infinity

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

def has_relations(self):
def has_relations(self) -> bool:
r"""
Return ``True`` if no relations are defined, and ``False``
otherwise.
8 changes: 4 additions & 4 deletions src/sage/modules/fp_graded/morphism.py
Original file line number Diff line number Diff line change
@@ -611,7 +611,7 @@ def __mul__(self, g):
return homset([self(g(x)) for x in g.domain().generators()])

@cached_method
def is_zero(self):
def is_zero(self) -> bool:
r"""
Decide if ``self`` is the zero homomorphism.

@@ -647,7 +647,7 @@ def is_zero(self):
__bool__ = is_zero

@cached_method
def is_identity(self):
def is_identity(self) -> bool:
r"""
Decide if ``self`` is the identity endomorphism.

@@ -1583,7 +1583,7 @@ def image(self, top_dim=None, verbose=False):
# its image equals im(self)
return Hom(I, j0.codomain())(j0._values)

def is_injective(self, top_dim=None, verbose=False):
def is_injective(self, top_dim=None, verbose=False) -> bool:
r"""
Return ``True`` if and only if ``self`` has a trivial kernel.

@@ -1614,7 +1614,7 @@ def is_injective(self, top_dim=None, verbose=False):
j0 = self._resolve_kernel(top_dim, verbose)
return j0.domain().is_trivial()

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

2 changes: 1 addition & 1 deletion src/sage/modules/fp_graded/steenrod/morphism.py
Original file line number Diff line number Diff line change
@@ -90,7 +90,7 @@ def _flatten(f):
return enveloping_profile_elements(elements,
char=self.base_ring().characteristic())

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

22 changes: 11 additions & 11 deletions src/sage/modules/free_module.py
Original file line number Diff line number Diff line change
@@ -984,7 +984,7 @@ def degree(self):
"""
return self.__degree

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

def is_exact(self):
def is_exact(self) -> bool:
"""
Test whether elements of this module are represented exactly.

@@ -1517,7 +1517,7 @@ def _eq(self, other):
# in the same ambient space
return self.is_submodule(other) and other.is_submodule(self)

def is_submodule(self, other):
def is_submodule(self, other) -> bool:
r"""
Return ``True`` if ``self`` is a submodule of ``other``.

@@ -2303,7 +2303,7 @@ def _eq(self, other):
return self.echelonized_basis_matrix() == other.echelonized_basis_matrix()
return self.is_submodule(other) and other.is_submodule(self)

def is_submodule(self, other):
def is_submodule(self, other) -> bool:
r"""
Return ``True`` if ``self`` is a submodule of ``other``.

@@ -3285,7 +3285,7 @@ def _inner_product_is_dot_product(self):
"""
return True

def is_ambient(self):
def is_ambient(self) -> bool:
"""
Return ``False`` since this is not an ambient free module.

@@ -3310,7 +3310,7 @@ def is_ambient(self):
"""
return False

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

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

def is_finite(self):
def is_finite(self) -> bool:
"""
Return ``True`` if the underlying set of this free module is finite.

@@ -4754,7 +4754,7 @@ def intersection(self, other):
B = [A1.linear_combination_of_rows(v.list()[:n]) for v in K.basis()]
return self.ambient_vector_space().submodule(B, check=False)

def is_subspace(self, other):
def is_subspace(self, other) -> bool:
"""
``True`` if this vector space is a subspace of ``other``.

@@ -5800,7 +5800,7 @@ def _latex_(self):
t = "(%s)" % t
return "%s^{%s}" % (t, self.rank())

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

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

8 changes: 4 additions & 4 deletions src/sage/modules/free_module_element.pyx
Original file line number Diff line number Diff line change
@@ -3619,9 +3619,9 @@ cdef class FreeModuleElement(Vector): # abstract base class
...
ArithmeticError: degrees (1 and 2) must be the same
"""
return (self.conjugate()).dot_product(right)
return self.conjugate().dot_product(right)

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

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

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

2 changes: 1 addition & 1 deletion src/sage/modules/free_module_integer.py
Original file line number Diff line number Diff line change
@@ -509,7 +509,7 @@ def discriminant(self):
return abs(self.gram_matrix().determinant())

@cached_method
def is_unimodular(self):
def is_unimodular(self) -> bool:
"""
Return ``True`` if this lattice is unimodular.

6 changes: 3 additions & 3 deletions src/sage/modules/free_module_morphism.py
Original file line number Diff line number Diff line change
@@ -658,7 +658,7 @@ class BaseIsomorphism1D(Morphism):
Multivariate Polynomial Ring in x, y over Rational Field
To: Multivariate Polynomial Ring in x, y over Rational Field
"""
def _repr_type(self):
def _repr_type(self) -> str:
r"""
EXAMPLES::

@@ -669,7 +669,7 @@ def _repr_type(self):
"""
return "Isomorphism"

def is_injective(self):
def is_injective(self) -> bool:
r"""
EXAMPLES::

@@ -680,7 +680,7 @@ def is_injective(self):
"""
return True

def is_surjective(self):
def is_surjective(self) -> bool:
r"""
EXAMPLES::

Original file line number Diff line number Diff line change
@@ -733,7 +733,7 @@ def _repr_(self):
return s

@cached_method
def is_even(self):
def is_even(self) -> bool:
r"""
Return whether the diagonal entries of the Gram matrix are even.

18 changes: 9 additions & 9 deletions src/sage/modules/matrix_morphism.py
Original file line number Diff line number Diff line change
@@ -1068,7 +1068,7 @@ def nullity(self):
else:
return self._matrix.right_nullity()

def is_bijective(self):
def is_bijective(self) -> bool:
r"""
Tell whether ``self`` is bijective.

@@ -1112,9 +1112,9 @@ def is_bijective(self):
"""
return self.is_injective() and self.is_surjective()

def is_identity(self):
def is_identity(self) -> bool:
r"""
Determines if this morphism is an identity function or not.
Determine if this morphism is an identity function or not.

EXAMPLES:

@@ -1186,9 +1186,9 @@ def is_identity(self):
# so we test equality on a basis, which is sufficient
return all(self(u) == u for u in self.domain().basis())

def is_zero(self):
def is_zero(self) -> bool:
r"""
Determines if this morphism is a zero function or not.
Determine if this morphism is a zero function or not.

EXAMPLES:

@@ -1228,9 +1228,9 @@ def is_zero(self):
# disqualifies the morphism as having totally zero outputs
return self._matrix.is_zero()

def is_equal_function(self, other):
def is_equal_function(self, other) -> bool:
r"""
Determines if two morphisms are equal functions.
Determine if two morphisms are equal functions.

INPUT:

@@ -1646,7 +1646,7 @@ def matrix(self, side=None):
return self._matrix
return self._matrix.transpose()

def is_injective(self):
def is_injective(self) -> bool:
"""
Tell whether ``self`` is injective.

@@ -1671,7 +1671,7 @@ def is_injective(self):
ker = self._matrix.right_kernel()
return ker.dimension() == 0

def is_surjective(self):
def is_surjective(self) -> bool:
r"""
Tell whether ``self`` is surjective.

6 changes: 3 additions & 3 deletions src/sage/modules/multi_filtered_vector_space.py
Original file line number Diff line number Diff line change
@@ -209,7 +209,7 @@ def ambient_vector_space(self):
return VectorSpace(self.base_ring(), self.dimension())

@cached_method
def is_constant(self):
def is_constant(self) -> bool:
"""
Return whether the multi-filtration is constant.

@@ -229,7 +229,7 @@ def is_constant(self):
"""
return all(F.is_constant() for F in self._filt.values())

def is_exhaustive(self):
def is_exhaustive(self) -> bool:
r"""
Return whether the multi-filtration is exhaustive.

@@ -249,7 +249,7 @@ def is_exhaustive(self):
"""
return all(F.is_exhaustive() for F in self._filt.values())

def is_separating(self):
def is_separating(self) -> bool:
r"""
Return whether the multi-filtration is separating.

2 changes: 1 addition & 1 deletion src/sage/modules/ore_module.py
Original file line number Diff line number Diff line change
@@ -524,7 +524,7 @@ def _coerce_map_from_(self, S):
"""
pass

def is_zero(self):
def is_zero(self) -> bool:
r"""
Return ``True`` if this Ore module is reduced to zero.

2 changes: 1 addition & 1 deletion src/sage/modules/ore_module_element.py
Original file line number Diff line number Diff line change
@@ -72,7 +72,7 @@ def _latex_(self):
names = parent._latex_names
return repr_lincomb([(names[i], self[i]) for i in range(len(names))], is_latex=True)

def is_mutable(self):
def is_mutable(self) -> bool:
r"""
Always return ``False`` since elements in Ore modules
are all immutable.
Loading
Loading