Skip to content

Commit e0074e6

Browse files
committed
various small fixes, some after ruff
1 parent 7888c42 commit e0074e6

File tree

20 files changed

+70
-72
lines changed

20 files changed

+70
-72
lines changed

src/sage/algebras/fusion_rings/fusion_double.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,8 @@ def s_ij(self, i, j, unitary=False, base_coercion=True):
257257
"""
258258
sum_val = ZZ.zero()
259259
G = self._G
260-
[i] = list(i._monomial_coefficients)
261-
[j] = list(j._monomial_coefficients)
260+
i, = list(i._monomial_coefficients)
261+
j, = list(j._monomial_coefficients)
262262
a = self._elt[i]
263263
b = self._elt[j]
264264
for g in G:

src/sage/combinat/crystals/fast_crystals.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,9 +220,9 @@ def _type_bc_init(self, l1, l2):
220220
4
221221
"""
222222
if self._cartan_type[0] == 'B':
223-
[m1, m2] = [l1+l2, l1-l2]
223+
m1, m2 = [l1+l2, l1-l2]
224224
else:
225-
[m1, m2] = [l1, l2]
225+
m1, m2 = [l1, l2]
226226
for b in range(m2,-1,-1):
227227
for a in range(m1,m2-1,-1):
228228
for c in range(b,a+1):
@@ -336,11 +336,11 @@ def weight(self):
336336
delpat = self.parent().delpat[self.value]
337337
if self.parent()._cartan_type[0] == 'A':
338338
delpat = delpat + [0,]
339-
[alpha1, alpha2] = self.parent().weight_lattice_realization().simple_roots()
339+
alpha1, alpha2 = self.parent().weight_lattice_realization().simple_roots()
340340
hwv = sum(self.parent().shape[i]*self.parent().weight_lattice_realization().monomial(i) for i in range(2))
341341
return hwv - (delpat[0]+delpat[2])*alpha1 - (delpat[1]+delpat[3])*alpha2
342342

343-
def _repr_(self):
343+
def _repr_(self) -> str:
344344
"""
345345
EXAMPLES::
346346

src/sage/combinat/parallelogram_polyomino.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,7 @@ def rotate(pos, angle):
695695
696696
The rotated position.
697697
"""
698-
[x, y] = pos
698+
x, y = pos
699699
return [x*cos(angle) - y*sin(angle), x*sin(angle) + y*cos(angle)]
700700

701701
def mirror(pos, axe):
@@ -770,8 +770,8 @@ def draw_line(self, v1, v2, color=None, size=None):
770770
color = self._color_line
771771
if size is None:
772772
size = self._line_size
773-
[x1, y1] = self.XY(v1)
774-
[x2, y2] = self.XY(v2)
773+
x1, y1 = self.XY(v1)
774+
x2, y2 = self.XY(v2)
775775
return "\n \\draw[color=%s, line width=%s] (%f, %f) -- (%f, %f);" % (
776776
color, size, float(x1), float(y1), float(x2), float(y2)
777777
)
@@ -844,14 +844,14 @@ def draw_point(self, p1, color=None, size=None):
844844
color = self._color_point
845845
if size is None:
846846
size = self._point_size
847-
[x1, y1] = self.XY(p1)
847+
x1, y1 = self.XY(p1)
848848
return "\n \\filldraw[color=%s] (%f, %f) circle (%spt);" % (
849849
color, float(x1), float(y1), size
850850
)
851851

852852

