Skip to content

Commit d41f832

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 97efef4 commit d41f832

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
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: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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)