Skip to content

Commit

Permalink
Added a unittest for the interpolate function in utils/bezier.py
Browse files Browse the repository at this point in the history
  • Loading branch information
henrikmidtiby committed Jan 4, 2025
1 parent 04fe98d commit 580e027
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/module/utils/test_bezier.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
_get_subdivision_matrix,
get_quadratic_approximation_of_cubic,
get_smooth_cubic_bezier_handle_points,
interpolate,
partial_bezier_points,
split_bezier,
subdivide_bezier,
Expand Down Expand Up @@ -215,3 +216,18 @@ def test_get_quadratic_approximation_of_cubic() -> None:
]
),
)


def test_interpolate() -> None:
"""Test that :func:`interpolate` handles interpolation of both float and uint8 values."""
start = 127.0
end = 25.0
alpha = 0.2
val = interpolate(start, end, alpha)
assert np.allclose(val, 106.6000000)

start = np.array(127, dtype=np.uint8)
end = np.array(25, dtype=np.uint8)
alpha = 0.09739
val = interpolate(start, end, alpha)
assert np.allclose(val, np.array([117.06622]))

0 comments on commit 580e027

Please sign in to comment.