A community-maintained Python framework for creating mathematical animations.
Some random fix from the internet
Devin Neal435166ee5ff6
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex 4045ce5dc..036105545 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -50,7 +50,7 @@ jobs:run: |sudo apt updatesudo apt install -y ffmpeg- sudo apt-get -y install texlive texlive-latex-extra texlive-fonts-extra texlive-latex-recommended texlive-science texlive-fonts-extra tipa freeglut3-dev+ sudo apt-get -y install texlive texlive-latex-extra texlive-fonts-extra texlive-latex-recommended texlive-science texlive-fonts-extra tipa freeglut3-dev python-openglecho "$HOME/.poetry/bin" >> $GITHUB_PATH- name: Install system dependencies (MacOS)@@ -115,7 +115,7 @@ jobs:poetry install -E webgl_renderer- name: Run tests- run: poetry run pytest+ run: xvfb-run -s "-screen 0 1400x900x24" poetry run pytest- name: Run module doctestsrun: poetry run pytest --doctest-modules manimdiff --git a/manim/_config/utils.py b/manim/_config/utils.pyindex d67ca0927..c11c8bf41 100644--- a/manim/_config/utils.py+++ b/manim/_config/utils.py@@ -1065,7 +1065,6 @@ class ManimConfig(MutableMapping):if val:self["disable_caching"] = True-@propertydef use_webgl_renderer(self):"""Whether or not to use WebGL renderer."""diff --git a/manim/mobject/mobject.py b/manim/mobject/mobject.pyindex 5bb722de6..ff621d1de 100644--- a/manim/mobject/mobject.py+++ b/manim/mobject/mobject.py@@ -94,14 +94,16 @@ class Mobject(Container):return self.data["bounding_box"]def compute_bounding_box(self):- all_points = np.vstack([- self.data["points"],- *(- mob.get_bounding_box()- for mob in self.get_family()[1:]- if mob.has_points()- )- ])+ all_points = np.vstack(+ [+ self.data["points"],+ *(+ mob.get_bounding_box()+ for mob in self.get_family()[1:]+ if mob.has_points()+ ),+ ]+ )if len(all_points) == 0:return np.zeros((3, self.dim))else:@@ -656,8 +658,8 @@ class Mobject(Container):for mob in self.family_members_with_points():mob.points = mob.points.astype("float")mob.points += total_vector- if hasattr(mob, 'data') and 'points' in mob.data:- mob.data['points'] += total_vector+ if hasattr(mob, "data") and "points" in mob.data:+ mob.data["points"] += total_vectorreturn selfdef scale(self, scale_factor, **kwargs):@@ -674,7 +676,7 @@ class Mobject(Container):self.apply_points_function(lambda points: scale_factor * points,works_on_bounding_box=True,- **kwargs+ **kwargs,)return selfelse:@@ -690,8 +692,7 @@ class Mobject(Container):if config["use_opengl_renderer"]:rot_matrix_T = rotation_matrix_transpose(angle, axis)self.apply_points_function(- lambda points: np.dot(points, rot_matrix_T),- **kwargs+ lambda points: np.dot(points, rot_matrix_T), **kwargs)return selfelse:@@ -782,7 +783,9 @@ class Mobject(Container):# In place operations.# Note, much of these are now redundant with default behavior of# above methods- def apply_points_function(self, func, about_point=None, about_edge=ORIGIN, works_on_bounding_box=False):+ def apply_points_function(+ self, func, about_point=None, about_edge=ORIGIN, works_on_bounding_box=False+ ):if about_point is None and about_edge is not None:about_point = self.get_bounding_box_point(about_edge)@@ -1375,14 +1378,14 @@ class Mobject(Container):def get_start(self):self.throw_error_if_no_points()if config["use_opengl_renderer"]:- return np.array(self.data['points'][0])+ return np.array(self.data["points"][0])else:return np.array(self.points[0])def get_end(self):self.throw_error_if_no_points()if config["use_opengl_renderer"]:- return np.array(self.data['points'][-1])+ return np.array(self.data["points"][-1])else:return np.array(self.points[-1])diff --git a/manim/mobject/opengl_mobject.py b/manim/mobject/opengl_mobject.pyindex a3a69047f..18ee1cfda 100644--- a/manim/mobject/opengl_mobject.py+++ b/manim/mobject/opengl_mobject.py@@ -37,7 +37,8 @@ class OpenGLMobject:"""Mathematical Object"""- shader_dtype=[++ shader_dtype = [("point", np.float32, (3,)),]shader_folder = ""@@ -448,7 +449,11 @@ class OpenGLMobject:# Make sure any mobject or numpy array attributes are copiedfamily = self.get_family()for attr, value in list(self.__dict__.items()):- if isinstance(value, OpenGLMobject) and value in family and value is not self:+ if (+ isinstance(value, OpenGLMobject)+ and value in family+ and value is not self+ ):setattr(copy_mobject, attr, value.copy())if isinstance(value, np.ndarray):setattr(copy_mobject, attr, value.copy())@@ -1386,11 +1391,12 @@ class OpenGLMobject:def get_shader_wrapper(self):from ..renderer.shader_wrapper import ShaderWrapper+self.shader_wrapper = ShaderWrapper(vert_data=self.get_shader_data(),vert_indices=self.get_shader_vert_indices(),- uniforms = self.get_shader_uniforms(),- depth_test = self.depth_test,+ uniforms=self.get_shader_uniforms(),+ depth_test=self.depth_test,texture_paths=self.texture_paths,render_primitive=self.render_primitive,shader_folder=self.__class__.shader_folder,diff --git a/manim/mobject/types/vectorized_mobject.py b/manim/mobject/types/vectorized_mobject.pyindex d8de3a1b8..9f861b221 100644--- a/manim/mobject/types/vectorized_mobject.py+++ b/manim/mobject/types/vectorized_mobject.py@@ -60,6 +60,7 @@ class VMobject(Mobject):("stroke_width", np.float32, (1,)),("color", np.float32, (4,)),]+def __init__(self,fill_color=None,@@ -113,10 +114,8 @@ class VMobject(Mobject):self.tolerance_for_point_equality = tolerance_for_point_equalityself.n_points_per_cubic_curve = n_points_per_cubic_curve-Mobject.__init__(self, **kwargs)-def init_gl_data(self):self.needs_new_triangulation = Trueself.joint_type = "auto"@@ -549,7 +548,7 @@ class VMobject(Mobject):if config["use_opengl_renderer"]:handles = handles1anchors2 = handles2- assert(len(anchors1) == len(handles) == len(anchors2))+ assert len(anchors1) == len(handles) == len(anchors2)nppc = 3new_points = np.zeros((nppc * len(anchors1), self.dim))arrays = [anchors1, handles, anchors2]@@ -725,10 +724,12 @@ class VMobject(Mobject):if config["use_opengl_renderer"]:nppc = self.n_points_per_curvepoints = np.array(points)- self.set_anchors_and_handles(*[- interpolate(points[:-1], points[1:], a)- for a in np.linspace(0, 1, nppc)- ])+ self.set_anchors_and_handles(+ *[+ interpolate(points[:-1], points[1:], a)+ for a in np.linspace(0, 1, nppc)+ ]+ )return selfelse:nppcc = self.n_points_per_cubic_curve@@ -736,7 +737,10 @@ class VMobject(Mobject):# This will set the handles aligned with the anchors.# Id est, a bezier curve will be the segment from the two anchors such that the handles belongs to this segment.self.set_anchors_and_handles(- *[interpolate(points[:-1], points[1:], a) for a in np.linspace(0, 1, nppcc)]+ *[+ interpolate(points[:-1], points[1:], a)+ for a in np.linspace(0, 1, nppcc)+ ])return self