How to use the segno.encoder.mask_scores function in segno

To help you get started, we’ve selected a few segno examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github heuer / segno / tests / test_encoder.py View on Github external
def test_score_n3():
    matrix, matrix_size = make_thonky_score_matrix()
    scores = encoder.mask_scores(matrix, matrix_size)
    score = scores[2]
    # Thonky: 80
    assert 760 == score
github heuer / segno / tests / test_encoder.py View on Github external
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)
    scores = encoder.mask_scores(matrix, matrix_size)
    assert 189 == scores[0]
    assert 156 == scores[1]
    # Thonky: 200
    assert 800 == scores[2]
    # Thonky: 2, but that's impossible: Either 0 or a multiple of 10 (N4 = 10)
    assert 0 == scores[3]
    # See score 3 and 4
    assert 547 - 2 - 200 + 800 == encoder.evaluate_mask(matrix, matrix_size)
github heuer / segno / tests / test_encoder.py View on Github external
def test_thonky_pattern_4():
    # http://www.thonky.com/qr-code-tutorial/data-masking
    matrix = read_matrix('thonky_datamasking_mask-4')
    matrix_size = len(matrix)
    scores = encoder.mask_scores(matrix, matrix_size)
    assert 195 == scores[0]
    assert 138 == scores[1]
    # Thonky: 200
    assert 800 == scores[2]
    assert 0 == scores[3]
    # See score 3
    assert 533 - 200 + 800 == encoder.evaluate_mask(matrix, matrix_size)
github heuer / segno / tests / test_encoder.py View on Github external
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)
    scores = encoder.mask_scores(matrix, matrix_size)
    assert 180 == scores[0]
    assert 90 == scores[1]
    # Thonky: 80
    assert 760 == scores[2]
    assert 0 == scores[3]
    # See score 3
    assert 350 - 80 + 760 == encoder.evaluate_mask(matrix, matrix_size)
github heuer / segno / tests / test_encoder.py View on Github external
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)
    scores = encoder.mask_scores(matrix, matrix_size)
    assert 180 == scores[0]
    assert 141 == scores[1]
    # Thonky: 120
    assert 760 == scores[2]
    # Thonky: 2, but that's impossible: Either 0 or a multiple of 10 (N4 = 10)
    assert 0 == scores[3]
    assert 443 - 2 - 120 + 760 == encoder.evaluate_mask(matrix, matrix_size)
github heuer / segno / tests / test_encoder.py View on Github external
cnt = 0
        finished = False
        for i in range(len(matrix)):
            for j in range(len(matrix)):
                matrix[i][j] = 0x1
                cnt+=1
                finished = cnt == percent
                if finished:
                    break
            if finished:
                break

    matrix = make_matrix()
    fill_matrix(matrix, percent)
    matrix_size = len(matrix)
    scores = encoder.mask_scores(matrix, matrix_size)
    score = scores[3]
    assert score == score
github heuer / segno / tests / test_encoder.py View on Github external
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]))
    matrix_size = len(matrix)
    scores = encoder.mask_scores(matrix, matrix_size)
    score = scores[1]
    assert 12 == score

    matrix = (bytearray([0,0,0]), bytearray([0,0,0]), bytearray([0,0,0]))
    matrix_size = len(matrix)
    scores = encoder.mask_scores(matrix, matrix_size)
    score = scores[1]
    assert 12 == score
github heuer / segno / tests / test_encoder.py View on Github external
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)
    scores = encoder.mask_scores(matrix, matrix_size)
    assert 197 == scores[0]
    assert 123 == scores[1]
    # Thonky: 200
    assert 720 == scores[2]
    assert 0 == scores[3]
    # See score 3
    assert 520 - 200 + 720 == encoder.evaluate_mask(matrix, matrix_size)
github heuer / segno / tests / test_encoder.py View on Github external
def test_score_n1_iso():
    # For example, impose 5 penalty points on the block of “dark:dark:dark:dark:dark:dark:dark”
    # module pattern, where a series of seven consecutive modules is counted as one block
    matrix = tuple(bytearray([1] * 7) for i in range(7))
    matrix_size = len(matrix)
    scores = encoder.mask_scores(matrix, matrix_size)
    score = scores[0]
    assert 5 * 7 * 2 == score
github heuer / segno / tests / test_encoder.py View on Github external
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)
    scores = encoder.mask_scores(matrix, matrix_size)
    assert 172 == scores[0]
    assert 129 == scores[1]
    # Thonky: 120
    assert 760 == scores[2]
    assert 0 == scores[3]
    # See score 3
    assert 421 - 120 + 760 == encoder.evaluate_mask(matrix, matrix_size)