示例#1
0
def test_update_thread_substraction_for_loop():
    thread = 100 * np.ones(shape=(5, 5))
    nails = generate_rectangle_nail_list([0, 0], [4, 4], 4)
    target = np.array([[100, 100, 80, 100, 100], [100, 100, 90, 50, 100],
                       [100, 100, 90, 50, 100], [100, 100, 90, 100, 50],
                       [100, 100, 90, 100, 100]])
    init_distance = distance_image(thread, target)
    current_nail = [0, 2]
    distances = []
    for i in range(100):
        if current_nail is None:
            print(f'breaking at {i}')
            break
        current_nail, thread = update_thread_substraction(
            nails, current_nail, target, thread, 1, distances)
    new_distance = distance_image(thread, target)
    print(f'init_distance substraction : {init_distance}')
    print(f'new_distance substraction : {new_distance}')
    print(thread)
    assert new_distance < init_distance
示例#2
0
def test_distance_1():
    image_1 = np.array([[0, 0], [0, 0]])
    image_2 = np.array([[0, 0], [0, 0]])
    assert_float_equals(distance_image(image_1, image_2), 0)
示例#3
0
def test_distance_5():
    image_1 = np.array([[1, 0], [0, 0]])
    image_2 = np.array([[0, 2], [0, 0]])
    assert_float_equals(distance_image(image_1, image_2), math.sqrt(5))
示例#4
0
def test_distance_2():
    image_1 = np.array([[0, 0], [0, 0]])
    image_2 = np.array([[0, 1], [0, 0]])
    assert distance_image(image_1, image_2) == 1