Skip to content

Commit

Permalink
gh-38309: fixin' the ruff linter
Browse files Browse the repository at this point in the history
as this is currently badly broken

not sure the changes are all innocuous

### 📝 Checklist

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.

URL: #38309
Reported by: Frédéric Chapoton
Reviewer(s): Matthias Köppe
  • Loading branch information
Release Manager committed Jul 4, 2024
2 parents 389c7ab + 08f0c91 commit 812a116
Show file tree
Hide file tree
Showing 23 changed files with 57 additions and 58 deletions.
4 changes: 2 additions & 2 deletions build/pkgs/configure/checksums.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
tarball=configure-VERSION.tar.gz
sha1=7e1e01d82e171303935202d5876e0c109d431f8b
sha256=eec0d494a20c6eff61a1ccc679cca149efd78cb191f88ade0446468b45abee00
sha1=246264ebcb0a28d278f7bb85ffca3c7e916c0cb2
sha256=4a7cc9cfaa8a174a5ad17da30747bc76d245d980f86b4b0eda1f75b5fb1cfd51
2 changes: 1 addition & 1 deletion build/pkgs/configure/package-version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
19bd20218effcdb6b242bfb18b113ff85c6d8497
ca2d413dcd311b14304c7adb9a270a8dfa4d6081
2 changes: 1 addition & 1 deletion src/sage/categories/pushout.py
Original file line number Diff line number Diff line change
Expand Up @@ -1409,7 +1409,7 @@ def __mul__(self, other):
"""
if isinstance(other, IdentityConstructionFunctor):
return self
if isinstance(other, self.__class__): #
if isinstance(other, self.__class__):
INT = set(self._gens).intersection(other._gens)
if INT:
# if there is overlap of generators, it must only be at the ends, so that
Expand Down
6 changes: 3 additions & 3 deletions src/sage/combinat/integer_vector_weighted.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,10 @@ def __contains__(self, x):
if len(self._weights) != len(x):
return False
s = 0
for i, val in enumerate(x):
if (not isinstance(val, (int, Integer))) and (val not in ZZ):
for i, xi in enumerate(x):
if not isinstance(xi, (int, Integer)) and xi not in ZZ:
return False
s += x[i] * self._weights[i]
s += xi * self._weights[i]
return s == self._n

def _recfun(self, n, l):
Expand Down
4 changes: 2 additions & 2 deletions src/sage/geometry/pseudolines.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ def __init__(self, seq, encoding="auto"):

i = 0
while crossings > 0:
if (seq[i] != [] and
if (seq[i] and
(seq[i][0] == 0 and
seq[i+1][0] == 1)):

Expand All @@ -290,7 +290,7 @@ def __init__(self, seq, encoding="auto"):
seq[i].pop(0)
seq[i+1].pop(0)

if i > 0 and seq[i-1] is not []:
if i > 0 and seq[i - 1]:
i -= 1
else:
i += 1
Expand Down
12 changes: 6 additions & 6 deletions src/sage/graphs/generators/random.py
Original file line number Diff line number Diff line change
Expand Up @@ -2355,17 +2355,17 @@ def RandomBicubicPlanar(n, seed=None):
Z3 = Zmod(3)
colour = Z3.zero()
not_touched = [i for i, v in enumerate(w) if v[0] in ['x', 'xb']]
for i, v in enumerate(w):
for i, wi in enumerate(w):
# internal edges
if v[0] == 'i':
if wi[0] == 'i':
colour += 1
if w[i + 1][0] == 'n':
G.add_edge((w[i], w[i + 1], colour))
elif v[0] == 'n':
G.add_edge((wi, w[i + 1], colour))
elif wi[0] == 'n':
colour += 2
elif v[0] == 'x':
elif wi[0] == 'x':
pile.append(i)
elif v[0] == 'xb' and i in not_touched:
elif wi[0] == 'xb' and i in not_touched:
if pile:
j = pile.pop()
G.add_edge((w[i + 1], w[j - 1], colour))
Expand Down
34 changes: 17 additions & 17 deletions src/sage/graphs/graph_latex.py
Original file line number Diff line number Diff line change
Expand Up @@ -1714,34 +1714,34 @@ def translate(p):
vl_color = {}
vl_placement = {}
for u in vertex_list:
#

c = dvc
if u in vertex_colors:
c = cc.to_rgb(vertex_colors[u])
v_color[u] = c
#

c = dvfc
if u in vertex_fill_colors:
c = cc.to_rgb(vertex_fill_colors[u])
vf_color[u] = c
#

sh = dsh
if u in vertex_shapes:
sh = vertex_shapes[u]
v_shape[u] = sh
#

vs = dvs
if u in vertex_sizes:
vs = vertex_sizes[u]
v_size[u] = vs
#

if vertex_labels:
#

c = dvlc
if u in vertex_label_colors:
c = cc.to_rgb(vertex_label_colors[u])
vl_color[u] = c
#

vlp = dvlp
if u in vertex_label_placements:
vlp = vertex_label_placements[u]
Expand All @@ -1766,14 +1766,14 @@ def translate(p):
# We collect options for edges, default values and for-some-edges
# information. These are combined into dictionaries on a per-edge
# basis, for all edges
#

# Defaults
#

dec = cc.to_rgb(self.get_option('edge_color'))
if edge_fills:
defc = cc.to_rgb(self.get_option('edge_fill_color'))
det = self.get_option('edge_thickness')
#

if edge_labels:
edge_labels_math = self.get_option('edge_labels_math')
delc = cc.to_rgb(self.get_option('edge_label_color'))
Expand All @@ -1796,7 +1796,7 @@ def translate(p):
# an undirected graph in the "wrong" order, so we use a "reverse" to
# test for this case. Everything formed here conforms to the order
# used in the graph.
#

e_color = {}
if edge_fills:
ef_color = {}
Expand All @@ -1809,15 +1809,15 @@ def translate(p):
for e in self._graph.edges(sort=False):
edge = (e[0], e[1])
reverse = (e[1], e[0])
#

c = dec
if edge in edge_colors or (not is_directed and reverse in edge_colors):
if edge in edge_colors:
c = cc.to_rgb(edge_colors[edge])
else:
c = cc.to_rgb(edge_colors[reverse])
e_color[edge] = c
#

if edge_fills:
c = defc
if edge in edge_fill_colors or (not is_directed and reverse in edge_fill_colors):
Expand All @@ -1826,15 +1826,15 @@ def translate(p):
else:
c = cc.to_rgb(edge_fill_colors[reverse])
ef_color[edge] = c
#

et = det
if edge in edge_thicknesses or (not is_directed and reverse in edge_thicknesses):
if edge in edge_thicknesses:
et = edge_thicknesses[edge]
else:
et = edge_thicknesses[reverse]
e_thick[edge] = et
#

if edge_labels:
c = delc
if edge in edge_label_colors or (not is_directed and reverse in edge_label_colors):
Expand All @@ -1843,15 +1843,15 @@ def translate(p):
else:
c = cc.to_rgb(edge_label_colors[reverse])
el_color[edge] = c
#

els = dels
if edge in edge_label_slopes or (not is_directed and reverse in edge_label_slopes):
if edge in edge_label_slopes:
els = edge_label_slopes[edge]
else:
els = edge_label_slopes[reverse]
el_slope[edge] = els
#

elp = delp
if edge in edge_label_placements or (not is_directed and reverse in edge_label_placements):
if edge in edge_label_placements:
Expand Down
4 changes: 2 additions & 2 deletions src/sage/groups/cubic_braid.py
Original file line number Diff line number Diff line change
Expand Up @@ -1557,7 +1557,7 @@ def as_matrix_group(self, root_bur=None, domain=None, characteristic=None, var='
if unitary:
from sage.rings.finite_rings.finite_field_base import FiniteField
from sage.groups.matrix_gps.unitary import GU
d, d = herm_form.dimensions()
_, d = herm_form.dimensions()
if isinstance(domain, FiniteField):
base_group = GU(d, domain, var=domain.gen(), invariant_form=herm_form)
else:
Expand All @@ -1568,7 +1568,7 @@ def as_matrix_group(self, root_bur=None, domain=None, characteristic=None, var='
from sage.groups.matrix_gps.finitely_generated import MatrixGroup
matrix_group = MatrixGroup(gen_list, category=self.category())

# -------------------------------------------------------------------------------
# --------------------------------------------------------------------
# check if there is a well defined group homomorphism to matrix_group
# Register map from ``self`` to matrix_group.
# Since GAP' check is very expansive (on time and memory), the check is performed
Expand Down
2 changes: 1 addition & 1 deletion src/sage/knots/link.py
Original file line number Diff line number Diff line change
Expand Up @@ -1833,7 +1833,7 @@ def genus(self):
t = [Link(B(si)).number_of_components() for si in s]
for i, j in enumerate(s):
if not j:
s[i].append(-2)
j.append(-2)
for i in s:
q2 = max(abs(k) + 1 for k in i)
q.append(q2)
Expand Down
2 changes: 1 addition & 1 deletion src/sage/manifolds/chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ def __init__(self, domain, coordinates, calc_method=None, periods=None,
# Initialization of the set of charts which the current chart is a
# restriction of:
self._supercharts = set([self])
#

self._dom_restrict = {} # dict. of the restrictions of self to
# subsets of self._domain, with the
# subsets as keys
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -905,7 +905,7 @@ def _build_element(self, *args, **kwargs):
name = 'c'
class_type = 'multiplicative'
val = 1 + x
if val == 'Pontryagin':
elif val == 'Pontryagin':
if vbundle._field_type != 'real':
raise ValueError(f'total Pontryagin class not defined on {vbundle}')
if name is None:
Expand Down Expand Up @@ -966,7 +966,7 @@ def _build_element(self, *args, **kwargs):
class_type = 'Pfaffian'
val = x
else:
ValueError(f'predefined class "{val}" unknown')
raise ValueError(f'predefined class "{val}" unknown')

# turn symbolic expression into a polynomial via Taylor expansion
if isinstance(val, Expression):
Expand All @@ -978,7 +978,7 @@ def _build_element(self, *args, **kwargs):
elif vbundle._field_type == 'complex':
pow_range = dim // 2
else:
ValueError(f'field type of {vbundle} must be real or complex')
raise ValueError(f'field type of {vbundle} must be real or complex')

val = P(val.taylor(x, 0, pow_range))

Expand All @@ -1004,7 +1004,7 @@ def _build_element(self, *args, **kwargs):
val = P([(-1) ** k * val[2 * k + 1] for k in range(n + 1)])
sym = multiplicative_sequence(val, n)
else:
AttributeError('unkown class type')
raise AttributeError('unkown class type')

d = {}
w_vec = self._weighted_vectors
Expand Down
2 changes: 1 addition & 1 deletion src/sage/manifolds/differentiable/diff_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -1281,7 +1281,7 @@ def pushforward(self, tensor):
"the {} by the {}".format(tensor, self))
# Vector field module for the result:
fmodule2 = dom1.vector_field_module(dest_map=self)
#

frame2 = fmodule2.basis(from_frame=chart2.frame())
si1 = dom1.start_index()
si2 = fmodule2._sindex
Expand Down
2 changes: 1 addition & 1 deletion src/sage/manifolds/differentiable/examples/euclidean.py
Original file line number Diff line number Diff line change
Expand Up @@ -1728,7 +1728,7 @@ def __init__(self, name=None, latex_name=None, coordinates='Cartesian',
symbols = 'r ph:\\phi z'
self._spherical_chart = None # to be constructed later if necessary
self._spherical_frame = None # orthonormal frame
self._cylindrical_chart = None #
self._cylindrical_chart = None
self._cylindrical_frame = None # orthonormal frame
init_coord_methods = {'Cartesian': self._init_cartesian,
'spherical': self._init_spherical,
Expand Down
2 changes: 1 addition & 1 deletion src/sage/manifolds/differentiable/manifold.py
Original file line number Diff line number Diff line change
Expand Up @@ -3193,7 +3193,7 @@ def vector_frame(self, *args, **kwargs) -> VectorFrame:
latex_indices = kwargs.pop('latex_indices', None)
symbol_dual = kwargs.pop('symbol_dual', None)
latex_symbol_dual = kwargs.pop('latex_symbol_dual', None)
#

if vector_fields:
dest_map0 = vector_fields[0].parent().destination_map()
if dest_map and dest_map is not dest_map0:
Expand Down
4 changes: 2 additions & 2 deletions src/sage/manifolds/differentiable/vectorfield_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -2300,10 +2300,10 @@ def tensor_from_comp(self, tensor_type, comp, name=None,
if isinstance(comp, CompWithSym):
resu._sym = comp._sym
resu._antisym = comp._antisym
#

# 2/ Tensor components set to comp:
resu._components[comp._frame] = comp
#

return resu

def sym_bilinear_form(self, name=None, latex_name=None):
Expand Down
6 changes: 3 additions & 3 deletions src/sage/manifolds/differentiable/vectorframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -744,19 +744,19 @@ def __init__(self, vector_field_module, symbol, latex_symbol=None,
if dest_map is self._domain.identity_map():
# The frame is added to the list of the domain's covering frames:
self._domain._set_covering_frame(self)
#

# Dual coframe
self._coframe = self.dual_basis() # self._coframe = a shortcut for
# self._dual_basis
#

# Derived quantities:
# Initialization of the set of frames that are restrictions of the
# current frame to subdomains of the frame domain:
self._subframes = set([self])
# Initialization of the set of frames which the current frame is a
# restriction of:
self._superframes = set([self])
#

self._restrictions = {} # dict. of the restrictions of self to
# subdomains of self._domain, with the
# subdomains as keys
Expand Down
4 changes: 2 additions & 2 deletions src/sage/manifolds/manifold.py
Original file line number Diff line number Diff line change
Expand Up @@ -582,11 +582,11 @@ def __init__(self, n, name, field, structure, base_manifold=None,
category=category)
self._is_open = True
self._open_covers.append([self]) # list of open covers of self
#

if not isinstance(start_index, (int, Integer)):
raise TypeError("the starting index must be an integer")
self._sindex = start_index
#

self._atlas = [] # list of charts defined on subsets of self
self._top_charts = [] # list of charts defined on subsets of self
# that are not subcharts of charts on larger subsets
Expand Down
2 changes: 1 addition & 1 deletion src/sage/manifolds/scalarfield.py
Original file line number Diff line number Diff line change
Expand Up @@ -2200,7 +2200,7 @@ def _display_expression(self, chart, result):
else:
field_name = str(field)
field_latex_name = latex(field)
#

result = FormattedExpansion()
if self._name is None:
symbol = ""
Expand Down
2 changes: 1 addition & 1 deletion src/sage/manifolds/vector_bundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,7 @@ def local_frame(self, *args, **kwargs):
symbol_dual = kwargs.pop('symbol_dual', None)
latex_symbol_dual = kwargs.pop('latex_symbol_dual', None)
domain = kwargs.pop('domain', None)
#

sec_module = self.section_module(domain=domain, force_free=True)
resu = LocalFrame(sec_module, symbol=symbol, latex_symbol=latex_symbol,
indices=indices, latex_indices=latex_indices,
Expand Down
3 changes: 1 addition & 2 deletions src/sage/plot/multigraphics.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,10 @@ def __init__(self, graphics_list):
sage: G = MultiGraphics([c, (c, (0.7, 0.6, 0.2, 0.2))])
sage: print(G)
Multigraphics with 2 elements
"""
self._glist = []
self._positions = []
#

for ins in graphics_list:
if isinstance(ins, Graphics):
self.append(ins) # default position
Expand Down
4 changes: 2 additions & 2 deletions src/sage/tensor/modules/finite_rank_free_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -2324,10 +2324,10 @@ def tensor_from_comp(self, tensor_type, comp, name=None, latex_name=None):
if isinstance(comp, CompWithSym):
resu._sym = comp._sym
resu._antisym = comp._antisym
#

# 2/ Tensor components set to comp:
resu._components[comp._frame] = comp
#

return resu

def alternating_contravariant_tensor(self, degree, name=None,
Expand Down
2 changes: 1 addition & 1 deletion src/sage/tensor/modules/free_module_basis.py
Original file line number Diff line number Diff line change
Expand Up @@ -1083,5 +1083,5 @@ def new_basis(self, change_of_basis, symbol, latex_symbol=None,
# of changes of bases:
fmodule._basis_changes[(self, the_new_basis)] = transf
fmodule._basis_changes[(the_new_basis, self)] = inv_transf
#

return the_new_basis
Loading

0 comments on commit 812a116

Please sign in to comment.