Skip to content

Commit 69d5801

Browse files
author
Release Manager
committed
gh-36856: various details in modules folder (ruff, cython-lint, roles) This is fixing various little details in the `modules` folders, including some suggestions from `ruff` and `cython-lint`. ### 📝 Checklist - [x] The title is concise, informative, and self-explanatory. - [x] The description explains in detail what this PR is about. URL: #36856 Reported by: Frédéric Chapoton Reviewer(s): Matthias Köppe
2 parents 3d9dc8d + ccfbd09 commit 69d5801

17 files changed

+41
-51
lines changed

src/sage/modules/fg_pid/fgp_module.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1806,7 +1806,7 @@ def list(self):
18061806
sage: list(V/W)
18071807
[(0), (1)]
18081808
"""
1809-
return [e for e in self]
1809+
return list(self)
18101810

18111811
def __iter__(self):
18121812
"""

src/sage/modules/filtered_vector_space.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ def make_subspace(indices):
465465
indices = set(filtration.pop(infinity, []))
466466
V = make_subspace(indices)
467467
filtered_subspaces = [(infinity, V)]
468-
for deg in reversed(sorted(filtration.keys())):
468+
for deg in sorted(filtration.keys(), reverse=True):
469469
next_V = V
470470
indices.update(filtration[deg])
471471
V = make_subspace(indices)
@@ -775,13 +775,13 @@ def presentation(self):
775775

776776
def _repr_field_name(self):
777777
"""
778-
Return an abbreviated field name as string
778+
Return an abbreviated field name as string.
779779
780780
.. NOTE: This should rather be a method of fields and rings.
781781
782782
RAISES:
783783
784-
``NotImplementedError``: The field does not have an
784+
:class:`NotImplementedError`: The field does not have an
785785
abbreviated name defined.
786786
787787
EXAMPLES::

src/sage/modules/finite_submodule_iter.pyx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ cdef class FiniteFieldsubspace_iterator(FiniteZZsubmodule_iterator):
283283
sage: all(Y[i]-X[i] == v for i in range(len(X)))
284284
True
285285
"""
286-
cdef Py_ssize_t d, i, p
286+
cdef Py_ssize_t i, p
287287
cdef list pows, order
288288

289289
F = basis[0].base_ring()
@@ -366,7 +366,6 @@ cdef class FiniteFieldsubspace_projPoint_iterator:
366366
85
367367
"""
368368
from sage.matrix.constructor import matrix
369-
cdef i
370369
self._basis = list(basis)
371370
self._basis_length = len(self._basis)
372371
self._immutable = immutable

src/sage/modules/free_module.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ def VectorSpace(K, dimension_or_basis_keys=None, sparse=False, inner_product_mat
563563
(0, 0, 1)
564564
]
565565
566-
The base must be a field or a ``TypeError`` is raised.
566+
The base must be a field or a :class:`TypeError` is raised.
567567
568568
::
569569
@@ -1720,8 +1720,8 @@ def submodule(self, gens, check=True, already_echelonized=False):
17201720
Echelon basis matrix:
17211721
[3 3 0]
17221722
1723-
We try to create a submodule that isn't really a submodule,
1724-
which results in an ``ArithmeticError`` exception::
1723+
We try to create a submodule that is not really a submodule,
1724+
which results in an :class:`ArithmeticError` exception::
17251725
17261726
sage: W.submodule([B[0] - B[1]])
17271727
Traceback (most recent call last):
@@ -2722,7 +2722,7 @@ def coordinates(self, v, check=True):
27222722
27232723
\\sum c_i B_i = v.
27242724
2725-
If `v` is not in self, raise an ``ArithmeticError`` exception.
2725+
If `v` is not in self, raise an :class:`ArithmeticError` exception.
27262726
27272727
EXAMPLES::
27282728
@@ -4637,7 +4637,7 @@ def span_of_basis(self, basis, base_ring=None, check=True, already_echelonized=F
46374637
[3 3 0]
46384638
46394639
The basis vectors must be linearly independent or a
4640-
``ValueError`` exception is raised::
4640+
:class:`ValueError` exception is raised::
46414641
46424642
sage: W.span_of_basis([[2,2,2], [3,3,3]])
46434643
Traceback (most recent call last):
@@ -4696,7 +4696,7 @@ def subspace(self, gens, check=True, already_echelonized=False):
46964696
[1 1 0]
46974697
46984698
With ``check=True`` (the default) the mistake is correctly
4699-
detected and reported with an ``ArithmeticError`` exception::
4699+
detected and reported with an :class:`ArithmeticError` exception::
47004700
47014701
sage: W.subspace([[1,1,0]], check=True)
47024702
Traceback (most recent call last):
@@ -5799,7 +5799,7 @@ def coordinate_vector(self, v, check=True):
57995799
58005800
\\sum c_i B_i = v.
58015801
5802-
If `v` is not in self, raise an ``ArithmeticError`` exception.
5802+
If `v` is not in self, raise an :class:`ArithmeticError` exception.
58035803
58045804
EXAMPLES::
58055805
@@ -6150,7 +6150,7 @@ def coordinate_vector(self, v, check=True):
61506150
61516151
\\sum c_i B_i = v.
61526152
6153-
If `v` is not in self, raise an ``ArithmeticError`` exception.
6153+
If `v` is not in self, raise an :class:`ArithmeticError` exception.
61546154
61556155
EXAMPLES::
61566156
@@ -7001,7 +7001,7 @@ def echelon_coordinates(self, v, check=True):
70017001
70027002
\sum c_i B_i = v.
70037003
7004-
If `v` is not in self, raise an ``ArithmeticError`` exception.
7004+
If `v` is not in self, raise an :class:`ArithmeticError` exception.
70057005
70067006
EXAMPLES::
70077007
@@ -7441,7 +7441,7 @@ def coordinate_vector(self, v, check=True):
74417441
74427442
\\sum c_i B_i = v.
74437443
7444-
If `v` is not in self, raise an ``ArithmeticError`` exception.
7444+
If `v` is not in self, raise an :class:`ArithmeticError` exception.
74457445
74467446
EXAMPLES::
74477447
@@ -7498,7 +7498,7 @@ def echelon_coordinate_vector(self, v, check=True):
74987498
74997499
\\sum c_i B_i = v.
75007500
7501-
If `v` is not in self, raise an ``ArithmeticError`` exception.
7501+
If `v` is not in self, raise an :class:`ArithmeticError` exception.
75027502
75037503
EXAMPLES::
75047504
@@ -7652,7 +7652,7 @@ def coordinate_vector(self, v, check=True):
76527652
76537653
\\sum c_i B_i = v.
76547654
7655-
If `v` is not in self, raise an ``ArithmeticError`` exception.
7655+
If `v` is not in self, raise an :class:`ArithmeticError` exception.
76567656
76577657
EXAMPLES::
76587658
@@ -8054,7 +8054,7 @@ def echelon_coordinates(self, v, check=True):
80548054
80558055
\\sum c_i B_i = v.
80568056
8057-
If `v` is not in ``self``, raise an ``ArithmeticError`` exception.
8057+
If `v` is not in ``self``, raise an :class:`ArithmeticError` exception.
80588058
80598059
EXAMPLES::
80608060
@@ -8117,7 +8117,7 @@ def coordinate_vector(self, v, check=True):
81178117
81188118
\\sum c_i B_i = v.
81198119
8120-
If `v` is not in ``self``, raise an ``ArithmeticError`` exception.
8120+
If `v` is not in ``self``, raise an :class:`ArithmeticError` exception.
81218121
81228122
EXAMPLES::
81238123

src/sage/modules/free_module_element.pyx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4788,11 +4788,10 @@ cdef class FreeModuleElement_generic_sparse(FreeModuleElement):
47884788
sage: v.nonzero_positions()
47894789
[0, 1, 3, 4]
47904790
"""
4791-
#WARNING: In creation, we do not check that the indices i satisfy
4791+
# WARNING: In creation, we do not check that the indices i satisfy
47924792
# 0 <= i < degree
47934793
# or even that the indices are integers.
47944794
FreeModuleElement.__init__(self, parent)
4795-
R = self.base_ring()
47964795
cdef Py_ssize_t i
47974796
cdef dict entries_dict, e
47984797
if not entries:

