Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Perm((1, 3, 4, 0, 2)): [set()],
Perm((1, 4, 0, 2, 3)): [{(2, 2)}],
Perm((2, 0, 1, 4, 3)): [set()],
Perm((2, 0, 3, 1, 4)): [{(2, 2)}],
Perm((2, 0, 3, 4, 1)): [{(2, 2)}],
Perm((2, 0, 4, 1, 3)): [set()],
Perm((2, 3, 0, 1, 4)): [set()],
Perm((2, 3, 0, 4, 1)): [set()],
Perm((2, 3, 4, 0, 1)): [set()],
Perm((2, 4, 0, 1, 3)): [set()],
Perm((3, 0, 1, 4, 2)): [{(3, 3)}],
Perm((3, 0, 4, 1, 2)): [set()],
Perm((3, 4, 0, 1, 2)): [set()],
}
}
assert bisc(A, 5, 7) == {
5: {
Perm((0, 2, 1, 4, 3)): [set()],
Perm((0, 2, 4, 1, 3)): [{(3, 3)}],
Perm((0, 3, 1, 4, 2)): [{(3, 3)}],
Perm((0, 3, 4, 1, 2)): [set()],
Perm((1, 0, 2, 4, 3)): [set()],
Perm((1, 0, 3, 2, 4)): [set()],
Perm((1, 0, 3, 4, 2)): [set()],
Perm((1, 0, 4, 2, 3)): [set()],
Perm((1, 2, 0, 4, 3)): [set()],
Perm((1, 2, 4, 0, 3)): [{(3, 3)}],
Perm((1, 3, 0, 2, 4)): [{(2, 2)}],
Perm((1, 3, 0, 4, 2)): [set()],
Perm((1, 3, 4, 0, 2)): [set()],
Perm((1, 4, 0, 2, 3)): [{(2, 2)}],
Perm((2, 0, 1, 4, 3)): [set()],
def test_yt32():
"""
Testing permutations with Young tableaux without the shape [2,2]
Expected answer is
25 mesh patterns (some classical)
Suffices to look at permutations up to length 6
"""
A = read_bisc_file(ppf + "yt_perm_avoids_32_good_len8")
B = read_bisc_file(ppf + "yt_perm_avoids_32_bad_len8")
# Too short
assert bisc(A, 4, 4) == {}
assert bisc(A, 5, 5) == {
5: {
Perm((0, 2, 1, 4, 3)): [set()],
Perm((0, 2, 4, 1, 3)): [set()],
Perm((0, 3, 1, 4, 2)): [set()],
Perm((0, 3, 4, 1, 2)): [set()],
Perm((1, 0, 2, 4, 3)): [set()],
Perm((1, 0, 3, 2, 4)): [set()],
Perm((1, 0, 3, 4, 2)): [set()],
Perm((1, 0, 4, 2, 3)): [set()],
Perm((1, 2, 0, 4, 3)): [set()],
Perm((1, 2, 4, 0, 3)): [set()],
Perm((1, 3, 0, 2, 4)): [set()],
Perm((1, 3, 0, 4, 2)): [set()],
Perm((1, 3, 4, 0, 2)): [set()],
Perm((1, 4, 0, 2, 3)): [set()],
def test_yt32():
"""
Testing permutations with Young tableaux without the shape [2,2]
Expected answer is
25 mesh patterns (some classical)
Suffices to look at permutations up to length 6
"""
A = read_bisc_file(ppf + "yt_perm_avoids_32_good_len8")
B = read_bisc_file(ppf + "yt_perm_avoids_32_bad_len8")
# Too short
assert bisc(A, 4, 4) == {}
assert bisc(A, 5, 5) == {
5: {
Perm((0, 2, 1, 4, 3)): [set()],
Perm((0, 2, 4, 1, 3)): [set()],
Perm((0, 3, 1, 4, 2)): [set()],
Perm((0, 3, 4, 1, 2)): [set()],
Perm((1, 0, 2, 4, 3)): [set()],
Perm((1, 0, 3, 2, 4)): [set()],
Perm((1, 0, 3, 4, 2)): [set()],
Perm((1, 0, 4, 2, 3)): [set()],
Perm((1, 2, 0, 4, 3)): [set()],
Perm((1, 2, 4, 0, 3)): [set()],
Perm((1, 3, 0, 2, 4)): [set()],
Perm((1, 3, 0, 4, 2)): [set()],
Perm((1, 3, 4, 0, 2)): [set()],
Perm((1, 4, 0, 2, 3)): [set()],
Perm((2, 0, 1, 4, 3)): [set()],
Perm((1, 3, 0, 2)): [{(2, 2)}],
Perm((2, 0, 3, 1)): [{(2, 2)}],
Perm((2, 3, 0, 1)): [set()],
}
}
assert bisc(A, 4, 7) == {
4: {
Perm((1, 0, 3, 2)): [set()],
Perm((1, 3, 0, 2)): [{(2, 2)}],
Perm((2, 0, 3, 1)): [{(2, 2)}],
Perm((2, 3, 0, 1)): [set()],
}
}
# Looking for longer patterns
assert bisc(A, 5, 6) == {
4: {
Perm((1, 0, 3, 2)): [set()],
Perm((1, 3, 0, 2)): [{(2, 2)}],
Perm((2, 0, 3, 1)): [{(2, 2)}],
Perm((2, 3, 0, 1)): [set()],
},
5: {},
}
assert bisc(A, 5, 7) == {
4: {
Perm((1, 0, 3, 2)): [set()],
Perm((1, 3, 0, 2)): [{(2, 2)}],
Perm((2, 0, 3, 1)): [{(2, 2)}],
Perm((2, 3, 0, 1)): [set()],
},
5: {},
def test_SimSun():
"""
Testing SimSun permutations
Expected answer is
210 (1,0), (1,1), (2,2)
Suffices to look at permutations up to length 4
"""
A = read_bisc_file(ppf + "SimSun_good_len8")
# Too short
assert bisc(A, 2, 4) == {}
assert bisc(A, 3, 3) == {3: {Perm((2, 1, 0)): [set()]}}
# Should get expected answer
assert bisc(A, 3, 4) == {3: {Perm((2, 1, 0)): [{(1, 0), (1, 1), (2, 2)}]}}
assert bisc(A, 3, 5) == {3: {Perm((2, 1, 0)): [{(1, 0), (1, 1), (2, 2)}]}}
assert bisc(A, 3, 6) == {3: {Perm((2, 1, 0)): [{(1, 0), (1, 1), (2, 2)}]}}
assert bisc(A, 4, 6) == {3: {Perm((2, 1, 0)): [{(1, 0), (1, 1), (2, 2)}]}, 4: {}}
B = read_bisc_file(ppf + "forest_like_bad_len8")
# Too short
assert bisc(A, 3, 4) == {}
assert bisc(A, 4, 4) == {
4: {Perm((0, 2, 1, 3)): [set()], Perm((1, 0, 3, 2)): [set()]}
}
# # Should get expected answer
assert bisc(A, 4, 5) == {
4: {Perm((0, 2, 1, 3)): [set()], Perm((1, 0, 3, 2)): [{(2, 2)}]}
}
assert bisc(A, 4, 6) == {
4: {Perm((0, 2, 1, 3)): [set()], Perm((1, 0, 3, 2)): [{(2, 2)}]}
}
assert bisc(A, 4, 7) == {
4: {Perm((0, 2, 1, 3)): [set()], Perm((1, 0, 3, 2)): [{(2, 2)}]}
}
# # Looking for longer patterns
SG = bisc(A, 5, 7)
assert SG == {
4: {Perm((0, 2, 1, 3)): [set()], Perm((1, 0, 3, 2)): [{(2, 2)}]},
5: {Perm((1, 3, 0, 4, 2)): [set()], Perm((2, 0, 4, 1, 3)): [set()]},
}
assert patterns_suffice_for_bad(SG, 6, B) == (True, [])
assert run_clean_up(SG, B, limit_monitors=5) == (
[[(4, 0, 0), (4, 1, 0)]],
{
(4, 0, 0): (Perm((0, 2, 1, 3)), set()),
(4, 1, 0): (Perm((1, 0, 3, 2)), {(2, 2)}),
(5, 0, 0): (Perm((1, 3, 0, 4, 2)), set()),
def test_smooth():
"""
Testing smooth permutations
Expected answer is
0213
1032
Suffices to look at permutations up to length 4
"""
A = read_bisc_file(ppf + "smooth_good_len8")
B = read_bisc_file(ppf + "smooth_bad_len8")
# Too short
assert bisc(A, 3, 4) == {}
# # Should get expected answer
assert bisc(A, 4, 4) == {
4: {Perm((0, 2, 1, 3)): [set()], Perm((1, 0, 3, 2)): [set()]}
}
assert bisc(A, 4, 5) == {
4: {Perm((0, 2, 1, 3)): [set()], Perm((1, 0, 3, 2)): [set()]}
}
assert bisc(A, 4, 6) == {
4: {Perm((0, 2, 1, 3)): [set()], Perm((1, 0, 3, 2)): [set()]}
}
assert bisc(A, 4, 7) == {
4: {Perm((0, 2, 1, 3)): [set()], Perm((1, 0, 3, 2)): [set()]}
}
# # Looking for longer patterns
4: {
Perm((1, 0, 3, 2)): [set()],
Perm((1, 3, 0, 2)): [{(2, 2)}],
Perm((2, 0, 3, 1)): [{(2, 2)}],
Perm((2, 3, 0, 1)): [set()],
}
}
assert bisc(A, 4, 6) == {
4: {
Perm((1, 0, 3, 2)): [set()],
Perm((1, 3, 0, 2)): [{(2, 2)}],
Perm((2, 0, 3, 1)): [{(2, 2)}],
Perm((2, 3, 0, 1)): [set()],
}
}
assert bisc(A, 4, 7) == {
4: {
Perm((1, 0, 3, 2)): [set()],
Perm((1, 3, 0, 2)): [{(2, 2)}],
Perm((2, 0, 3, 1)): [{(2, 2)}],
Perm((2, 3, 0, 1)): [set()],
}
}
# Looking for longer patterns
assert bisc(A, 5, 6) == {
4: {
Perm((1, 0, 3, 2)): [set()],
Perm((1, 3, 0, 2)): [{(2, 2)}],
Perm((2, 0, 3, 1)): [{(2, 2)}],
Perm((2, 3, 0, 1)): [set()],
},
"""
A = read_bisc_file(ppf + "forest_like_good_len8")
B = read_bisc_file(ppf + "forest_like_bad_len8")
# Too short
assert bisc(A, 3, 4) == {}
assert bisc(A, 4, 4) == {
4: {Perm((0, 2, 1, 3)): [set()], Perm((1, 0, 3, 2)): [set()]}
}
# # Should get expected answer
assert bisc(A, 4, 5) == {
4: {Perm((0, 2, 1, 3)): [set()], Perm((1, 0, 3, 2)): [{(2, 2)}]}
}
assert bisc(A, 4, 6) == {
4: {Perm((0, 2, 1, 3)): [set()], Perm((1, 0, 3, 2)): [{(2, 2)}]}
}
assert bisc(A, 4, 7) == {
4: {Perm((0, 2, 1, 3)): [set()], Perm((1, 0, 3, 2)): [{(2, 2)}]}
}
# # Looking for longer patterns
SG = bisc(A, 5, 7)
assert SG == {
4: {Perm((0, 2, 1, 3)): [set()], Perm((1, 0, 3, 2)): [{(2, 2)}]},
5: {Perm((1, 3, 0, 4, 2)): [set()], Perm((2, 0, 4, 1, 3)): [set()]},
}
assert patterns_suffice_for_bad(SG, 6, B) == (True, [])
assert run_clean_up(SG, B, limit_monitors=5) == (
[[(4, 0, 0), (4, 1, 0)]],
{
B = read_bisc_file(ppf + "West_2_stack_sortable_bad_len8")
# Too short
assert bisc(A, 3, 4) == {}
assert bisc(A, 4, 4) == {
4: {Perm((1, 2, 3, 0)): [set()], Perm((2, 1, 3, 0)): [set()]}
}
# Should get expected answer
assert bisc(A, 4, 5) == {
4: {Perm((1, 2, 3, 0)): [set()], Perm((2, 1, 3, 0)): [{(1, 4)}]}
}
assert bisc(A, 4, 6) == {
4: {Perm((1, 2, 3, 0)): [set()], Perm((2, 1, 3, 0)): [{(1, 4)}]}
}
assert bisc(A, 4, 7) == {
4: {Perm((1, 2, 3, 0)): [set()], Perm((2, 1, 3, 0)): [{(1, 4)}]}
}
# Looking for longer patterns
assert bisc(A, 5, 7) == {
4: {Perm((1, 2, 3, 0)): [set()], Perm((2, 1, 3, 0)): [{(1, 4)}]},
5: {Perm((4, 2, 1, 3, 0)): [{(2, 4), (1, 5)}]},
}
SG = bisc(A, 5, 7)
assert SG == {
4: {Perm((1, 2, 3, 0)): [set()], Perm((2, 1, 3, 0)): [{(1, 4)}]},
5: {Perm((4, 2, 1, 3, 0)): [{(2, 4), (1, 5)}]},
}
assert patterns_suffice_for_bad(SG, 6, B) == (True, [])
assert run_clean_up(SG, B, limit_monitors=5) == (