Exemple #1
0
def check_constructors(coll):
    ReportGuard(False)
    # default constructor
    S = FroidurePin(coll[0])
    S.add_generators(coll[1:])

    # copy constructor
    U = FroidurePin(S)
    assert S is not U
    assert S.number_of_generators() == U.number_of_generators()
    assert S.current_size() == U.current_size()
Exemple #2
0
def check_froidure_pin_transf1(T):
    ReportGuard(False)
    if T is Transf16:
        add = list(range(8, 16))
    else:
        add = []

    S = FroidurePin(T.make([1, 7, 2, 6, 0, 4, 1, 5] + add))

    S.add_generator(T.make([2, 4, 6, 1, 4, 5, 2, 7] + add))
    S.add_generator(T.make([3, 0, 7, 2, 4, 6, 2, 4] + add))
    S.add_generator(T.make([3, 2, 3, 4, 5, 3, 0, 1] + add))
    S.add_generator(T.make([4, 3, 7, 7, 4, 5, 0, 4] + add))
    S.add_generator(T.make([5, 6, 3, 0, 3, 0, 5, 1] + add))
    S.add_generator(T.make([6, 0, 1, 1, 1, 6, 3, 4] + add))
    S.add_generator(T.make([7, 7, 4, 0, 6, 4, 1, 7] + add))
    S.reserve(600000)

    assert S.number_of_generators() == 8
    assert S.current_size() == 8
    assert S.current_number_of_rules() == 0
    S.enumerate(100)
    assert S.current_size() == 8200
    assert S.current_number_of_rules() == 1049

    if T == Transf16:
        assert S.degree() == 16
    else:
        assert S.degree() == 8
Exemple #3
0
def check_generators(coll):
    ReportGuard(False)
    S = FroidurePin(coll[0])
    S.add_generators(coll[1:])
    for i, x in enumerate(coll):
        assert S.generator(i) == x

    with pytest.raises(RuntimeError):
        S.generator(len(coll))

    U = FroidurePin(coll[0])
    for x in coll[1:]:
        U.add_generator(x)
    assert S.number_of_generators() == U.number_of_generators()
    assert S.size() == U.size()

    S.closure(coll)
    assert S.number_of_generators() == len(coll)

    U = S.copy_closure(coll)
    assert U.number_of_generators() == S.number_of_generators()
    assert U.size() == S.size()
    assert U is not S

    U = S.copy_add_generators(coll)
    assert U.number_of_generators() == 2 * S.number_of_generators()
    assert U.size() == S.size()
    assert U is not S