Skip to content

Commit 21cf999

Browse files
MqCreaplechopan050
andauthored
Fix IndexError in get_nth_subpath() and ensure it always returns a NumPy array (#4630)
* fix #3569 and #4629 * Add changes to opengl_vectorized_mobject.py --------- Co-authored-by: Francisco Manríquez Novoa <49853152+chopan050@users.noreply.github.com>
1 parent ebb230f commit 21cf999

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

manim/mobject/opengl/opengl_vectorized_mobject.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1227,7 +1227,9 @@ def align_points(self, vmobject):
12271227
def get_nth_subpath(path_list, n):
12281228
if n >= len(path_list):
12291229
# Create a null path at the very end
1230-
return [path_list[-1][-1]] * nppc
1230+
if len(path_list) == 0:
1231+
return np.tile(np.zeros(3), (nppc, 1))
1232+
return np.tile(path_list[-1][-1], (nppc, 1))
12311233
path = path_list[n]
12321234
# Check for useless points at the end of the path and remove them
12331235
# https://github.com/ManimCommunity/manim/issues/1959

manim/mobject/types/vectorized_mobject.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1785,7 +1785,9 @@ def align_points(self, vmobject: VMobject) -> Self:
17851785
def get_nth_subpath(path_list, n):
17861786
if n >= len(path_list):
17871787
# Create a null path at the very end
1788-
return [path_list[-1][-1]] * nppcc
1788+
if len(path_list) == 0:
1789+
return np.tile(np.zeros(3), (nppcc, 1))
1790+
return np.tile(path_list[-1][-1], (nppcc, 1))
17891791
path = path_list[n]
17901792
# Check for useless points at the end of the path and remove them
17911793
# https://github.com/ManimCommunity/manim/issues/1959

0 commit comments

Comments
 (0)