Skip to content

Commit 4849bdd

Browse files
committed
Fix incorrect assignment in Mobject.put_start_and_end_on
PR ManimCommunity#3718 changed the behavior of `Mobject.put_start_and_end_on` when `start == end`, however the assigment to `self.points` was incorrect. The existing code assigned the Point3D directly to `self.points`, that then becomes an array with shape `(3,)`, while instead it should really have shape `(1, 3)`. This commit fixes the incorrect code and associated test.
1 parent a21a5e5 commit 4849bdd

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

manim/mobject/mobject.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1771,7 +1771,7 @@ def put_start_and_end_on(self, start: Point3D, end: Point3D) -> Self:
17711771
curr_start, curr_end = self.get_start_and_end()
17721772
curr_vect = curr_end - curr_start
17731773
if np.all(curr_vect == 0):
1774-
self.points = start
1774+
self.points = np.array([start])
17751775
return self
17761776
target_vect = np.array(end) - np.array(start)
17771777
axis = (

tests/module/mobject/graphing/test_number_line.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import numpy as np
44

5-
from manim import DashedLine, NumberLine
5+
from manim import Line, NumberLine
66
from manim.mobject.text.numbers import Integer
77

88

@@ -126,7 +126,8 @@ def test_point_to_number():
126126

127127

128128
def test_start_and_end_at_same_point():
129-
line = DashedLine(np.zeros(3), np.zeros(3))
130-
line.put_start_and_end_on(np.zeros(3), np.array([0, 0, 0]))
129+
point = [1.0, 2.0, 3.0]
130+
line = Line(point, point)
131+
line.put_start_and_end_on(point, point)
131132

132-
np.testing.assert_array_equal(np.round(np.zeros(3), 4), np.round(line.points, 4))
133+
np.testing.assert_array_equal(np.round([point], 4), np.round(line.points, 4))

0 commit comments

Comments
 (0)