Skip to content

Commit 7b2c803

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)`. PR ManimCommunity#4027 added a comment that this should be fixed, but did not fix the issue. The comment is now superfluous. This commit fixes the incorrect code and associated test.
1 parent 7879fe4 commit 7b2c803

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

manim/mobject/mobject.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1776,10 +1776,7 @@ def put_start_and_end_on(self, start: Point3DLike, end: Point3DLike) -> Self:
17761776
curr_start, curr_end = self.get_start_and_end()
17771777
curr_vect = curr_end - curr_start
17781778
if np.all(curr_vect == 0):
1779-
# TODO: this looks broken. It makes self.points a Point3D instead
1780-
# of a Point3D_Array. However, modifying this breaks some tests
1781-
# where this is currently expected.
1782-
self.points = np.array(start)
1779+
self.points = np.array([start])
17831780
return self
17841781
target_vect = np.asarray(end) - np.asarray(start)
17851782
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)