Пример #1
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]
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]
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
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
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
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