Skip to content

handling a few unused variables in geometry,graphs,numerical,structure #39685

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 2 commits into from
Mar 22, 2025
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/sage/geometry/palp_normal_form.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def _palp_PM_max(Matrix_integer_dense PM, check=False):
else:
S[i] = i + 1

cdef int l, np, cf, ccf, n_s_bar, d1, v0, vc, vj
cdef int l, cf, ccf, n_s_bar, d1, v0, vc, vj
cdef list l_r

# We determine the other rows of PM_max in turn by use of perms and
Expand Down
3 changes: 1 addition & 2 deletions src/sage/graphs/base/static_sparse_graph.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -280,10 +280,9 @@
g.m = G.size()

cdef int isdigraph = G.is_directed()
cdef uint32_t i, v_id, j
cdef uint32_t i, j
cdef list vertices = vertex_list if vertex_list is not None else list(G)
cdef dict v_to_id = {v: i for i, v in enumerate(vertices)}
cdef list neighbor_label
cdef list edge_labels
# Loops are not stored twice for undirected graphs
cdef int n_edges = g.m if isdigraph else 2*g.m - G.number_of_loops()
Expand Down Expand Up @@ -1183,7 +1182,7 @@
sage: while not G.is_strongly_connected():
....: shuffle(r)
....: G.add_edges(enumerate(r), loops=False)
sage: spectral_radius(G, 1e-10) # random # long time

Check warning on line 1185 in src/sage/graphs/base/static_sparse_graph.pyx

View workflow job for this annotation

GitHub Actions / test-long (src/sage/[g-o]*)

Warning: slow doctest:

slow doctest:
(1.9997956006500042, 1.9998043797692782)

The algorithm takes care of multiple edges::
Expand Down
8 changes: 2 additions & 6 deletions src/sage/graphs/traversals.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -471,8 +471,6 @@ def lex_BFS(G, reverse=False, tree=False, initial_vertex=None, algorithm="fast")
if algorithm != "fast":
raise ValueError(f"unknown algorithm '{algorithm}'")

cdef size_t n = G.order()

# For algorithm "fast" we need to convert G to an undirected graph
if G.is_directed():
G = G.to_undirected()
Expand All @@ -485,8 +483,6 @@ def lex_BFS(G, reverse=False, tree=False, initial_vertex=None, algorithm="fast")
# Initialize variables needed by the fast algorithm
cdef vector[int] sigma_int
cdef vector[int] pred
# Initialize variables needed by the slow algorithm
cdef dict lexicographic_label
# Temporary variables
cdef int vi, i, initial_v_int

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

if reverse:
sigma.reverse()
Expand Down
2 changes: 1 addition & 1 deletion src/sage/numerical/backends/cvxopt_backend.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ cdef class CVXOPTBackend(GenericBackend):
"""
for i in range(len(coeff)):
self.objective_function[i] = coeff[i]
obj_constant_term = d
self.obj_constant_term = d

cpdef set_verbosity(self, int level):
"""
Expand Down
2 changes: 1 addition & 1 deletion src/sage/numerical/backends/matrix_sdp_backend.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ cdef class MatrixSDPBackend(GenericSDPBackend):
"""
for i in range(len(coeff)):
self.objective_function[i] = coeff[i]
obj_constant_term = d
self.obj_constant_term = d

cpdef add_linear_constraint(self, coefficients, name=None):
"""
Expand Down
6 changes: 2 additions & 4 deletions src/sage/numerical/mip.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -990,7 +990,6 @@ cdef class MixedIntegerLinearProgram(SageObject):
"""
from sage.rings.integer import Integer as Integer
cdef int i
cdef str s
cdef GenericBackend b = self._backend

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

# List of constraints
elif isinstance(indices, list):
if isinstance(indices, list):
for i in indices:
lb, ub = b.row_bounds(i)
result.append((lb, b.row(i), ub))

return result

# Weird Input
else:
raise ValueError("constraints() requires a list of integers, though it will accommodate None or an integer.")
raise ValueError("constraints() requires a list of integers, though it will accommodate None or an integer.")

def polyhedron(self, **kwds):
r"""
Expand Down
4 changes: 2 additions & 2 deletions src/sage/numerical/sdp.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ cdef class SemidefiniteProgram(SageObject):

##### Constraints
print("Constraints:")
for 0<= i < b.nrows():
for i in range(b.nrows()):
indices, values = b.row(i)
print(" ", end=" ")
# Constraint's name
Expand All @@ -666,7 +666,7 @@ cdef class SemidefiniteProgram(SageObject):
l = sorted(zip(indices,values))
l.reverse()
if l[-1][0] == -1:
last_i,last_value = l.pop()
_, last_value = l.pop()
else:
last_value = matrix.zero( l[0][1].dimensions()[0],l[0][1].dimensions()[1] )
l.reverse()
Expand Down
2 changes: 1 addition & 1 deletion src/sage/structure/coerce.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1600,7 +1600,7 @@ cdef class CoercionModel:
"""
if homs is None:
return None
cdef Map x_map, y_map
cdef Map R_map, S_map
R_map, S_map = homs
if isinstance(R, type):
R = Set_PythonType(R)
Expand Down
2 changes: 1 addition & 1 deletion src/sage/structure/coerce_actions.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ cdef class IntegerMulAction(IntegerAction):
def __init__(self, Z, M, is_left=True, m=None):
if m is None:
m = M.an_element()
test = m + (-m) # make sure addition and negation is allowed
_ = m + (-m) # make sure addition and negation is allowed
super().__init__(Z, M, is_left, operator.mul)

cpdef _act_(self, nn, a):
Expand Down
1 change: 0 additions & 1 deletion src/sage/structure/element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,6 @@ cdef class Element(SageObject):
"""
tester = self._tester(**options)
SageObject._test_category(self, tester=tester)
category = self.category()
# Tests that self inherits methods from the categories
if can_assign_class(self):
# For usual Python classes, that should be done with
Expand Down
3 changes: 1 addition & 2 deletions src/sage/structure/parent.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,6 @@ cdef class Parent(sage.structure.category_object.CategoryObject):
"""
if self._element_constructor is None:
raise NotImplementedError(f"cannot construct elements of {self}")
cdef Py_ssize_t i
cdef R = parent(x)
cdef bint no_extra_args = (not args and not kwds)
if R is self and no_extra_args:
Expand Down Expand Up @@ -2409,7 +2408,7 @@ cdef class Parent(sage.structure.category_object.CategoryObject):
# setting this to 1 will make it return the first path found.

cdef int mor_found = 0
cdef Parent R, D
cdef Parent D
# Recurse. Note that if S is the domain of one of the maps in self._coerce_from_list,
# we will have stuck the map into _coerce_map_hash and thus returned it already.
for mor in self._coerce_from_list:
Expand Down
Loading