Skip to content

Commit a573bb4

Browse files
committed
remove unnecessary calls to list in doctests
1 parent 21cb54f commit a573bb4

File tree

1 file changed

+15
-18
lines changed

1 file changed

+15
-18
lines changed

src/sage/combinat/bijectionist.py

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@
4242
`(s, wex, fix) \sim (llis, des, adj)`::
4343
4444
sage: N = 3
45-
sage: As = [list(Permutations(n)) for n in range(N+1)]
46-
sage: A = B = sum(As, [])
45+
sage: A = B = [pi for n in range(N+1) for pi in Permutations(n)]
4746
sage: alpha1 = lambda p: len(p.weak_excedences())
4847
sage: alpha2 = lambda p: len(p.fixed_points())
4948
sage: beta1 = lambda p: len(p.descents(final_descent=True)) if p else 0
@@ -106,7 +105,7 @@
106105
+-----------+---+--------+--------+--------+
107106
108107
sage: from sage.combinat.cyclic_sieving_phenomenon import orbit_decomposition
109-
sage: bij.set_constant_blocks(sum([orbit_decomposition(A, rotate_permutation) for A in As], []))
108+
sage: bij.set_constant_blocks(orbit_decomposition(A, rotate_permutation))
110109
sage: bij.constant_blocks()
111110
{{[1, 3, 2], [2, 1, 3], [3, 2, 1]}}
112111
sage: next(bij.solutions_iterator())
@@ -124,9 +123,9 @@
124123
There is no rotation invariant statistic on non crossing set partitions which is equidistributed
125124
with the Strahler number on ordered trees::
126125
127-
sage: N = 8; As = [[SetPartition(d.to_noncrossing_partition()) for d in DyckWords(n)] for n in range(N)]
128-
sage: A = sum(As, [])
129-
sage: B = sum([list(OrderedTrees(n)) for n in range(1, N+1)], [])
126+
sage: N = 8;
127+
sage: A = [SetPartition(d.to_noncrossing_partition()) for n in range(N) for d in DyckWords(n)]
128+
sage: B = [t for n in range(1, N+1) for t in OrderedTrees(n)]
130129
sage: theta = lambda m: SetPartition([[i % m.size() + 1 for i in b] for b in m])
131130
132131
The following code is equivalent to ``tau = findstat(397)``::
@@ -144,7 +143,7 @@
144143
sage: bij = Bijectionist(A, B, tau)
145144
sage: bij.set_statistics((lambda a: a.size(), lambda b: b.node_number()-1))
146145
sage: from sage.combinat.cyclic_sieving_phenomenon import orbit_decomposition
147-
sage: bij.set_constant_blocks(sum([orbit_decomposition(A_n, theta) for A_n in As], []))
146+
sage: bij.set_constant_blocks(orbit_decomposition(A, theta))
148147
sage: list(bij.solutions_iterator())
149148
[]
150149
@@ -279,7 +278,7 @@
279278
280279
Constant blocks::
281280
282-
sage: A = B = list('abcd')
281+
sage: A = B = 'abcd'
283282
sage: pi = lambda p1, p2: 'abcdefgh'[A.index(p1) + A.index(p2)]
284283
sage: rho = lambda s1, s2: (s1 + s2) % 2
285284
sage: bij = Bijectionist(A, B, lambda x: B.index(x) % 2, P=[['a', 'c']], pi_rho=((2, pi, rho),))
@@ -492,7 +491,7 @@ def __init__(self, A, B, tau=None, alpha_beta=tuple(), P=[],
492491
493492
Check that large input sets are handled well::
494493
495-
sage: A = B = list(range(20000))
494+
sage: A = B = range(20000)
496495
sage: bij = Bijectionist(A, B) # long time
497496
"""
498497
# glossary of standard letters:
@@ -569,7 +568,7 @@ def set_constant_blocks(self, P):
569568
current partition can be reviewed using
570569
:meth:`constant_blocks`::
571570
572-
sage: A = B = list('abcd')
571+
sage: A = B = 'abcd'
573572
sage: bij = Bijectionist(A, B, lambda x: B.index(x) % 2)
574573
sage: bij.constant_blocks()
575574
{}
@@ -1766,7 +1765,7 @@ def possible_values(self, p=None, optimal=False):
17661765
17671766
Test an unfeasible problem::
17681767
1769-
sage: A = B = list('ab')
1768+
sage: A = B = 'ab'
17701769
sage: bij = Bijectionist(A, B, lambda x: B.index(x) % 2)
17711770
sage: bij.set_constant_blocks([['a', 'b']])
17721771
sage: bij.possible_values(p="a")
@@ -2147,11 +2146,11 @@ def _preprocess_intertwining_relations(self):
21472146
21482147
.. TODO::
21492148
2150-
it is not clear, whether this method makes sense
2149+
it is not clear whether this method makes sense
21512150
21522151
EXAMPLES::
21532152
2154-
sage: A = B = list('abcd')
2153+
sage: A = B = 'abcd'
21552154
sage: bij = Bijectionist(A, B, lambda x: B.index(x) % 2)
21562155
sage: pi = lambda p1, p2: 'abcdefgh'[A.index(p1) + A.index(p2)]
21572156
sage: rho = lambda s1, s2: (s1 + s2) % 2
@@ -2273,7 +2272,7 @@ def solutions_iterator(self):
22732272
22742273
EXAMPLES::
22752274
2276-
sage: A = B = list('abc')
2275+
sage: A = B = 'abc'
22772276
sage: bij = Bijectionist(A, B, lambda x: B.index(x) % 2, solver="GLPK")
22782277
sage: next(bij.solutions_iterator())
22792278
{'a': 0, 'b': 1, 'c': 0}
@@ -2362,8 +2361,7 @@ def solutions_iterator(self):
23622361
veto: x_0 + x_1 + x_3 + x_4 + x_6 + x_10 + x_14 <= 6
23632362
veto: x_0 + x_1 + x_2 + x_5 + x_6 + x_10 + x_14 <= 6
23642363
2365-
Changing or re-setting problem parameters clears the internal cache and
2366-
prints even more information::
2364+
Changing or re-setting problem parameters clears the internal cache::
23672365
23682366
sage: bij.set_constant_blocks(P)
23692367
sage: _ = list(bij.solutions_iterator())
@@ -2519,7 +2517,6 @@ class _BijectionistMILP():
25192517
Wrapper class for the MixedIntegerLinearProgram (MILP). This
25202518
class is used to manage the MILP, add constraints, solve the
25212519
problem and check for uniqueness of solution values.
2522-
25232520
"""
25242521
def __init__(self, bijectionist: Bijectionist, solutions=None):
25252522
r"""
@@ -2987,7 +2984,7 @@ def add_intertwining_relation_constraints(self):
29872984
29882985
EXAMPLES::
29892986
2990-
sage: A = B = list('abcd')
2987+
sage: A = B = 'abcd'
29912988
sage: bij = Bijectionist(A, B, lambda x: B.index(x) % 2)
29922989
sage: pi = lambda p1, p2: 'abcdefgh'[A.index(p1) + A.index(p2)]
29932990
sage: rho = lambda s1, s2: (s1 + s2) % 2

0 commit comments

Comments
 (0)