A community-maintained Python framework for creating mathematical animations.
Fix creation or animation of a zero-length `DashedLine` (#4606)
Abdelsalame34e70785814
diff --git a/manim/mobject/geometry/arc.py b/manim/mobject/geometry/arc.pyindex eef149307..d78a3622b 100644--- a/manim/mobject/geometry/arc.py+++ b/manim/mobject/geometry/arc.py@@ -241,7 +241,8 @@ class TipableVMobject(VMobject, metaclass=ConvertToOpenGL):if self.has_start_tip():result.add(self.start_tip)self.remove(self.start_tip)- self.put_start_and_end_on(start, end)+ if result.submobjects:+ self.put_start_and_end_on(start, end)return resultdef get_tips(self) -> VGroup:diff --git a/tests/module/mobject/types/vectorized_mobject/test_dashed_vmobject.py b/tests/module/mobject/types/vectorized_mobject/test_dashed_vmobject.pyindex 809c9c47f..499d017e4 100644--- a/tests/module/mobject/types/vectorized_mobject/test_dashed_vmobject.py+++ b/tests/module/mobject/types/vectorized_mobject/test_dashed_vmobject.py@@ -1,4 +1,4 @@-from manim import ORIGIN, UR, Arrow, DashedVMobject, VGroup+from manim import ORIGIN, UR, Arrow, DashedLine, DashedVMobject, VGroupfrom manim.mobject.geometry.tips import ArrowTip, StealthTip@@ -41,3 +41,19 @@ def test_dashed_arrow_with_start_tip_has_two_tips():tips = _collect_tips(dashed)assert len(tips) == 2+++def test_zero_length_dashed_line_submobjects_have_2d_points():+ """Submobjects of a zero-length DashedLine must have 2-D point arrays."""+ line = DashedLine(ORIGIN, ORIGIN)+ for sub in line.submobjects:+ assert sub.points.ndim == 2, (+ f"Expected 2-D points array, got shape {sub.points.shape}"+ )+++def test_become_nonzero_to_zero_dashed_line_does_not_crash():+ """become() from a normal DashedLine to a zero-length one should not crash."""+ normal = DashedLine(ORIGIN, 2 * UR)+ zero = DashedLine(ORIGIN, ORIGIN)+ normal.become(zero)