def test_generate():
    assert set(Permutation.fpf_involutions(2)) == {Permutation(2, 1)}
    assert set(Permutation.fpf_involutions(3)) == set()
    assert set(Permutation.fpf_involutions(4)) == {
        Permutation(2, 1, 4, 3),
        Permutation(3, 4, 1, 2),
        Permutation(4, 3, 2, 1),
    }
Exemple #2
0
def test_involutions():
    assert set(Permutation.involutions(1)) == {Permutation()}
    assert set(Permutation.involutions(1, True)) == {Permutation(), Permutation(-1)}
    assert set(Permutation.involutions(2)) == {Permutation(), Permutation(2, 1)}
    assert set(Permutation.involutions(2, True)) == {
        Permutation(),
        Permutation(-1),
        Permutation(2, 1),
        Permutation(-2, -1),
        Permutation(-1, -2),
        Permutation(1, -2)
    }

    n = 6
    assert set(Permutation.involutions(n)) == {
        w for w in Permutation.all(n) if w.inverse() == w
    }
    assert set(Permutation.involutions(n, True)) == {
        w for w in Permutation.all(n, True) if w.inverse() == w
    }
    assert len(set(Permutation.involutions(n))) == len(list(Permutation.involutions(n)))

    assert set(Permutation.fpf_involutions(4)) == {
        Permutation(2, 1, 4, 3),
        Permutation(3, 4, 1, 2),
        Permutation(4, 3, 2, 1),
    }
def test_get_molecules_n(n=8):
    ans = {}
    fpf = set(Permutation.fpf_involutions(n))
    bns = get_molecules_n(n)
    for mu in bns:
        molecule = molecule_n(mu)
        fpf -= molecule
        ans[mu] = molecule
    assert len(fpf) == 0
    assert all(ans[mu] == bns[mu] for mu in bns)
def test_bidirected_edges_m(n=8):
    for w in Permutation.fpf_involutions(n):
        p, _ = rsk(w)
        for y, i in set(bidirected_edges_m(w)):
            print(w, '<--', i, '-->', y)
            q, _ = rsk(y)
            print(p)
            print(q)
            print()
            assert q == dual_equivalence(p, i)
Exemple #5
0
def test_fpf_atoms():
    y = Permutation(4, 3, 2, 1)
    s = Permutation.s_i(1)
    t = Permutation.s_i(2)
    u = Permutation.s_i(3)
    assert set(y.get_fpf_atoms()) == {t * s, t * u}

    n = 6
    for w in Permutation.fpf_involutions(n):
        atoms = set()
        for word in w.get_fpf_involution_words():
            atoms.add(Permutation.from_word(word))
        assert atoms == set(w.get_fpf_atoms())
def test_get_molecules_m(n=8):
    ans = {}
    inv = set(Permutation.fpf_involutions(n))
    while inv:
        w = inv.pop()
        mu = rsk(w)[0].shape()
        molecule = molecule_m(mu)
        inv -= molecule
        assert mu not in ans
        ans[mu] = molecule
    bns = get_molecules_m(n)
    assert all(ans[mu] == bns[mu] for mu in bns)
    assert all(representative_m(mu) in bns[mu] for mu in bns)
def get_molecules_m(n, verbose=False):
    ans = {}
    nn = double_fac(n - 1)
    for i, w in enumerate(Permutation.fpf_involutions(n)):
        mu = rsk(w)[0].shape()
        if mu not in ans:
            ans[mu] = set()
        ans[mu].add(w)

        if verbose:
            a = nn - i
            if a % 100 == 0:
                print(a)
    return ans
def test_six():
    _test(Permutation.fpf_involutions(6), 6)
def test_four():
    _test(Permutation.fpf_involutions(4), 8)
def test_three():
    _test(Permutation.fpf_involutions(3), 10)
def test_two():
    _test(Permutation.fpf_involutions(2), 8)
def test_one():
    _test(Permutation.fpf_involutions(1), 12)