src/sage/modules/free_module_integer.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
"""
32
Discrete subgroups of `\\ZZ^n`
43

src/sage/modules/free_quadratic_module.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ def QuadraticSpace(K, dimension, inner_product_matrix, sparse=False):
207207
(0, 0, 1)
208208
]
209209
210-
The base must be a field or a ``TypeError`` is raised::
210+
The base must be a field or a :class:`TypeError` is raised::
211211
212212
sage: QuadraticSpace(ZZ,5,identity_matrix(ZZ,2))
213213
Traceback (most recent call last):
@@ -791,7 +791,7 @@ def span_of_basis(self, basis, check=True, already_echelonized=False):
791791
[3 3 0]
792792
793793
The basis vectors must be linearly independent or a
794-
``ValueError`` exception is raised::
794+
:class:`ValueError` exception is raised::
795795
796796
sage: W.span_of_basis([[2,2,2], [3,3,3]])
797797
Traceback (most recent call last):
@@ -1341,7 +1341,7 @@ def change_ring(self, R):
13411341
element of ``self`` into a vector over the fraction field of `R`,
13421342
then taking the resulting `R`-module.
13431343
1344-
This raises a ``TypeError`` if coercion is not possible.
1344+
This raises a :class:`TypeError` if coercion is not possible.
13451345
13461346
INPUT:
13471347

src/sage/modules/matrix_morphism.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ def inverse(self):
321321
r"""
322322
Return the inverse of this matrix morphism, if the inverse exists.
323323
324-
Raises a ``ZeroDivisionError`` if the inverse does not exist.
324+
This raises a :class:`ZeroDivisionError` if the inverse does not exist.
325325
326326
EXAMPLES:
327327

src/sage/modules/module.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ cdef class Module(Parent):
205205
Return the base extension of ``self`` to `R`.
206206
207207
This is the same as ``self.change_ring(R)`` except that a
208-
``TypeError`` is raised if there is no canonical coerce map
208+
:class:`TypeError` is raised if there is no canonical coerce map
209209
from the base ring of ``self`` to `R`.
210210
211211
INPUT:

src/sage/modules/tensor_operations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ def __init__(self, vector_collections, operation='product'):
282282
assert all(V.base_ring() is base_ring for V in vector_collections)
283283
self._V = tuple(vector_collections)
284284
self._vectors = []
285-
self._index_map = dict()
285+
self._index_map = {}
286286
if operation == 'product':
287287
self._init_product()
288288
elif operation == 'symmetric':

0 commit comments

Comments
 (0)