A community-maintained Python framework for creating mathematical animations.
Fix `IndexError` in `get_nth_subpath()` and ensure it always returns a NumPy array (#4630)
Mingqi Geng21cf9998cc7a
diff --git a/manim/mobject/opengl/opengl_vectorized_mobject.py b/manim/mobject/opengl/opengl_vectorized_mobject.pyindex 41059782f..c805ebb37 100644--- a/manim/mobject/opengl/opengl_vectorized_mobject.py+++ b/manim/mobject/opengl/opengl_vectorized_mobject.py@@ -1227,7 +1227,9 @@ class OpenGLVMobject(OpenGLMobject):def get_nth_subpath(path_list, n):if n >= len(path_list):# Create a null path at the very end- return [path_list[-1][-1]] * nppc+ if len(path_list) == 0:+ return np.tile(np.zeros(3), (nppc, 1))+ return np.tile(path_list[-1][-1], (nppc, 1))path = path_list[n]# Check for useless points at the end of the path and remove them# https://github.com/ManimCommunity/manim/issues/1959diff --git a/manim/mobject/types/vectorized_mobject.py b/manim/mobject/types/vectorized_mobject.pyindex 9aa02d05c..19cb14d59 100644--- a/manim/mobject/types/vectorized_mobject.py+++ b/manim/mobject/types/vectorized_mobject.py@@ -1785,7 +1785,9 @@ class VMobject(Mobject):def get_nth_subpath(path_list, n):if n >= len(path_list):# Create a null path at the very end- return [path_list[-1][-1]] * nppcc+ if len(path_list) == 0:+ return np.tile(np.zeros(3), (nppcc, 1))+ return np.tile(path_list[-1][-1], (nppcc, 1))path = path_list[n]# Check for useless points at the end of the path and remove them# https://github.com/ManimCommunity/manim/issues/1959