@@ -1938,24 +1938,32 @@ 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+
19411949 # Allocate space for (upper_index-lower_index+1) Bézier curves.
19421950 self .points = np .empty ((nppc * (upper_index - lower_index + 1 ), self .dim ))
19431951 # Look at the "lower_index"-th Bezier curve and select its part from
19441952 # t=lower_residue to t=1. This is the first curve in self.points.
19451953 self .points [:nppc ] = partial_bezier_points (
1946- vmobject . points [nppc * lower_index : nppc * (lower_index + 1 )],
1954+ vmobject_points [nppc * lower_index : nppc * (lower_index + 1 )],
19471955 lower_residue ,
19481956 1 ,
19491957 )
19501958 # If there are more curves between the "lower_index"-th and the
19511959 # "upper_index"-th Béziers, add them all to self.points.
1952- self .points [nppc :- nppc ] = vmobject . points [
1960+ self .points [nppc :- nppc ] = vmobject_points [
19531961 nppc * (lower_index + 1 ) : nppc * upper_index
19541962 ]
19551963 # Look at the "upper_index"-th Bézier curve and select its part from
19561964 # t=0 to t=upper_residue. This is the last curve in self.points.
19571965 self .points [- nppc :] = partial_bezier_points (
1958- vmobject . points [nppc * upper_index : nppc * (upper_index + 1 )],
1966+ vmobject_points [nppc * upper_index : nppc * (upper_index + 1 )],
19591967 0 ,
19601968 upper_residue ,
19611969 )
0 commit comments