Skip to content

Commit ad8912e

Browse files
committed
Up to but not including Counting Cycles
1 parent d16bf8c commit ad8912e

1 file changed

Lines changed: 21 additions & 10 deletions

File tree

test/test_combinatorica.py

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def test_combinatorica_permutations_1_1():
5454
" {3, 1, 2, 4}, {3, 1, 4, 2}, {3, 2, 1, 4}, {3, 2, 4, 1}, "
5555
" {3, 4, 1, 2}, {3, 4, 2, 1}, {4, 1, 2, 3}, {4, 1, 3, 2}, "
5656
" {4, 2, 1, 3}, {4, 2, 3, 1}, {4, 3, 1, 2}, {4, 3, 2, 1}} ",
57-
"slower method for computing permutations in lex order, 1.1.2, Page 6"
57+
"slower method for computing permutations in lex order, 1.1.2, Page 6",
5858
),
5959
(
6060
"Map[RankPermutation, Permutations[Range[4]]]",
@@ -126,7 +126,7 @@ def test_combinatorica_permutations_1_2():
126126
" {4, 3, 6, 5, 1, 2}, "
127127
" {5, 6, 2, 1, 4, 3}, "
128128
" {6, 5, 4, 3, 2, 1}}",
129-
"Symmetric group S_n. S_n is not commutative. 1.2 Page 17"
129+
"Symmetric group S_n. S_n is not commutative. 1.2 Page 17",
130130
),
131131
(
132132
"InversePermutation[{4,8,5,2,1,3,7,6}]",
@@ -165,43 +165,53 @@ def test_combinatorica_permutations_1_2():
165165
(
166166
"ToCycles[Range[10]]",
167167
"{{1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9}, {10}}",
168-
"ToCycles, 1.2.4, Page 21"
168+
"ToCycles, 1.2.4, Page 21",
169169
),
170170
(
171171
"Select[ Permutations[Range[4]], (Length[ToCycles[#]] == 1)&]",
172172
"{{2, 3, 4, 1}, {2, 4, 1, 3}, {3, 1, 4, 2}, "
173173
" {3, 4, 2, 1}, {4, 1, 2, 3}, {4, 3, 1, 2}}",
174-
"ToCycles, 1.2.4, Page 21"
174+
"ToCycles, 1.2.4, Page 21",
175175
),
176176
(
177177
"ToCycles[ Reverse[Range[10]] ]",
178178
"{{10, 1}, {9, 2}, {8, 3}, {7, 4}, {6, 5}}",
179-
"Reverse ToCycles, 1.2.4, Page 21"
179+
"Reverse ToCycles, 1.2.4, Page 21",
180180
),
181181
(
182182
"Permute[ Reverse[Range[10]], Reverse[Range[10]] ]",
183183
"Range[10]",
184-
"Pemute as involution, 1.2.4, Page 21"
184+
"Pemute as involution, 1.2.4, Page 21",
185185
),
186186
(
187187
"Apply[ And, List[p=RandomPermutation[8]; p===FromCycles[ToCycles[p]]] ]",
188188
"True",
189-
"Convert to-and-from cycle structure is identity, 1.2.4, Page 22"
189+
"Convert to-and-from cycle structure is identity, 1.2.4, Page 22",
190190
),
191191
(
192192
"Apply[ And, List[p=RandomPermutation[8]; p===FromCycles[ToCycles[p]]] ]",
193193
"True",
194-
"Convert to-and-from cycle structure is identity, 1.2.4, Page 22"
194+
"Convert to-and-from cycle structure is identity, 1.2.4, Page 22",
195195
),
196196
(
197197
"ToCycles[{6,2,1,5,4,3} ]",
198198
"{{6, 3, 1}, {2}, {5, 4}}",
199-
"Three permutations, one of each size, 1.2.4, Page 22"
199+
"Three permutations, one of each size, 1.2.4, Page 22",
200200
),
201201
(
202202
"HideCycles[ToCycles[{6,2,1,5,4,3}]]",
203203
"{4, 5, 2, 1, 6, 3}",
204-
"Permutations is not what we started with, 1.2.4, Page 23"
204+
"Permutations is not what we started with, 1.2.4, Page 23",
205+
),
206+
(
207+
"RevealCycles[ HideCycles[ToCycles[{6,2,1,5,4,3}]] ]",
208+
"{{4, 5}, {2}, {1, 6, 3}}",
209+
"RevealCycles 1.2.4, Page 23",
210+
),
211+
(
212+
"Apply[Or, Map[(# === HideCycles[ToCycles[#]])&, Permutations[Range[5]] ]]",
213+
"False",
214+
"None of the permutatoins on five elements is identical to its hidden cycle representation 1.2.4, Page 23",
205215
),
206216
):
207217
check_evaluation(str_expr, str_expected, message)
@@ -235,6 +245,7 @@ def test_combinatorica_permutations_1_5():
235245
):
236246
check_evaluation(str_expr, str_expected, message)
237247

248+
238249
def test_combinatorica_rest():
239250

240251
# Permutation[3] doesn't work

0 commit comments

Comments
 (0)