Ejemplo n.º 1
0
def test_should_leave_bounds_unchanged_if_no_need_to_crop():
    bounds = np.array([[50, 60, 50], [50, 60, 51], [50, 60, 52]])
    bounds_to_crop = bounds.copy()
    w = 100
    h = 100
    crop_bounds(bounds=bounds_to_crop, w=w, h=h)
    assert np.array_equal(bounds, bounds_to_crop)
Ejemplo n.º 2
0
def test_should_crop_when_multiple_variables_are_out_of_bounds(
        x1, x2, y, cropped_x1, cropped_x2, cropped_y):
    bounds = np.array([[x1, x2, y]])
    crop_bounds(bounds=bounds, w=100, h=100)
    assert bounds[0][
        0] == cropped_x1, f'actual x1: {bounds[0][0]}, expected x1: {cropped_x1}'
    assert bounds[0][
        1] == cropped_x2, f'actual x2: {bounds[0][1]}, expected x2: {cropped_x2}'
    assert bounds[0][
        2] == cropped_y, f'actual y: {bounds[0][2]}, expected y: {cropped_y}'
Ejemplo n.º 3
0
def test_should_crop_negative_ys_to_zeros():
    bounds = np.array([[50, 60, -1], [50, 100, 51], [50, 60, 52]])
    w = 100
    h = 100
    crop_bounds(bounds=bounds, w=w, h=h)
    assert np.all(bounds >= 0)
Ejemplo n.º 4
0
def test_should_crop_too_big_ys_to_max_height():
    bounds = np.array([[50, 60, 50], [50, 100, 51], [50, 60, 100]])
    w = 100
    h = 100
    crop_bounds(bounds=bounds, w=w, h=h)
    assert np.all(bounds < h)
Ejemplo n.º 5
0
def test_should_crop_too_big_x2s_to_max_width():
    bounds = np.array([[50, 60, 50], [50, 100, 51], [50, 60, 52]])
    w = 100
    h = 100
    crop_bounds(bounds=bounds, w=w, h=h)
    assert np.all(bounds < w)