コード例 #1
0
def test_prod_exceptions():
    with pytest.raises(ValueError):
        a = galois.Poly.Random(5)
        b = galois.Poly.Random(4, field=galois.GF(3))
        c = galois.Poly.Random(3)
        galois.prod(a, b, c)
コード例 #2
0
def test_outer_exceptions():
    with pytest.raises(TypeError):
        a = galois.GF(2**4).Random(5)
        b = galois.GF(2**5).Random(5)
        np.outer(a, b)
コード例 #3
0
def construct_field(folder):
    if len(folder.split("-")) >= 2:
        folder, ufunc_mode = folder.split("-", maxsplit=1)
    else:
        ufunc_mode = "auto"

    if folder == "GF(2)":
        GF = galois.GF2

    elif folder == "GF(5)":
        GF = galois.GF(5, compile=ufunc_mode)
    elif folder == "GF(7)":
        GF = galois.GF(7, compile=ufunc_mode)
    elif folder == "GF(31)":
        GF = galois.GF(31, compile=ufunc_mode)
    elif folder == "GF(3191)":
        GF = galois.GF(3191, compile=ufunc_mode)
    elif folder == "GF(2147483647)":
        GF = galois.GF(2147483647, compile=ufunc_mode)
    elif folder == "GF(36893488147419103183)":
        GF = galois.GF(36893488147419103183, compile=ufunc_mode)

    elif folder == "GF(2^2)":
        GF = galois.GF(2**2, compile=ufunc_mode)
    elif folder == "GF(2^3)":
        GF = galois.GF(2**3, compile=ufunc_mode)
    elif folder == "GF(2^8)":
        GF = galois.GF(2**8, compile=ufunc_mode)
    elif folder == "GF(2^8, 283, 19)":
        GF = galois.GF(2**8,
                       irreducible_poly=283,
                       primitive_element=19,
                       compile=ufunc_mode)
    elif folder == "GF(2^32)":
        GF = galois.GF(2**32, compile=ufunc_mode)
    elif folder == "GF(2^100)":
        GF = galois.GF(2**100, compile=ufunc_mode)

    elif folder == "GF(7^3)":
        GF = galois.GF(7**3, compile=ufunc_mode)
    elif folder == "GF(7^3, 643, 244)":
        GF = galois.GF(7**3,
                       irreducible_poly=643,
                       primitive_element=244,
                       compile=ufunc_mode)
    elif folder == "GF(109987^4)":
        GF = galois.GF(109987**4, compile=ufunc_mode)

    else:
        raise AssertionError(f"Test data folder {folder} not found")

    return GF, ufunc_mode, os.path.join(PATH, folder)