Skip to content

Commit

Permalink
Add test_vmobject_add_points_as_corners()
Browse files Browse the repository at this point in the history
  • Loading branch information
chopan050 committed Jan 5, 2025
1 parent e996c62 commit eba5b09
Showing 1 changed file with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,37 @@ def test_vmobject_add():
assert len(obj.submobjects) == 1


def test_vmobject_add_points_as_corners():
points = np.array(
[
[2, 0, 0],
[1, 1, 0],
[-1, 1, 0],
[-2, 0, 0],
[-1, -1, 0],
[1, -1, 0],
[2, 0, 0],
]
)

# Test that add_points_as_corners(points) is equivalent to calling
# add_line_to(point) for every point in points.
obj1 = VMobject().start_new_path(points[0]).add_points_as_corners(points[1:])
obj2 = VMobject().start_new_path(points[0])
for point in points[1:]:
obj2.add_line_to(point)
assert np.allclose(obj1.points, obj2.points)

# Test that passing an array with no points does nothing.
obj3 = VMobject().start_new_path(points[0])
points3_old = obj3.points.copy()
obj3.add_points_as_corners([])
assert np.allclose(points3_old, obj3.points)

obj3.add_points_as_corners(points[1:]).add_points_as_corners([])
assert np.allclose(obj1.points, obj3.points)


def test_vmobject_point_from_proportion():
obj = VMobject()

Expand Down

0 comments on commit eba5b09

Please sign in to comment.