853853
class ParallelogramPolyomino(ClonableList,
854-
metaclass=InheritComparisonClasscallMetaclass):
854+
metaclass=InheritComparisonClasscallMetaclass):
855855
r"""
856856
Parallelogram Polyominoes.
857857

src/sage/combinat/words/finite_word.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1684,8 +1684,8 @@ def reduced_rauzy_graph(self, n):
16841684
g.allow_loops(True)
16851685
g.allow_multiple_edges(True)
16861686
for v in l:
1687-
[i] = g.neighbors_in(v)
1688-
[o] = g.neighbors_out(v)
1687+
i, = g.neighbors_in(v)
1688+
o, = g.neighbors_out(v)
16891689
g.add_edge(i, o, g.edge_label(i, v)[0]*g.edge_label(v, o)[0])
16901690
g.delete_vertex(v)
16911691
return g

src/sage/dynamics/arithmetic_dynamics/wehlerK3.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1140,20 +1140,20 @@ def sigmaX(self, P, **kwds):
11401140
raise TypeError("%s fails to convert into the map's domain %s, but a `pushforward` method is not properly implemented" % (P, self))
11411141
pt = list(P[0]) + [0, 0, 0]
11421142
if P[1][0] != 0:
1143-
[a,b,c] = [P[1][0]*self.Gpoly(1, 0)(*pt),
1143+
a, b, c = [P[1][0]*self.Gpoly(1, 0)(*pt),
11441144
-1*P[1][0]*self.Hpoly(1, 0, 1)(*pt) - P[1][1]*self.Gpoly(1, 0)(*pt),
11451145
-P[1][0]*self.Hpoly(1, 0, 2)(*pt) - P[1][2]*self.Gpoly(1, 0)(*pt)]
11461146
elif P[1][1] != 0:
1147-
[a,b,c] = [-1*P[1][1]*self.Hpoly(1, 0, 1)(*pt)-P[1][0]*self.Gpoly(1, 1)(*pt),
1147+
a, b, c = [-1*P[1][1]*self.Hpoly(1, 0, 1)(*pt)-P[1][0]*self.Gpoly(1, 1)(*pt),
11481148
P[1][1]*self.Gpoly(1, 1)(*pt),
11491149
-P[1][1]*self.Hpoly(1, 1, 2)(*pt)-P[1][2]*self.Gpoly(1, 1)(*pt)]
11501150
else:
1151-
[a,b,c] = [-1*P[1][2]*self.Hpoly(1, 0, 2)(*pt) - P[1][0]*self.Gpoly(1, 2)(*pt),
1151+
a, b, c = [-1*P[1][2]*self.Hpoly(1, 0, 2)(*pt) - P[1][0]*self.Gpoly(1, 2)(*pt),
11521152
-P[1][2]*self.Hpoly(1, 1, 2)(*pt) - P[1][1]*self.Gpoly(1, 2)(*pt),
11531153
P[1][2]*self.Gpoly(1, 2)(*pt)]
11541154
Point = [P[0][0], P[0][1], P[0][2], a, b, c]
11551155

1156-
if [a,b,c] != [0,0,0]:
1156+
if any([a, b, c]):
11571157
if normalize:
11581158
Point = self.point(Point,False)
11591159
Point.normalize_coordinates()
@@ -1237,7 +1237,7 @@ def sigmaX(self, P, **kwds):
12371237
if len(V) == 2:
12381238
for D in V:
12391239
if D[s] != 0:
1240-
[a,b,c] = [D[z0], D[z1], D[z2]]
1240+
a, b, c = [D[z0], D[z1], D[z2]]
12411241
else:
12421242
newT = [phi(tee) for tee in T]
12431243
for i in range(2):
@@ -1278,9 +1278,9 @@ def sigmaX(self, P, **kwds):
12781278
raise ValueError("cannot distinguish points in the degenerate fiber")
12791279

12801280
if len(V) == 1:
1281-
[a, b, c] = [V[0][z0], V[0][z1], V[0][z2]]
1281+
a, b, c = [V[0][z0], V[0][z1], V[0][z2]]
12821282

1283-
if len(V) == 0 or [a,b,c] == [0, 0, 0]:
1283+
if len(V) == 0 or not any([a, b, c]):
12841284
SS = PolynomialRing(BR, 3, 'z0, z1, z2', order='lex')
12851285
z0,z1,z2 = SS.gens()
12861286
phi = RR.hom([1, 0, z0, z1, z2], SS)
@@ -1290,7 +1290,7 @@ def sigmaX(self, P, **kwds):
12901290
V = phi(I).variety()
12911291
if len(V) > 1:
12921292
raise ValueError( "cannot distinguish points in the degenerate fiber")
1293-
[a,b,c] = [V[0][z0], V[0][z1], V[0][z2]]
1293+
a, b, c = [V[0][z0], V[0][z1], V[0][z2]]
12941294

12951295
Point = [P[0][0], P[0][1], P[0][2], a, b, c]
12961296
if normalize:
@@ -1384,19 +1384,19 @@ def sigmaY(self, P, **kwds):
13841384
raise TypeError("%s fails to convert into the map's domain %s, but a `pushforward` method is not properly implemented" % (P, self))
13851385
pt = [0, 0, 0] + list(P[1])
13861386
if P[0][0] != 0:
1387-
[a, b, c] = [P[0][0]*self.Gpoly(0, 0)(*pt),
1387+
a, b, c = [P[0][0]*self.Gpoly(0, 0)(*pt),
13881388
-1*P[0][0]*self.Hpoly(0, 0, 1)(*pt) - P[0][1]*self.Gpoly(0, 0)(*pt),
13891389
-P[0][0]*self.Hpoly(0, 0, 2)(*pt) - P[0][2]*self.Gpoly(0, 0)(*pt)]
13901390
elif P[0][1] != 0:
1391-
[a, b, c] = [-1*P[0][1]*self.Hpoly(0, 0, 1)(*pt) - P[0][0]*self.Gpoly(0, 1)(*pt),
1391+
a, b, c = [-1*P[0][1]*self.Hpoly(0, 0, 1)(*pt) - P[0][0]*self.Gpoly(0, 1)(*pt),
13921392
P[0][1]*self.Gpoly(0, 1)(*pt),
13931393
-P[0][1]*self.Hpoly(0, 1, 2)(*pt) - P[0][2]*self.Gpoly(0, 1)(*pt)]
13941394
else:
1395-
[a, b, c] = [-1*P[0][2]*self.Hpoly(0, 0, 2)(*pt) - P[0][0]*self.Gpoly(0, 2)(*pt),
1395+
a, b, c = [-1*P[0][2]*self.Hpoly(0, 0, 2)(*pt) - P[0][0]*self.Gpoly(0, 2)(*pt),
13961396
- P[0][2]*self.Hpoly(0, 1, 2)(*pt) - P[0][1]*self.Gpoly(0, 2)(*pt),
13971397
P[0][2]*self.Gpoly(0, 2)(*pt)]
13981398
Point = [a, b, c, P[1][0], P[1][1], P[1][2]]
1399-
if [a, b, c] != [0, 0, 0]:
1399+
if any([a, b, c]):
14001400
if normalize:
14011401
Point = self.point(Point, False)
14021402
Point.normalize_coordinates()
@@ -1520,18 +1520,18 @@ def sigmaY(self, P, **kwds):
15201520
if len(V) > 1:
15211521
raise ValueError("cannot distinguish points in the degenerate fiber")
15221522
if len(V) == 1:
1523-
[a, b, c] = [V[0][z0], V[0][z1], V[0][z2]]
1524-
if len(V) == 0 or [a,b,c] == [0, 0, 0]:
1523+
a, b, c = [V[0][z0], V[0][z1], V[0][z2]]
1524+
if len(V) == 0 or not any([a, b, c]):
15251525
SS = PolynomialRing(BR, 3, 'z0, z1, z2', order='lex')
1526-
z0,z1,z2 = SS.gens()
1526+
z0, z1, z2 = SS.gens()
15271527
phi = RR.hom([1, 0, z0, z1, z2], SS)
15281528
J = phi(I)
15291529
if J.dimension() > 0:
15301530
raise ValueError("cannot distinguish points in the degenerate fiber")
15311531
V = phi(I).variety()
15321532
if len(V) > 1:
15331533
raise ValueError("cannot distinguish points in the degenerate fiber")
1534-
[a,b,c] = [V[0][z0], V[0][z1], V[0][z2]]
1534+
a, b, c = [V[0][z0], V[0][z1], V[0][z2]]
15351535

15361536
Point = [a, b, c, P[1][0], P[1][1], P[1][2]]
15371537
if normalize:

src/sage/geometry/hyperbolic_space/hyperbolic_geodesic.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,11 +1213,10 @@ def ideal_endpoints(self):
12131213
[Boundary point in UHP -sqrt(65) + 9,
12141214
Boundary point in UHP sqrt(65) + 9]
12151215
"""
1216-
12171216
start = self._start.coordinates()
12181217
end = self._end.coordinates()
1219-
[x1, x2] = [real(k) for k in [start, end]]
1220-
[y1, y2] = [imag(k) for k in [start, end]]
1218+
x1, x2 = [real(k) for k in [start, end]]
1219+
y1, y2 = [imag(k) for k in [start, end]]
12211220
M = self._model
12221221
# infinity is the first endpoint, so the other ideal endpoint
12231222
# is just the real part of the second coordinate
@@ -2046,8 +2045,7 @@ def _to_std_geod(self, p):
20462045
Full MatrixSpace of 2 by 2 dense matrices over Complex Field
20472046
with 53 bits of precision
20482047
"""
2049-
2050-
[s, e] = [k.coordinates() for k in self.complete().endpoints()]
2048+
s, e = [k.coordinates() for k in self.complete().endpoints()]
20512049
B = HyperbolicGeodesicUHP._get_B(p)
20522050
# outmat below will be returned after we normalize the determinant.
20532051
outmat = B * HyperbolicGeodesicUHP._crossratio_matrix(s, p, e)

src/sage/geometry/hyperbolic_space/hyperbolic_model.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,9 +1091,9 @@ def random_isometry(self, preserve_orientation=True, **kwargs):
10911091
sage: B.preserves_orientation() # needs scipy
10921092
False
10931093
"""
1094-
[a, b, c, d] = [RR.random_element() for k in range(4)]
1094+
a, b, c, d = [RR.random_element() for k in range(4)]
10951095
while abs(a*d - b*c) < EPSILON:
1096-
[a, b, c, d] = [RR.random_element() for k in range(4)]
1096+
a, b, c, d = [RR.random_element() for k in range(4)]
10971097
M = matrix(RDF, 2, [a, b, c, d])
10981098
M = M / (M.det()).abs().sqrt()
10991099
if M.det() > 0:

