Skip to content

Commit e34e707

Browse files
Fix creation or animation of a zero-length DashedLine (#4606)
* fixing #4591 * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 7c1c925 commit e34e707

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

manim/mobject/geometry/arc.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,8 @@ def pop_tips(self) -> VGroup:
241241
if self.has_start_tip():
242242
result.add(self.start_tip)
243243
self.remove(self.start_tip)
244-
self.put_start_and_end_on(start, end)
244+
if result.submobjects:
245+
self.put_start_and_end_on(start, end)
245246
return result
246247

247248
def get_tips(self) -> VGroup:

tests/module/mobject/types/vectorized_mobject/test_dashed_vmobject.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from manim import ORIGIN, UR, Arrow, DashedVMobject, VGroup
1+
from manim import ORIGIN, UR, Arrow, DashedLine, DashedVMobject, VGroup
22
from manim.mobject.geometry.tips import ArrowTip, StealthTip
33

44

@@ -41,3 +41,19 @@ def test_dashed_arrow_with_start_tip_has_two_tips():
4141
tips = _collect_tips(dashed)
4242

4343
assert len(tips) == 2
44+
45+
46+
def test_zero_length_dashed_line_submobjects_have_2d_points():
47+
"""Submobjects of a zero-length DashedLine must have 2-D point arrays."""
48+
line = DashedLine(ORIGIN, ORIGIN)
49+
for sub in line.submobjects:
50+
assert sub.points.ndim == 2, (
51+
f"Expected 2-D points array, got shape {sub.points.shape}"
52+
)
53+
54+
55+
def test_become_nonzero_to_zero_dashed_line_does_not_crash():
56+
"""become() from a normal DashedLine to a zero-length one should not crash."""
57+
normal = DashedLine(ORIGIN, 2 * UR)
58+
zero = DashedLine(ORIGIN, ORIGIN)
59+
normal.become(zero)

0 commit comments

Comments
 (0)