Example #1
0
def test_score_n2_iso():
    # Take a block consisting of 3 x 3 dark
    # modules for an example. Considering that up to four 2 x 2 dark modules can
    # be included in this block, the penalty applied to this block shall be
    # calculated as 4 (blocks) x 3 (points) = 12 points.
    matrix = (bytearray([1,1,1]), bytearray([1,1,1]), bytearray([1,1,1]))
    score = encoder.score_n2(matrix, len(matrix))
    assert 12 == score

    matrix = (bytearray([0,0,0]), bytearray([0,0,0]), bytearray([0,0,0]))
    score = encoder.score_n2(matrix, len(matrix))
    assert 12 == score
Example #2
0
def test_score_n2_iso():
    # Take a block consisting of 3 x 3 dark
    # modules for an example. Considering that up to four 2 x 2 dark modules can
    # be included in this block, the penalty applied to this block shall be
    # calculated as 4 (blocks) x 3 (points) = 12 points.
    matrix = (bytearray([1,1,1]), bytearray([1,1,1]), bytearray([1,1,1]))
    score = encoder.score_n2(matrix, len(matrix))
    assert 12 == score

    matrix = (bytearray([0,0,0]), bytearray([0,0,0]), bytearray([0,0,0]))
    score = encoder.score_n2(matrix, len(matrix))
    assert 12 == score
Example #3
0
def test_thonky_pattern_2():
    # http://www.thonky.com/qr-code-tutorial/data-masking
    matrix = read_matrix('thonky_datamasking_mask-2')
    matrix_size = len(matrix)
    assert 206 == encoder.score_n1(matrix, matrix_size)
    assert 141 == encoder.score_n2(matrix, matrix_size)
    # Thonky: 160
    assert 800 == encoder.score_n3(matrix, matrix_size)
    assert 0 == encoder.score_n4(matrix, matrix_size)
    assert 507 - 160 + 800 == encoder.evaluate_mask(matrix, matrix_size)
Example #4
0
def test_thonky_pattern_2():
    # http://www.thonky.com/qr-code-tutorial/data-masking
    matrix = read_matrix('thonky_datamasking_mask-2')
    matrix_size = len(matrix)
    assert 206 == encoder.score_n1(matrix, matrix_size)
    assert 141 == encoder.score_n2(matrix, matrix_size)
    # Thonky: 160
    assert 800 == encoder.score_n3(matrix, matrix_size)
    assert 0 == encoder.score_n4(matrix, matrix_size)
    assert 507 - 160 + 800 == encoder.evaluate_mask(matrix, matrix_size)
Example #5
0
def test_thonky_pattern_3():
    # http://www.thonky.com/qr-code-tutorial/data-masking
    matrix = read_matrix('thonky_datamasking_mask-3')
    matrix_size = len(matrix)
    assert 180 == encoder.score_n1(matrix, matrix_size)
    assert 141 == encoder.score_n2(matrix, matrix_size)
    # Thonky: 120
    assert 760 == encoder.score_n3(matrix, matrix_size)
    # Thonky: 2, but that's impossible: Either 0 or a multiple of 10 (N4 = 10)
    assert 0 == encoder.score_n4(matrix, matrix_size)
    assert 443 - 2 - 120 + 760 == encoder.evaluate_mask(matrix, matrix_size)
Example #6
0
def test_thonky_pattern_1():
    # http://www.thonky.com/qr-code-tutorial/data-masking
    matrix = read_matrix('thonky_datamasking_mask-1')
    matrix_size = len(matrix)
    assert 172 == encoder.score_n1(matrix, matrix_size)
    assert 129 == encoder.score_n2(matrix, matrix_size)
    # Thonky: 120
    assert 760 == encoder.score_n3(matrix, matrix_size)
    assert 0 == encoder.score_n4(matrix, matrix_size)
    # See score 3
    assert 421 - 120 + 760 == encoder.evaluate_mask(matrix, matrix_size)
Example #7
0
def test_thonky_pattern_0():
    # http://www.thonky.com/qr-code-tutorial/data-masking
    matrix = read_matrix('thonky_datamasking_mask-0')
    matrix_size = len(matrix)
    assert 180 == encoder.score_n1(matrix, matrix_size)
    assert 90 == encoder.score_n2(matrix, matrix_size)
    # Thonky: 80
    assert 760 == encoder.score_n3(matrix, matrix_size)
    assert 0 == encoder.score_n4(matrix, matrix_size)
    # See score 3
    assert 350 - 80 + 760 == encoder.evaluate_mask(matrix, matrix_size)
Example #8
0
def test_thonky_pattern_0():
    # http://www.thonky.com/qr-code-tutorial/data-masking
    matrix = read_matrix('thonky_datamasking_mask-0')
    matrix_size = len(matrix)
    assert 180 == encoder.score_n1(matrix, matrix_size)
    assert 90 == encoder.score_n2(matrix, matrix_size)
    # Thonky: 80
    assert 760 == encoder.score_n3(matrix, matrix_size)
    assert 0 == encoder.score_n4(matrix, matrix_size)
    # See score 3
    assert 350 - 80 + 760 == encoder.evaluate_mask(matrix, matrix_size)
Example #9
0
def test_thonky_pattern_7():
    # http://www.thonky.com/qr-code-tutorial/data-masking
    matrix = read_matrix('thonky_datamasking_mask-7')
    matrix_size = len(matrix)
    assert 197 == encoder.score_n1(matrix, matrix_size)
    assert 123 == encoder.score_n2(matrix, matrix_size)
    # Thonky: 200
    assert 720 == encoder.score_n3(matrix, matrix_size)
    assert 0 == encoder.score_n4(matrix, matrix_size)
    # See score 3
    assert 520 - 200 + 720 == encoder.evaluate_mask(matrix, matrix_size)
