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]
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]
Beispiel #3
0
def test_example():
    """ From Lecture 7 - 01 """
    v = program.binary_matrix([[1, 1, 0, 0, 0, 0, 0]])
    H = program.get_parity_check(3)
    syndromes = program.create_syndrome_dict(7, 3)
    vH = program.calculate_syndrome(v, H)
    assert vH == [0, 1, 1]
def test_example():
    """ Example from Lecture 7 - 01 """
    v = program.binary_matrix([[1, 1, 0, 0, 0, 0, 0]])
    H = program.get_parity_check(3)
    syndromes = program.create_syndrome_dict(7, 3)
    res = program.decode_syndrome(v, syndromes, H)
    assert res == [1, 1, 1, 0, 0, 0, 0]
Beispiel #5
0
def test_binary_matrix():
    """
    Ensures that the create_binary_list method is actually returning a binary
    matrix and not a regular list
    """
    assert (type(program.create_binary_matrix([1, 2])) == type(
        program.binary_matrix([1, 2])))
Beispiel #6
0
def test_binary_matrix_for_non_lists():
    """
    Tests the binary_list type for single integers.
    Should raise an error.
    """
    with pytest.raises(TypeError):
        assert (type(program.create_binary_matrix(1)) == type(
            program.binary_matrix(1)))
Beispiel #7
0
def test_larger_span_creation():
    assert program.span_from_identity(3) == program.binary_matrix([
                                                                [1,1,0],
                                                                [1,0,1],
                                                                [0,1,1],
                                                                [1,1,1],
                                                                [1,0,0],
                                                                [0,1,0],
                                                                [0,0,1]
                                                                ])
Beispiel #8
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]
def test_interleave_for_multiple():
    a = program.binary_matrix([[0,0,0,0,0,0,0],[1,1,1,1,1,1,1]])
    a_T = program.interleave(a)
    assert a_T == [[0,1],[0,1],[0,1],[0,1],[0,1],[0,1],[0,1]]
def test_interleave_for_one():
    a = program.binary_matrix([[0,0,0,0,0,0,0]])
    a_T = program.interleave(a)
    assert a_T == [[0],[0],[0],[0],[0],[0],[0]]
Beispiel #11
0
def test_binary_matrix_for_small_values():
    """
    Tests the binary_list type for single integers
    """
    assert (type(program.create_binary_matrix([1])) == type(
        program.binary_matrix([1])))
def test_ones():
    a = program.binary_matrix([[1, 1, 1, 1, 1, 1, 1]])
    H = program.get_parity_check(3)
    assert program.do_parity_check(a, H) == True
Beispiel #13
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]
def test_normal():
    a = program.binary_matrix([[1, 1, 1, 0, 0, 0, 0]])
    H = program.get_parity_check(3)
    assert program.do_parity_check(a, H) == True
Beispiel #15
0
def test_type():
    """ Ensure types returned are correct """
    assert (
        type(program.identity(3)) ==
        type(program.binary_matrix([1]))
        )
Beispiel #16
0
def test_i_1():
    """ Ensure I_1 is just [1] """
    assert program.identity(1) == program.binary_matrix([[1]])
Beispiel #17
0
def test_i_0():
    """ Ensure I_0 is the empty matrix"""
    assert program.identity(0) == program.binary_matrix()
def test_failure():
    a = program.binary_matrix([[0, 1, 1, 1, 0, 1, 1]])
    H = program.get_parity_check(3)
    assert program.do_parity_check(a, H) == False
Beispiel #19
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]
def test_zeros():
    a = program.binary_matrix([[0, 0, 0, 0, 0, 0, 0]])
    H = program.get_parity_check(3)
    assert program.do_parity_check(a, H) == True