Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Addressed some maintenance TODOs (#2200)

Martmists4537b5048c2b
diff --git a/manim/camera/camera.py b/manim/camera/camera.py
index ceedde780..636f43d7e 100644
--- a/manim/camera/camera.py
+++ b/manim/camera/camera.py
@@ -9,7 +9,7 @@ import operator as op
import pathlib
import time
from functools import reduce
-from typing import Union
+from typing import Any, Union
import cairo
import numpy as np
@@ -461,9 +461,20 @@ class Camera:
],
)
- def capture_mobject(
- self, mobject, **kwargs
- ): # TODO Write better docstrings for this method.
+ def capture_mobject(self, mobject: Mobject, **kwargs: Any):
+ """Capture mobjects by storing it in :attr:`pixel_array`.
+
+ This is a single-mobject version of :meth:`capture_mobjects`.
+
+ Parameters
+ ----------
+ mobject
+ Mobject to capture.
+
+ kwargs
+ Keyword arguments to be passed to :meth:`get_mobjects_to_display`.
+
+ """
return self.capture_mobjects([mobject], **kwargs)
def capture_mobjects(self, mobjects, **kwargs):
diff --git a/manim/camera/mapping_camera.py b/manim/camera/mapping_camera.py
index ee23dce3e..e08b86b8a 100644
--- a/manim/camera/mapping_camera.py
+++ b/manim/camera/mapping_camera.py
@@ -2,6 +2,7 @@
__all__ = ["MappingCamera", "OldMultiCamera", "SplitScreenCamera"]
+import math
import numpy as np
@@ -30,11 +31,11 @@ class MappingCamera(Camera):
self.allow_object_intrusion = allow_object_intrusion
super().__init__(**kwargs)
- def points_to_pixel_coords(self, points):
+ def points_to_pixel_coords(self, mobject, points):
return super().points_to_pixel_coords(
+ mobject,
np.apply_along_axis(self.mapping_func, 1, points),
- ) # TODO: There is an error here, but I don't know how to fix it:
- # FIXME: Call to method Camera.points_to_pixel_coords with too few arguments; should be no fewer than 3.
+ )
def capture_mobjects(self, mobjects, **kwargs):
mobjects = self.get_mobjects_to_display(mobjects, **kwargs)
@@ -126,9 +127,8 @@ class SplitScreenCamera(OldMultiCamera):
self.left_camera = left_camera
self.right_camera = right_camera
- half_width = self.pixel_width / 2
+ half_width = math.ceil(self.pixel_width / 2)
for camera in [self.left_camera, self.right_camera]:
- # TODO: Round up on one if width is odd
camera.reset_pixel_shape(camera.pixel_height, half_width)
super().__init__(
diff --git a/tests/opengl/test_opengl_vectorized_mobject.py b/tests/opengl/test_opengl_vectorized_mobject.py
index 44f05c047..49d8e0e45 100644
--- a/tests/opengl/test_opengl_vectorized_mobject.py
+++ b/tests/opengl/test_opengl_vectorized_mobject.py
@@ -54,7 +54,7 @@ def test_vgroup_add(using_opengl_renderer):
# If only one of the added object is not an instance of OpenGLVMobject, none of them should be added
obj.add(OpenGLVMobject(), OpenGLMobject())
assert len(obj.submobjects) == 1
- with pytest.raises(Exception): # TODO change this to ValueError once #307 is merged
+ with pytest.raises(ValueError):
# a OpenGLMobject cannot contain itself
obj.add(obj)
@@ -74,7 +74,7 @@ def test_vgroup_add_dunder(using_opengl_renderer):
# If only one of the added object is not an instance of OpenGLVMobject, none of them should be added
obj += (OpenGLVMobject(), OpenGLMobject())
assert len(obj.submobjects) == 1
- with pytest.raises(Exception): # TODO change this to ValueError once #307 is merged
+ with pytest.raises(ValueError):
# a OpenGLMobject cannot contain itself
obj += obj
diff --git a/tests/test_vectorized_mobject.py b/tests/test_vectorized_mobject.py
index bfbca7425..9a60ad7b9 100644
--- a/tests/test_vectorized_mobject.py
+++ b/tests/test_vectorized_mobject.py
@@ -52,7 +52,7 @@ def test_vgroup_add():
# If only one of the added object is not an instance of VMobject, none of them should be added
obj.add(VMobject(), Mobject())
assert len(obj.submobjects) == 1
- with pytest.raises(Exception): # TODO change this to ValueError once #307 is merged
+ with pytest.raises(ValueError):
# a Mobject cannot contain itself
obj.add(obj)
@@ -72,7 +72,7 @@ def test_vgroup_add_dunder():
# If only one of the added object is not an instance of VMobject, none of them should be added
obj += (VMobject(), Mobject())
assert len(obj.submobjects) == 1
- with pytest.raises(Exception): # TODO change this to ValueError once #307 is merged
+ with pytest.raises(ValueError):
# a Mobject cannot contain itself
obj += obj