def test_small_example():
    s = program.binary_matrix([[1, 1, 1]])
    G = program.create_generator_matrix(2, 1)
    v = program.binary_matrix([program.get_encoding(s, G)])
    H = program.get_parity_check(2)
    syndromes = program.create_syndrome_dict(3, 2)
    res = program.decode_syndrome(v, syndromes, H)
    assert res == v[0]
def test_larger_example():
    start = program.binary_matrix([[1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0]])
    G = program.create_generator_matrix(4, 11)
    v = program.binary_matrix([program.get_encoding(start, G)])
    H = program.get_parity_check(4)
    syndromes = program.create_syndrome_dict(15, 4)
    res = program.decode_syndrome(v, syndromes, H)
    assert res == v[0]
Example #3
0
def test_for_one():
    a = program.binary_matrix([[1, 1, 1, 1]])
    G = program.create_generator_matrix(3, 4)
    assert program.get_encoding(a, G) == [1, 1, 1, 1, 1, 1, 1]
Example #4
0
def test_for_zero():
    a = program.binary_matrix([[0, 0, 0, 0]])
    G = program.create_generator_matrix(3, 4)
    assert program.get_encoding(a, G) == [0, 0, 0, 0, 0, 0, 0]
Example #5
0
def test_normal_encoding():
    a = program.binary_matrix([[1, 1, 1, 0]])
    G = program.create_generator_matrix(3, 4)
    assert program.get_encoding(a, G) == [1, 1, 1, 0, 0, 0, 0]