Skip to content

Commit 57b7771

Browse files
author
Release Manager
committed
gh-36898: ruff auto-fixing several details in combinat folder this was scripted using `ruff --fix --select=UP009,UP018,UP034,UP039,UP025 src/sage/combinat` see https://docs.astral.sh/ruff/rules/#pyupgrade-up ### 📝 Checklist - [x] The title is concise, informative, and self-explanatory. - [x] The description explains in detail what this PR is about. URL: #36898 Reported by: Frédéric Chapoton Reviewer(s): David Coudert
2 parents f8d7d6d + 45b27f7 commit 57b7771

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+125
-163
lines changed

src/sage/combinat/abstract_tree.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
r"""
32
Abstract Recursive Trees
43
@@ -73,7 +72,7 @@
7372
# of it later.
7473

7574

76-
class AbstractTree():
75+
class AbstractTree:
7776
"""
7877
Abstract Tree.
7978
@@ -1276,7 +1275,7 @@ def node_to_str(t):
12761275
if hasattr(t, "label"):
12771276
return str(t.label())
12781277
else:
1279-
return u"o"
1278+
return "o"
12801279
# other possible choices for nodes would be u"█ ▓ ░ ╋ ╬"
12811280

12821281
if self.is_empty():
@@ -1291,9 +1290,9 @@ def node_to_str(t):
12911290

