How to use permuta - 10 common examples

To help you get started, we’ve selected a few permuta examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github PermutaTriangle / Permuta / tests / patterns / test_perm.py View on Github external
Perm((1, 2, 4, 0, 3, 5)).ascii_plot() == " | | | | | |\n"
        "-+-+-+-+-+-●-\n"
        " | | | | | |\n"
        "-+-+-●-+-+-+-\n"
        " | | | | | |\n"
        "-+-+-+-+-●-+-\n"
        " | | | | | |\n"
        "-+-●-+-+-+-+-\n"
        " | | | | | |\n"
        "-●-+-+-+-+-+-\n"
        " | | | | | |\n"
        "-+-+-+-●-+-+-\n"
        " | | | | | |"
    )
    for _ in range(10):
        perm = Perm.random(random.randint(0, 20))
        plot = perm.ascii_plot(cell_size=0).split("\n")
        for i in range(len(perm)):
            assert plot[len(perm) - perm[i] - 1][2 * i] == "\u25cf"
github PermutaTriangle / Permuta / tests / enumeration_strategies / test_core_strategies.py View on Github external
def test_is_valid_extension(self):
        assert Rd2134CoreStrategy.is_valid_extension(Perm((0, 3, 4, 2, 1)))
        assert not Rd2134CoreStrategy.is_valid_extension(Perm((0, 4, 3, 1, 2)))
        assert Rd2134CoreStrategy.is_valid_extension(Perm((0, 1, 2, 3)))
        assert not Rd2134CoreStrategy.is_valid_extension(Perm((0, 1, 2, 4, 3)))
github PermutaTriangle / Permuta / tests / patterns / test_perm.py View on Github external
def test_inverse():
    for i in range(10):
        assert Perm(range(i)) == Perm(range(i)).inverse()
    assert Perm([2, 1, 3, 0]) == Perm([3, 1, 0, 2]).inverse()
    assert Perm((1, 2, 5, 0, 3, 4)).inverse() == Perm((3, 0, 1, 4, 5, 2))
    assert (
        Perm([4, 3, 1, 6, 5, 7, 8, 0, 2]) == Perm([7, 2, 8, 1, 0, 4, 3, 5, 6]).inverse()
    )
github PermutaTriangle / Permuta / tests / patterns / test_perm.py View on Github external
def test_flip_diagonal():
    for i in range(10):
        assert Perm(range(i)) == Perm(range(i)).flip_diagonal()
    assert Perm([2, 1, 3, 0]) == Perm([3, 1, 0, 2]).flip_diagonal()
    assert Perm((1, 2, 5, 0, 3, 4)).flip_diagonal() == Perm((3, 0, 1, 4, 5, 2))
    assert (
        Perm([4, 3, 1, 6, 5, 7, 8, 0, 2])
        == Perm([7, 2, 8, 1, 0, 4, 3, 5, 6]).flip_diagonal()
    )
github PermutaTriangle / Permuta / tests / patterns / test_perm.py View on Github external
def test_is_skew_decomposable():
    p1 = Perm((0, 1, 3, 2))
    p2 = Perm((0, 4, 2, 1, 3))
    p3 = Perm((2, 0, 1))
    p4 = Perm((0,))
    p5 = Perm()

    assert p1.skew_sum(p2).is_skew_decomposable()
    assert p1.skew_sum(p2, p3).is_skew_decomposable()
    assert p1.skew_sum(p2, p3, p4).is_skew_decomposable()
    assert p2.skew_sum(p3, p4).is_skew_decomposable()
    assert not p5.is_skew_decomposable()

    assert not Perm((0, 1, 2, 3, 4)).is_skew_decomposable()
    assert not Perm((0, 5, 4, 3, 2, 1)).is_skew_decomposable()
github PermutaTriangle / Permuta / tests / enumeration_strategies / test_enumeration_strategies.py View on Github external
def test_insertion_encoding():
    strat = InsertionEncodingStrategy([Perm((0, 1, 2)), Perm((2, 0, 1))])
    assert strat.applies()
    strat = InsertionEncodingStrategy([Perm((0, 2, 1, 3))])
    assert not strat.applies()
github PermutaTriangle / Permuta / tests / enumeration_strategies / test_core_strategies.py View on Github external
def test_zero_plus_perm():
    assert zero_plus_perm(Perm((0, 1, 2)))
    assert not zero_plus_perm(Perm((3, 0, 1, 2)))
github PermutaTriangle / Permuta / tests / patterns / test_perm.py View on Github external
def test_ge():
    # TODO: No length testing is done here
    for _ in range(30):
        l1 = list(range(10))
        l2 = list(range(10))
        random.shuffle(l1)
        random.shuffle(l2)
        if l1 >= l2:
            assert Perm(l1) >= Perm(l2)
        else:
            assert not (Perm(l1) >= Perm(l2))
        assert Perm(l1) >= Perm(l1)
        assert Perm(l2) >= Perm(l2)
github PermutaTriangle / Permuta / tests / perm_sets / test_av.py View on Github external
def test_generators():
    assert list(Av(Basis(Perm((0, 1)), Perm((1, 0)))).first(500)) == [
        Perm(),
        Perm((0,)),
    ]
    assert sorted(Av(Basis(Perm((0, 2, 1)), Perm((1, 2, 0)))).of_length(3)) == sorted(
        set(Perm.of_length(3)) - {Perm((0, 2, 1)), Perm((1, 2, 0))}
    )
    assert sorted(
        Av(Basis(Perm((0, 2, 1)), Perm((1, 2, 0)))).up_to_length(3)
    ) == sorted(set(Perm.up_to_length(3)) - {Perm((0, 2, 1)), Perm((1, 2, 0))})
github PermutaTriangle / Permuta / tests / bisc / test_bisc.py View on Github external
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()],