Skip to content

Commit efb532d

Browse files
committed
change self to self.copy() in Line, and remove the previous change in pointwise_become_partial()
1 parent 5e36c42 commit efb532d

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

manim/mobject/geometry/line.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def _account_for_buff(self, buff: float) -> None:
133133
if length < 2 * buff:
134134
return
135135
buff_proportion = buff / length
136-
self.pointwise_become_partial(self, buff_proportion, 1 - buff_proportion)
136+
self.pointwise_become_partial(self.copy(), buff_proportion, 1 - buff_proportion)
137137
return
138138

139139
def _set_start_and_end_attrs(

manim/mobject/types/vectorized_mobject.py

+3-11
Original file line numberDiff line numberDiff line change
@@ -1938,32 +1938,24 @@ def pointwise_become_partial(
19381938
upper_residue,
19391939
)
19401940
else:
1941-
# Copy points if self.points is vmobject.points before setting
1942-
# self.points = np.empty(...) to avoid in-place modification
1943-
vmobject_points = (
1944-
vmobject.points.copy()
1945-
if self.points is vmobject.points
1946-
else vmobject.points
1947-
)
1948-
19491941
# Allocate space for (upper_index-lower_index+1) Bézier curves.
19501942
self.points = np.empty((nppc * (upper_index - lower_index + 1), self.dim))
19511943
# Look at the "lower_index"-th Bezier curve and select its part from
19521944
# t=lower_residue to t=1. This is the first curve in self.points.
19531945
self.points[:nppc] = partial_bezier_points(
1954-
vmobject_points[nppc * lower_index : nppc * (lower_index + 1)],
1946+
vmobject.points[nppc * lower_index : nppc * (lower_index + 1)],
19551947
lower_residue,
19561948
1,
19571949
)
19581950
# If there are more curves between the "lower_index"-th and the
19591951
# "upper_index"-th Béziers, add them all to self.points.
1960-
self.points[nppc:-nppc] = vmobject_points[
1952+
self.points[nppc:-nppc] = vmobject.points[
19611953
nppc * (lower_index + 1) : nppc * upper_index
19621954
]
19631955
# Look at the "upper_index"-th Bézier curve and select its part from
19641956
# t=0 to t=upper_residue. This is the last curve in self.points.
19651957
self.points[-nppc:] = partial_bezier_points(
1966-
vmobject_points[nppc * upper_index : nppc * (upper_index + 1)],
1958+
vmobject.points[nppc * upper_index : nppc * (upper_index + 1)],
19671959
0,
19681960
upper_residue,
19691961
)

0 commit comments

Comments
 (0)