12921291
if len(self) == 1:
12931292
repr_child = self[0]._unicode_art_()
1294-
sep = UnicodeArt([u" " * repr_child._root])
1293+
sep = UnicodeArt([" " * repr_child._root])
12951294
t_repr = UnicodeArt([node_to_str(self)])
1296-
repr_root = (sep + t_repr) * (sep + UnicodeArt([u"│"]))
1295+
repr_root = (sep + t_repr) * (sep + UnicodeArt(["│"]))
12971296
t_repr = repr_root * repr_child
12981297
t_repr._root = repr_child._root
12991298
t_repr._baseline = t_repr._h - 1
@@ -1303,17 +1302,17 @@ def node_to_str(t):
13031302
l_repr = [subtree._unicode_art_() for subtree in self]
13041303
acc = l_repr.pop(0)
13051304
whitesep = acc._root
1306-
lf_sep = u" " * whitesep + u"╭" + u"─" * (acc._l - acc._root)
1307-
ls_sep = u" " * whitesep + u"│" + u" " * (acc._l - acc._root)
1305+
lf_sep = " " * whitesep + "╭" + "─" * (acc._l - acc._root)
1306+
ls_sep = " " * whitesep + "│" + " " * (acc._l - acc._root)
13081307
while l_repr:
13091308
tr = l_repr.pop(0)
1310-
acc += UnicodeArt([u" "]) + tr
1309+
acc += UnicodeArt([" "]) + tr
13111310
if not len(l_repr):
1312-
lf_sep += u"─" * (tr._root) + u"╮"
1313-
ls_sep += u" " * (tr._root) + u"│"
1311+
lf_sep += "─" * (tr._root) + "╮"
1312+
ls_sep += " " * (tr._root) + "│"
13141313
else:
1315-
lf_sep += u"─" * (tr._root) + u"┬" + u"─" * (tr._l - tr._root)
1316-
ls_sep += u" " * (tr._root) + u"│" + u" " * (tr._l - tr._root)
1314+
lf_sep += "─" * (tr._root) + "┬" + "─" * (tr._l - tr._root)
1315+
ls_sep += " " * (tr._root) + "│" + " " * (tr._l - tr._root)
13171316
mid = whitesep + (len(lf_sep) - whitesep) // 2
13181317
node = node_to_str(self)
13191318
lf_sep = (lf_sep[:mid - len(node) // 2] + node +
@@ -1501,7 +1500,7 @@ def create_node(self):
15011500
. the matrix
15021501
. and the edges
15031502
"""
1504-
name = "".join((chr(ord(x) + 49) for x in str(num[0])))
1503+
name = "".join(chr(ord(x) + 49) for x in str(num[0]))
15051504
node = cmd + name
15061505
nodes.append((name,
15071506
(str(self.label()) if hasattr(self, "label") else ""))

src/sage/combinat/backtrack.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
from sage.sets.recursively_enumerated_set import RecursivelyEnumeratedSet_forest
3737

3838

39-
class GenericBacktracker():
39+
class GenericBacktracker:
4040
r"""
4141
A generic backtrack tool for exploring a search space organized as a tree,
4242
with branch pruning, etc.

src/sage/combinat/baxter_permutations.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
Baxter permutations
43
"""

src/sage/combinat/bijectionist.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2455,7 +2455,7 @@ def solutions_iterator(self):
24552455
yield from self._bmilp.solutions_iterator(False, [])
24562456

24572457

2458-
class _BijectionistMILP():
2458+
class _BijectionistMILP:
24592459
r"""
24602460
Wrapper class for the MixedIntegerLinearProgram (MILP).
24612461

src/sage/combinat/binary_tree.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
"""
32
Binary Trees
43
@@ -593,7 +592,7 @@ def _unicode_art_(self):
593592
o o o o
594593
"""
595594
def node_to_str(bt):
596-
return str(bt.label()) if hasattr(bt, "label") else u"o"
595+
return str(bt.label()) if hasattr(bt, "label") else "o"
597596

598597
if self.is_empty():
599598
from sage.typeset.unicode_art import empty_unicode_art
@@ -609,14 +608,14 @@ def node_to_str(bt):
609608
node = node_to_str(self)
610609
rr_tree = self[1]._unicode_art_()
611610
if rr_tree._root > 2:
612-
f_line = u" " * (rr_tree._root - 3) + node
613-
s_line = u" " * (len(node) + rr_tree._root - 3) + u"╲"
611+
f_line = " " * (rr_tree._root - 3) + node
612+
s_line = " " * (len(node) + rr_tree._root - 3) + "╲"
614613
t_repr = UnicodeArt([f_line, s_line]) * rr_tree
615614
t_repr._root = rr_tree._root - 2
616615
else:
617616
f_line = node
618-
s_line = u" ╲"
619-
t_line = u" " * (len(node) + 1)
617+
s_line = " ╲"
618+
t_line = " " * (len(node) + 1)
620619
t_repr = UnicodeArt([f_line, s_line]) * (UnicodeArt([t_line]) + rr_tree)
621620
t_repr._root = rr_tree._root
622621
t_repr._baseline = t_repr._h - 1
@@ -625,8 +624,8 @@ def node_to_str(bt):
625624
if self[1].is_empty():
626625
node = node_to_str(self)
627626
lr_tree = self[0]._unicode_art_()
628-
f_line = u" " * (lr_tree._root + 1) + node
629-
s_line = u" " * lr_tree._root + u"╱"
627+
f_line = " " * (lr_tree._root + 1) + node
628+
s_line = " " * lr_tree._root + "╱"
630629
t_repr = UnicodeArt([f_line, s_line]) * lr_tree
631630
t_repr._root = lr_tree._root + 2
632631
t_repr._baseline = t_repr._h - 1
@@ -638,10 +637,10 @@ def node_to_str(bt):
638637
nb_ = lr_tree._l - lr_tree._root + rr_tree._root - 1
639638
nb_L = nb_ // 2
640639
nb_R = nb_L + (nb_ % 2)
641-
f_line = u" " * (lr_tree._root + 1) + u"_" * nb_L + node
642-
f_line += u"_" * nb_R
643-
s_line = u" " * lr_tree._root + u"╱" + u" " * (len(node) + rr_tree._root - 1 + (lr_tree._l - lr_tree._root)) + u"╲"
644-
t_repr = UnicodeArt([f_line, s_line]) * (lr_tree + UnicodeArt([u" " * (len(node) + 2)]) + rr_tree)
640+
f_line = " " * (lr_tree._root + 1) + "_" * nb_L + node
641+
f_line += "_" * nb_R
642+
s_line = " " * lr_tree._root + "╱" + " " * (len(node) + rr_tree._root - 1 + (lr_tree._l - lr_tree._root)) + "╲"
643+
t_repr = UnicodeArt([f_line, s_line]) * (lr_tree + UnicodeArt([" " * (len(node) + 2)]) + rr_tree)
645644
t_repr._root = lr_tree._root + nb_L + 2
646645
t_repr._baseline = t_repr._h - 1
647646
return t_repr

src/sage/combinat/combinatorial_map.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ def combinatorial_map_wrapper(f=None, order=None, name=None):
197197
# combinatorial_map = combinatorial_map_wrapper
198198

199199

200-
class CombinatorialMap():
200+
class CombinatorialMap:
201201
r"""
202202
This is a wrapper class for methods that are *combinatorial maps*.
203203

src/sage/combinat/composition.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
r"""
32
Integer compositions
43

src/sage/combinat/composition_tableau.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def __init__(self, parent, t):
120120

121121
CombinatorialElement.__init__(self, parent, t)
122122

123-
def _repr_diagram(self):
123+
def _repr_diagram(self) -> str:
124124
r"""
125125
Return a string representation of ``self`` as an array.
126126
@@ -132,8 +132,8 @@ def _repr_diagram(self):
132132
3 2
133133
4 4
134134
"""
135-
return '\n'.join(("".join(("%3s" % str(x) for x in row))
136-
for row in self))
135+
return '\n'.join("".join("%3s" % str(x) for x in row)
136+
for row in self)
137137

138138
def __call__(self, *cell):
139139
r"""

src/sage/combinat/crystals/generalized_young_walls.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ def generate_signature(self, i):
285285
strsig = ''.join( x[0] for x in sig)
286286
reducedsig = strsig
287287
while re.search(r"\+\s*-",reducedsig):
288-
reducedsig = re.sub(r"\+\s*-", lambda match : str().ljust(len(match.group(int(0)))) , reducedsig)
288+
reducedsig = re.sub(r"\+\s*-", lambda match : ''.ljust(len(match.group(0))) , reducedsig)
289289
return (sig,reducedsig)
290290

291291
def signature(self, i):

src/sage/combinat/crystals/tensor_product.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ class Element(TensorProductOfSuperCrystalsElement):
655655
pass
656656

657657

658-
class QueerSuperCrystalsMixin():
658+
class QueerSuperCrystalsMixin:
659659
"""
660660
Mixin class with methods for a finite queer supercrystal.
661661
"""

0 commit comments

Comments
 (0)