Example #1
0
def test_clamp_multiple_points_to_bounding_box():
    """test that an array of points can be clamped to the bbox"""
    points = np.array([[10, 10, 10], [0, 5, 0], [20, 0, 20]])
    bbox = np.array([[0, 25], [0, 10], [3, 25]])
    expected_points = np.array([[10, 9, 10], [0, 5, 3], [20, 0, 20]])
    clamped_points = clamp_point_to_bounding_box(points, bbox)
    np.testing.assert_array_equal(clamped_points, expected_points)
Example #2
0
def test_clamp_point_to_bounding_box(point, bounding_box, expected):
    """Test that points are correctly clamped to the limits of the data.
    Note: bounding boxes are calculated from layer extents, points are clamped
    to the range of valid indices into each dimension.

    e.g. for a shape (10,) array, data is clamped to the range (0, 9)
    """
    clamped_point = clamp_point_to_bounding_box(point, bounding_box)
    np.testing.assert_allclose(expected, clamped_point)