src/sage/graphs/graph.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5781,7 +5781,7 @@ def write_to_eps(self, filename, **options):
57815781
"""
57825782
from sage.graphs.print_graphs import print_graph_eps
57835783
pos = self.layout(**options)
5784-
[xmin, xmax, ymin, ymax] = self._layout_bounding_box(pos)
5784+
xmin, xmax, ymin, ymax = self._layout_bounding_box(pos)
57855785
for v in pos:
57865786
pos[v] = (1.8*(pos[v][0] - xmin)/(xmax - xmin) - 0.9, 1.8*(pos[v][1] - ymin)/(ymax - ymin) - 0.9)
57875787
if filename[-4:] != '.eps':

src/sage/knots/link.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2868,8 +2868,8 @@ def _bracket(self):
28682868

28692869
cross = pd_code[0]
28702870
rest = [list(vertex) for vertex in pd_code[1:]]
2871-
[a, b, c, d] = cross
2872-
if a == d and c == b and len(rest) > 0:
2871+
a, b, c, d = cross
2872+
if a == d and c == b and rest:
28732873
return (~t + t**(-5)) * Link(rest)._bracket()
28742874
elif a == b and c == d and len(rest) > 0:
28752875
return (t + t**5) * Link(rest)._bracket()

src/sage/matroids/matroids_plot_helpers.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ def slp(M1, pos_dict=None, B=None) -> tuple:
398398
sage: M1 = Matroid(ring=GF(2), matrix=[[1, 0, 0, 0, 1, 1, 1,0,1,0,1],
399399
....: [0, 1, 0, 1, 0, 1, 1,0,0,1,0],
400400
....: [0, 0, 1, 1, 1, 0, 1,0,0,0,0]])
401-
sage: [M,L,P] = matroids_plot_helpers.slp(M1) # needs sage.rings.finite_rings
401+
sage: M, L, P = matroids_plot_helpers.slp(M1) # needs sage.rings.finite_rings
402402
sage: M.is_simple() # needs sage.rings.finite_rings
403403
True
404404
sage: setprint([L,P]) # needs sage.rings.finite_rings
@@ -408,7 +408,7 @@ def slp(M1, pos_dict=None, B=None) -> tuple:
408408
....: [0, 0, 1, 1, 1, 0, 1,0,0,0,0]])
409409
sage: posdict = {8: (0, 0), 1: (2, 0), 2: (1, 2), 3: (1.5, 1.0),
410410
....: 4: (0.5, 1.0), 5: (1.0, 0.0), 6: (1.0, 0.6666666666666666)}
411-
sage: [M,L,P] = matroids_plot_helpers.slp(M1, pos_dict=posdict) # needs sage.rings.finite_rings
411+
sage: M, L, P = matroids_plot_helpers.slp(M1, pos_dict=posdict) # needs sage.rings.finite_rings
412412
sage: M.is_simple() # needs sage.rings.finite_rings
413413
True
414414
sage: setprint([L,P]) # needs sage.rings.finite_rings
@@ -479,7 +479,7 @@ def addlp(M, M1, L, P, ptsdict, G=None, limits=None) -> tuple:
479479
sage: M = Matroid(ring=GF(2), matrix=[[1, 0, 0, 0, 1, 1, 1,0,1],
480480
....: [0, 1, 0, 1, 0, 1, 1,0,0],
481481
....: [0, 0, 1, 1, 1, 0, 1,0,0]])
482-
sage: [M1,L,P] = matroids_plot_helpers.slp(M) # needs sage.rings.finite_rings
482+
sage: M1, L, P = matroids_plot_helpers.slp(M) # needs sage.rings.finite_rings
483483
sage: G, lims = matroids_plot_helpers.addlp(M,M1,L,P,{0:(0,0)}) # needs sage.plot sage.rings.finite_rings
484484
sage: G.show(axes=False) # needs sage.plot sage.rings.finite_rings
485485
@@ -759,7 +759,7 @@ def geomrep(M1, B1=None, lineorders1=None, pd=None, sp=False):
759759
"""
760760
G = Graphics()
761761
# create lists of loops and parallel elements and simplify given matroid
762-
[M, L, P] = slp(M1, pos_dict=pd, B=B1)
762+
M, L, P = slp(M1, pos_dict=pd, B=B1)
763763
if B1 is None:
764764
B1 = list(M.basis())
765765
M._cached_info = M1._cached_info

0 commit comments

Comments
 (0)