Example #10
0
def test_thonky_pattern_3():
    # http://www.thonky.com/qr-code-tutorial/data-masking
    matrix = read_matrix('thonky_datamasking_mask-3')
    matrix_size = len(matrix)
    assert 180 == encoder.score_n1(matrix, matrix_size)
    assert 141 == encoder.score_n2(matrix, matrix_size)
    # Thonky: 120
    assert 760 == encoder.score_n3(matrix, matrix_size)
    # Thonky: 2, but that's impossible: Either 0 or a multiple of 10 (N4 = 10)
    assert 0 == encoder.score_n4(matrix, matrix_size)
    assert 443 - 2 - 120 + 760 == encoder.evaluate_mask(matrix, matrix_size)
Example #11
0
def test_thonky_pattern_1():
    # http://www.thonky.com/qr-code-tutorial/data-masking
    matrix = read_matrix('thonky_datamasking_mask-1')
    matrix_size = len(matrix)
    assert 172 == encoder.score_n1(matrix, matrix_size)
    assert 129 == encoder.score_n2(matrix, matrix_size)
    # Thonky: 120
    assert 760 == encoder.score_n3(matrix, matrix_size)
    assert 0 == encoder.score_n4(matrix, matrix_size)
    # See score 3
    assert 421 - 120 + 760 == encoder.evaluate_mask(matrix, matrix_size)
Example #12
0
def test_thonky_pattern_7():
    # http://www.thonky.com/qr-code-tutorial/data-masking
    matrix = read_matrix('thonky_datamasking_mask-7')
    matrix_size = len(matrix)
    assert 197 == encoder.score_n1(matrix, matrix_size)
    assert 123 == encoder.score_n2(matrix, matrix_size)
    # Thonky: 200
    assert 720 == encoder.score_n3(matrix, matrix_size)
    assert 0 == encoder.score_n4(matrix, matrix_size)
    # See score 3
    assert 520 - 200 + 720 == encoder.evaluate_mask(matrix, matrix_size)
Example #13
0
def test_thonky_pattern_6():
    # http://www.thonky.com/qr-code-tutorial/data-masking
    matrix = read_matrix('thonky_datamasking_mask-6')
    matrix_size = len(matrix)
    assert 171 == encoder.score_n1(matrix, matrix_size)
    assert 102 == encoder.score_n2(matrix, matrix_size)
    # Thonky: 80
    assert 840 == encoder.score_n3(matrix, matrix_size)
    # Thonky: 4, but that's impossible: Either 0 or a multiple of 10 (N4 = 10)
    assert 0 == encoder.score_n4(matrix, matrix_size)
    # See score 3 and 4
    assert 357 - 4 - 80 + 840 == encoder.evaluate_mask(matrix, matrix_size)
Example #14
0
def test_thonky_pattern_5():
    # http://www.thonky.com/qr-code-tutorial/data-masking
    matrix = read_matrix('thonky_datamasking_mask-5')
    matrix_size = len(matrix)
    assert 189 == encoder.score_n1(matrix, matrix_size)
    assert 156 == encoder.score_n2(matrix, matrix_size)
    # Thonky: 200
    assert 800 == encoder.score_n3(matrix, matrix_size)
    # Thonky: 2, but that's impossible: Either 0 or a multiple of 10 (N4 = 10)
    assert 0 == encoder.score_n4(matrix, matrix_size)
    # See score 3 and 4
    assert 547 - 2 - 200 + 800 == encoder.evaluate_mask(matrix, matrix_size)
Example #15
0
def test_thonky_pattern_6():
    # http://www.thonky.com/qr-code-tutorial/data-masking
    matrix = read_matrix('thonky_datamasking_mask-6')
    matrix_size = len(matrix)
    assert 171 == encoder.score_n1(matrix, matrix_size)
    assert 102 == encoder.score_n2(matrix, matrix_size)
    # Thonky: 80
    assert 840 == encoder.score_n3(matrix, matrix_size)
    # Thonky: 4, but that's impossible: Either 0 or a multiple of 10 (N4 = 10)
    assert 0 == encoder.score_n4(matrix, matrix_size)
    # See score 3 and 4
    assert 357 - 4 - 80 + 840 == encoder.evaluate_mask(matrix, matrix_size)
Example #16
0
def test_thonky_pattern_5():
    # http://www.thonky.com/qr-code-tutorial/data-masking
    matrix = read_matrix('thonky_datamasking_mask-5')
    matrix_size = len(matrix)
    assert 189 == encoder.score_n1(matrix, matrix_size)
    assert 156 == encoder.score_n2(matrix, matrix_size)
    # Thonky: 200
    assert 800 == encoder.score_n3(matrix, matrix_size)
    # Thonky: 2, but that's impossible: Either 0 or a multiple of 10 (N4 = 10)
    assert 0 == encoder.score_n4(matrix, matrix_size)
    # See score 3 and 4
    assert 547 - 2 - 200 + 800 == encoder.evaluate_mask(matrix, matrix_size)
Example #17
0
def test_score_n2():
    matrix, matrix_size = make_thonky_score_matrix()
    score = encoder.score_n2(matrix, matrix_size)
    assert 90 == score
Example #18
0
def test_score_n2():
    matrix, matrix_size = make_thonky_score_matrix()
    score = encoder.score_n2(matrix, matrix_size)
    assert 90 == score