Skip to content

Commit 087ee1f

Browse files
author
Release Manager
committed
sagemathgh-39685: handling a few unused variables in geometry,graphs,numerical,structure found using `cython-lint` ### 📝 Checklist - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. URL: sagemath#39685 Reported by: Frédéric Chapoton Reviewer(s): David Coudert
2 parents e09181b + eb840a4 commit 087ee1f

File tree

11 files changed

+13
-22
lines changed

11 files changed

+13
-22
lines changed

src/sage/geometry/palp_normal_form.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ def _palp_PM_max(Matrix_integer_dense PM, check=False):
195195
else:
196196
S[i] = i + 1
197197

198-
cdef int l, np, cf, ccf, n_s_bar, d1, v0, vc, vj
198+
cdef int l, cf, ccf, n_s_bar, d1, v0, vc, vj
199199
cdef list l_r
200200

201201
# We determine the other rows of PM_max in turn by use of perms and

src/sage/graphs/base/static_sparse_graph.pyx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,10 +280,9 @@ cdef int init_short_digraph(short_digraph g, G, edge_labelled=False,
280280
g.m = G.size()
281281

282282
cdef int isdigraph = G.is_directed()
283-
cdef uint32_t i, v_id, j
283+
cdef uint32_t i, j
284284
cdef list vertices = vertex_list if vertex_list is not None else list(G)
285285
cdef dict v_to_id = {v: i for i, v in enumerate(vertices)}
286-
cdef list neighbor_label
287286
cdef list edge_labels
288287
# Loops are not stored twice for undirected graphs
289288
cdef int n_edges = g.m if isdigraph else 2*g.m - G.number_of_loops()

src/sage/graphs/traversals.pyx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -471,8 +471,6 @@ def lex_BFS(G, reverse=False, tree=False, initial_vertex=None, algorithm="fast")
471471
if algorithm != "fast":
472472
raise ValueError(f"unknown algorithm '{algorithm}'")
473473

474-
cdef size_t n = G.order()
475-
476474
# For algorithm "fast" we need to convert G to an undirected graph
477475
if G.is_directed():
478476
G = G.to_undirected()
@@ -485,8 +483,6 @@ def lex_BFS(G, reverse=False, tree=False, initial_vertex=None, algorithm="fast")
485483
# Initialize variables needed by the fast algorithm
486484
cdef vector[int] sigma_int
487485
cdef vector[int] pred
488-
# Initialize variables needed by the slow algorithm
489-
cdef dict lexicographic_label
490486
# Temporary variables
491487
cdef int vi, i, initial_v_int
492488

@@ -497,8 +493,8 @@ def lex_BFS(G, reverse=False, tree=False, initial_vertex=None, algorithm="fast")
497493
else:
498494
initial_v_int = -1
499495
extended_lex_BFS(cg, sigma_int, NULL, initial_v_int, &pred, NULL, NULL)
500-
sigma = [ Gbackend.vertex_label(vi) for vi in sigma_int ]
501-
predecessor = { u: sigma[i] for u, i in zip(sigma, pred) if i != -1 }
496+
sigma = [Gbackend.vertex_label(vi) for vi in sigma_int]
497+
predecessor = {u: sigma[i] for u, i in zip(sigma, pred) if i != -1}
502498

503499
if reverse:
504500
sigma.reverse()

src/sage/numerical/backends/cvxopt_backend.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ cdef class CVXOPTBackend(GenericBackend):
300300
"""
301301
for i in range(len(coeff)):
302302
self.objective_function[i] = coeff[i]
303-
obj_constant_term = d
303+
self.obj_constant_term = d
304304

305305
cpdef set_verbosity(self, int level):
306306
"""

src/sage/numerical/backends/matrix_sdp_backend.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ cdef class MatrixSDPBackend(GenericSDPBackend):
242242
"""
243243
for i in range(len(coeff)):
244244
self.objective_function[i] = coeff[i]
245-
obj_constant_term = d
245+
self.obj_constant_term = d
246246

247247
cpdef add_linear_constraint(self, coefficients, name=None):
248248
"""

src/sage/numerical/mip.pyx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -990,7 +990,6 @@ cdef class MixedIntegerLinearProgram(SageObject):
990990
"""
991991
from sage.rings.integer import Integer as Integer
992992
cdef int i
993-
cdef str s
994993
cdef GenericBackend b = self._backend
995994

996995
result = []
@@ -1005,16 +1004,15 @@ cdef class MixedIntegerLinearProgram(SageObject):
10051004
return (lb, b.row(indices), ub)
10061005

10071006
# List of constraints
1008-
elif isinstance(indices, list):
1007+
if isinstance(indices, list):
10091008
for i in indices:
10101009
lb, ub = b.row_bounds(i)
10111010
result.append((lb, b.row(i), ub))
10121011

10131012
return result
10141013

10151014
# Weird Input
1016-
else:
1017-
raise ValueError("constraints() requires a list of integers, though it will accommodate None or an integer.")
1015+
raise ValueError("constraints() requires a list of integers, though it will accommodate None or an integer.")
10181016

10191017
def polyhedron(self, **kwds):
10201018
r"""

src/sage/numerical/sdp.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ cdef class SemidefiniteProgram(SageObject):
656656
657657
##### Constraints
658658
print("Constraints:")
659-
for 0<= i < b.nrows():
659+
for i in range(b.nrows()):
660660
indices, values = b.row(i)
661661
print(" ", end=" ")
662662
# Constraint's name
@@ -666,7 +666,7 @@ cdef class SemidefiniteProgram(SageObject):
666666
l = sorted(zip(indices,values))
667667
l.reverse()
668668
if l[-1][0] == -1:
669-
last_i,last_value = l.pop()
669+
_, last_value = l.pop()
670670
else:
671671
last_value = matrix.zero( l[0][1].dimensions()[0],l[0][1].dimensions()[1] )
672672
l.reverse()

src/sage/structure/coerce.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1600,7 +1600,7 @@ cdef class CoercionModel:
16001600
"""
16011601
if homs is None:
16021602
return None
1603-
cdef Map x_map, y_map
1603+
cdef Map R_map, S_map
16041604
R_map, S_map = homs
16051605
if isinstance(R, type):
16061606
R = Set_PythonType(R)

src/sage/structure/coerce_actions.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,7 @@ cdef class IntegerMulAction(IntegerAction):
759759
def __init__(self, Z, M, is_left=True, m=None):
760760
if m is None:
761761
m = M.an_element()
762-
test = m + (-m) # make sure addition and negation is allowed
762+
_ = m + (-m) # make sure addition and negation is allowed
763763
super().__init__(Z, M, is_left, operator.mul)
764764

765765
cpdef _act_(self, nn, a):

src/sage/structure/element.pyx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,6 @@ cdef class Element(SageObject):
712712
"""
713713
tester = self._tester(**options)
714714
SageObject._test_category(self, tester=tester)
715-
category = self.category()
716715
# Tests that self inherits methods from the categories
717716
if can_assign_class(self):
718717
# For usual Python classes, that should be done with

0 commit comments

Comments
 (0)