Ejemplo n.º 1
0
def test_autploop(n_cases):
    for i in range(n_cases):
        autp = AutPL('r', 'r')
        g = group(autp)
        assert g ==  group([('d', autp.cocode), ('p',  autp.perm)])
        assert g ==  group('p',  autp)
        coc, p_num = autp.cocode, autp.perm_num
        if coc and p_num:
            assert g.as_tuples() == autp.as_tuples() 
            assert g.as_tuples() == [('d', coc), ('p', p_num)] 
        Coc = Cocode(coc)
        h1 = range(9, 18)
        h2 = autp.perm[9:18]
        assert g ==  group([('d', Coc), ('p',  zip(h1, h2))])    
        assert g ==  group([('d', Coc), ('p',  dict(zip(h1, h2)))])    
Ejemplo n.º 2
0
def test_group_from_perm(n_cases):
    for i in range(n_cases):
        h1 = rand_u7()
        h2 = rand_u7()
        autp = AutPL(0, zip(h1, h2))
        assert autp == AutPL(0, dict(zip(h1, h2)))
        assert autp.perm == mat24.perm_from_heptads(h1, h2)
        assert autp.cocode == 0
        perm_num = autp.perm_num
        assert perm_num == mat24.perm_to_m24num(autp.perm)
        assert autp == AutPL(0, mat24.perm_from_heptads(h1, h2))
        assert autp == AutPL(autp)
        assert autp == AutPL(0, autp.perm_num)
        assert autp == AutPL(0, zip(h1, h2))
        coc_num = randint(1, 0xfff)
        coc = Cocode(coc_num)
        assert coc != Cocode(0)
        assert coc.cocode == coc_num
        im_coc = coc * autp
        assert type(im_coc) == type(coc)
        assert AutPL(im_coc) == AutPL(coc)**autp
        aut_cp = AutPL(coc) * autp
        assert aut_cp == AutPL(coc_num, perm_num)
        if coc_num and perm_num:
            assert aut_cp.as_tuples() == [('d', coc_num), ('p', perm_num)]
        assert autp * AutPL(im_coc) == aut_cp
        assert type(aut_cp) == type(autp)
        assert aut_cp.perm_num == perm_num
        assert aut_cp.cocode == coc_num
        assert Parity(aut_cp) == Parity(coc)
        assert aut_cp.parity == coc.parity == Parity(coc).ord
        assert autp == AutPL() * autp == autp * AutPL()
        with pytest.raises(TypeError):
            autp * coc
        with pytest.raises(TypeError):
            autp * Parity(randint(0, 9))
        with pytest.raises(TypeError):
            autp * randint(2, 9)
        with pytest.raises(TypeError):
            randint(2, 9) * autp
        with pytest.raises(TypeError):
            autp * PLoop(randint(0, 0x1fff))