A community-maintained Python framework for creating mathematical animations.
Fixed errors reported by ``flake8`` (#3231)
Benjamin Hackl820bfc7bf0d4
diff --git a/manim/_config/utils.py b/manim/_config/utils.pyindex cdbd62fce..67522906f 100644--- a/manim/_config/utils.py+++ b/manim/_config/utils.py@@ -1172,7 +1172,7 @@ class ManimConfig(MutableMapping):keys = ["pixel_width", "pixel_height", "frame_rate"]q = {k: self[k] for k in keys}for qual in constants.QUALITIES:- if all([q[k] == constants.QUALITIES[qual][k] for k in keys]):+ if all(q[k] == constants.QUALITIES[qual][k] for k in keys):return qualreturn Nonediff --git a/manim/camera/camera.py b/manim/camera/camera.pyindex 84e7060e3..d5ebdc30a 100644--- a/manim/camera/camera.py+++ b/manim/camera/camera.py@@ -886,8 +886,10 @@ class Camera:thickness: float,pixel_array: np.ndarray,):- """Displays a PMobject by modifying the Pixel array suitably..+ """Displays a PMobject by modifying the pixel array suitably.+TODO: Write a description for the rgbas argument.+Parameters----------pmobject@@ -1122,17 +1124,19 @@ class Camera:],)- def adjusted_thickness(self, thickness: float):- """+ def adjusted_thickness(self, thickness: float) -> float:+ """Computes the adjusted stroke width for a zoomed camera.Parameters----------thickness+ The stroke width of a mobject.Returns-------float-+ The adjusted stroke width that reflects zooming in with+ the camera."""# TODO: This seems...unsystematicbig_sum = op.add(config["pixel_height"], config["pixel_width"])@@ -1141,7 +1145,8 @@ class Camera:return 1 + (thickness - 1) * factordef get_thickening_nudges(self, thickness: float):- """+ """Determine a list of vectors used to nudge+ two-dimensional pixel coordinates.Parameters----------@@ -1215,13 +1220,16 @@ class Camera:# NOTE: The methods of the following class have not been mentioned outside of their definitions.# Their DocStrings are not as detailed as preferred.class BackgroundColoredVMobjectDisplayer:+ """Auxiliary class that handles displaying vectorized mobjects with+ a set background image.++ Parameters+ ----------+ camera+ Camera object to use.+ """+def __init__(self, camera: Camera):- """- Parameters- ----------- camera- Camera object to use.- """self.camera = cameraself.file_name_to_pixel_array_map = {}self.pixel_array = np.array(camera.pixel_array)diff --git a/manim/mobject/geometry/arc.py b/manim/mobject/geometry/arc.pyindex 894ca3d02..3b8e22859 100644--- a/manim/mobject/geometry/arc.py+++ b/manim/mobject/geometry/arc.py@@ -777,7 +777,9 @@ class Ellipse(Circle):class AnnularSector(Arc):- """+ """A sector of an annulus.++Parameters----------inner_radius@@ -862,7 +864,8 @@ class AnnularSector(Arc):class Sector(AnnularSector):- """+ """A sector of a circle.+Examples--------.. manim:: ExampleSector@@ -935,7 +938,8 @@ class Annulus(Circle):class CubicBezier(VMobject, metaclass=ConvertToOpenGL):- """+ """A cubic Bézier curve.+Example-------.. manim:: BezierSplineExamplediff --git a/manim/mobject/graphing/probability.py b/manim/mobject/graphing/probability.pyindex b38027ddf..f0e3a2c3f 100644--- a/manim/mobject/graphing/probability.py+++ b/manim/mobject/graphing/probability.py@@ -34,7 +34,8 @@ EPSILON = 0.0001class SampleSpace(Rectangle):- """+ """A mobject representing a twodimensional rectangular+ sampling space.Examples--------diff --git a/manim/mobject/graphing/scale.py b/manim/mobject/graphing/scale.pyindex a0797f7e9..e1f88398a 100644--- a/manim/mobject/graphing/scale.py+++ b/manim/mobject/graphing/scale.py@@ -14,15 +14,15 @@ if TYPE_CHECKING:class _ScaleBase:- """Scale baseclass for graphing/functions."""+ """Scale baseclass for graphing/functions.++ Parameters+ ----------+ custom_labels+ Whether to create custom labels when plotted on a :class:`~.NumberLine`.+ """def __init__(self, custom_labels: bool = False):- """- Parameters- ----------- custom_labels- Whether to create custom labels when plotted on a :class:`~.NumberLine`.- """self.custom_labels = custom_labelsdef function(self, value: float) -> float:diff --git a/manim/mobject/matrix.py b/manim/mobject/matrix.pyindex f8cc6b0af..25eb9e580 100644--- a/manim/mobject/matrix.py+++ b/manim/mobject/matrix.py@@ -74,6 +74,39 @@ def matrix_to_mobject(matrix):class Matrix(VMobject, metaclass=ConvertToOpenGL):"""A mobject that displays a matrix on the screen.+ Parameters+ ----------+ matrix+ A numpy 2d array or list of lists.+ v_buff+ Vertical distance between elements, by default 0.8.+ h_buff+ Horizontal distance between elements, by default 1.3.+ bracket_h_buff+ Distance of the brackets from the matrix, by default ``MED_SMALL_BUFF``.+ bracket_v_buff+ Height of the brackets, by default ``MED_SMALL_BUFF``.+ add_background_rectangles_to_entries+ ``True`` if should add backgraound rectangles to entries, by default ``False``.+ include_background_rectangle+ ``True`` if should include background rectangle, by default ``False``.+ element_to_mobject+ The mobject class used to construct the elements, by default :class:`~.MathTex`.+ element_to_mobject_config+ Additional arguments to be passed to the constructor in ``element_to_mobject``,+ by default ``{}``.+ element_alignment_corner+ The corner to which elements are aligned, by default ``DR``.+ left_bracket+ The left bracket type, by default ``"["``.+ right_bracket+ The right bracket type, by default ``"]"``.+ stretch_brackets+ ``True`` if should stretch the brackets to fit the height of matrix contents, by default ``True``.+ bracket_config+ Additional arguments to be passed to :class:`~.MathTex` when constructing+ the brackets.+Examples--------The first example shows a variety of uses of this module while the second example@@ -146,43 +179,6 @@ class Matrix(VMobject, metaclass=ConvertToOpenGL):bracket_config: dict = {},**kwargs,):- """-- Parameters- ----------- matrix- A numpy 2d array or list of lists.- v_buff- Vertical distance between elements, by default 0.8.- h_buff- Horizontal distance between elements, by default 1.3.- bracket_h_buff- Distance of the brackets from the matrix, by default ``MED_SMALL_BUFF``.- bracket_v_buff- Height of the brackets, by default ``MED_SMALL_BUFF``.- add_background_rectangles_to_entries- ``True`` if should add backgraound rectangles to entries, by default ``False``.- include_background_rectangle- ``True`` if should include background rectangle, by default ``False``.- element_to_mobject- The mobject class used to construct the elements, by default :class:`~.MathTex`.- element_to_mobject_config- Additional arguments to be passed to the constructor in ``element_to_mobject``,- by default ``{}``.- element_alignment_corner- The corner to which elements are aligned, by default ``DR``.- left_bracket- The left bracket type, by default ``"["``.- right_bracket- The right bracket type, by default ``"]"``.- stretch_brackets- ``True`` if should stretch the brackets to fit the height of matrix contents, by default ``True``.- bracket_config- Additional arguments to be passed to :class:`~.MathTex` when constructing- the brackets.-- """-self.v_buff = v_buffself.h_buff = h_buffself.bracket_h_buff = bracket_h_buffdiff --git a/manim/mobject/opengl/opengl_mobject.py b/manim/mobject/opengl/opengl_mobject.pyindex 25159ab23..583dd4ef7 100644--- a/manim/mobject/opengl/opengl_mobject.py+++ b/manim/mobject/opengl/opengl_mobject.py@@ -2725,7 +2725,7 @@ class OpenGLMobject:class OpenGLGroup(OpenGLMobject):def __init__(self, *mobjects, **kwargs):- if not all([isinstance(m, OpenGLMobject) for m in mobjects]):+ if not all(isinstance(m, OpenGLMobject) for m in mobjects):raise Exception("All submobjects must be of type OpenGLMobject")super().__init__(**kwargs)self.add(*mobjects)diff --git a/manim/mobject/opengl/opengl_point_cloud_mobject.py b/manim/mobject/opengl/opengl_point_cloud_mobject.pyindex 531423be5..6f1d879ae 100644--- a/manim/mobject/opengl/opengl_point_cloud_mobject.py+++ b/manim/mobject/opengl/opengl_point_cloud_mobject.py@@ -162,7 +162,7 @@ class OpenGLPMobject(OpenGLMobject):class OpenGLPGroup(OpenGLPMobject):def __init__(self, *pmobs, **kwargs):- if not all([isinstance(m, OpenGLPMobject) for m in pmobs]):+ if not all(isinstance(m, OpenGLPMobject) for m in pmobs):raise Exception("All submobjects must be of type OpenglPMObject")super().__init__(**kwargs)self.add(*pmobs)diff --git a/manim/mobject/opengl/opengl_vectorized_mobject.py b/manim/mobject/opengl/opengl_vectorized_mobject.pyindex 8858a422f..d270ec6d4 100644--- a/manim/mobject/opengl/opengl_vectorized_mobject.py+++ b/manim/mobject/opengl/opengl_vectorized_mobject.py@@ -1676,7 +1676,7 @@ class OpenGLVGroup(OpenGLVMobject):"""def __init__(self, *vmobjects, **kwargs):- if not all([isinstance(m, OpenGLVMobject) for m in vmobjects]):+ if not all(isinstance(m, OpenGLVMobject) for m in vmobjects):raise Exception("All submobjects must be of type OpenGLVMobject")super().__init__(**kwargs)self.add(*vmobjects)diff --git a/manim/mobject/table.py b/manim/mobject/table.pyindex 7e8e45fca..04e47b666 100644--- a/manim/mobject/table.py+++ b/manim/mobject/table.py@@ -89,6 +89,43 @@ from .utils import get_vectorized_mobject_classclass Table(VGroup):"""A mobject that displays a table on the screen.+ Parameters+ ----------+ table+ A 2D array or list of lists. Content of the table has to be a valid input+ for the callable set in ``element_to_mobject``.+ row_labels+ List of :class:`~.VMobject` representing the labels of each row.+ col_labels+ List of :class:`~.VMobject` representing the labels of each column.+ top_left_entry+ The top-left entry of the table, can only be specified if row and+ column labels are given.+ v_buff+ Vertical buffer passed to :meth:`~.Mobject.arrange_in_grid`, by default 0.8.+ h_buff+ Horizontal buffer passed to :meth:`~.Mobject.arrange_in_grid`, by default 1.3.+ include_outer_lines+ ``True`` if the table should include outer lines, by default False.+ add_background_rectangles_to_entries+ ``True`` if background rectangles should be added to entries, by default ``False``.+ entries_background_color+ Background color of entries if ``add_background_rectangles_to_entries`` is ``True``.+ include_background_rectangle+ ``True`` if the table should have a background rectangle, by default ``False``.+ background_rectangle_color+ Background color of table if ``include_background_rectangle`` is ``True``.+ element_to_mobject+ The :class:`~.Mobject` class applied to the table entries. by default :class:`~.Paragraph`. For common choices, see :mod:`~.text_mobject`/:mod:`~.tex_mobject`.+ element_to_mobject_config+ Custom configuration passed to :attr:`element_to_mobject`, by default {}.+ arrange_in_grid_config+ Dict passed to :meth:`~.Mobject.arrange_in_grid`, customizes the arrangement of the table.+ line_config+ Dict passed to :class:`~.Line`, customizes the lines of the table.+ kwargs+ Additional arguments to be passed to :class:`~.VGroup`.+Examples--------@@ -172,45 +209,6 @@ class Table(VGroup):line_config: dict = {},**kwargs,):- """- Parameters- ----------- table- A 2D array or list of lists. Content of the table has to be a valid input- for the callable set in ``element_to_mobject``.- row_labels- List of :class:`~.VMobject` representing the labels of each row.- col_labels- List of :class:`~.VMobject` representing the labels of each column.- top_left_entry- The top-left entry of the table, can only be specified if row and- column labels are given.- v_buff- Vertical buffer passed to :meth:`~.Mobject.arrange_in_grid`, by default 0.8.- h_buff- Horizontal buffer passed to :meth:`~.Mobject.arrange_in_grid`, by default 1.3.- include_outer_lines- ``True`` if the table should include outer lines, by default False.- add_background_rectangles_to_entries- ``True`` if background rectangles should be added to entries, by default ``False``.- entries_background_color- Background color of entries if ``add_background_rectangles_to_entries`` is ``True``.- include_background_rectangle- ``True`` if the table should have a background rectangle, by default ``False``.- background_rectangle_color- Background color of table if ``include_background_rectangle`` is ``True``.- element_to_mobject- The :class:`~.Mobject` class applied to the table entries. by default :class:`~.Paragraph`. For common choices, see :mod:`~.text_mobject`/:mod:`~.tex_mobject`.- element_to_mobject_config- Custom configuration passed to :attr:`element_to_mobject`, by default {}.- arrange_in_grid_config- Dict passed to :meth:`~.Mobject.arrange_in_grid`, customizes the arrangement of the table.- line_config- Dict passed to :class:`~.Line`, customizes the lines of the table.- kwargs- Additional arguments to be passed to :class:`~.VGroup`.- """-self.row_labels = row_labelsself.col_labels = col_labelsself.top_left_entry = top_left_entrydiff --git a/manim/mobject/text/tex_mobject.py b/manim/mobject/text/tex_mobject.pyindex 7c3bc5378..b92b5459e 100644--- a/manim/mobject/text/tex_mobject.py+++ b/manim/mobject/text/tex_mobject.py@@ -455,7 +455,8 @@ class Tex(MathTex):class BulletedList(Tex):- """+ """A bulleted list.+Examples--------@@ -508,7 +509,8 @@ class BulletedList(Tex):class Title(Tex):- """+ """A mobject representing an underlined title.+Examples--------.. manim:: TitleExamplediff --git a/manim/mobject/types/point_cloud_mobject.py b/manim/mobject/types/point_cloud_mobject.pyindex 4a6b5302a..354dff2e5 100644--- a/manim/mobject/types/point_cloud_mobject.py+++ b/manim/mobject/types/point_cloud_mobject.py@@ -244,7 +244,8 @@ class Mobject2D(PMobject, metaclass=ConvertToOpenGL):class PGroup(PMobject):- """+ """A group for several point mobjects.+Examples--------@@ -266,7 +267,7 @@ class PGroup(PMobject):"""def __init__(self, *pmobs, **kwargs):- if not all([isinstance(m, (PMobject, OpenGLPMobject)) for m in pmobs]):+ if not all(isinstance(m, (PMobject, OpenGLPMobject)) for m in pmobs):raise ValueError("All submobjects must be of type PMobject or OpenGLPMObject"" if using the opengl renderer",@@ -281,7 +282,8 @@ class PGroup(PMobject):class PointCloudDot(Mobject1D):- """A disc made of a cloud of Dots+ """A disc made of a cloud of dots.+Examples--------.. manim:: PointCloudDotExample@@ -347,7 +349,7 @@ class PointCloudDot(Mobject1D):class Point(PMobject):- """+ """A mobject representing a point.Examples--------diff --git a/manim/plugins/plugins_flags.py b/manim/plugins/plugins_flags.pyindex 44b0dce7f..a1487e577 100644--- a/manim/plugins/plugins_flags.py+++ b/manim/plugins/plugins_flags.py@@ -1,9 +1,4 @@-"""-plugins_flags.py---------------Plugin Managing Utility.-"""+"""Plugin Managing Utility"""from __future__ import annotationsdiff --git a/manim/scene/scene.py b/manim/scene/scene.pyindex b7cfb1c2b..69f0f9584 100644--- a/manim/scene/scene.py+++ b/manim/scene/scene.py@@ -385,10 +385,8 @@ class Scene:or self.updatersor wait_animation.stop_condition is not Noneor any(- [- mob.has_time_based_updater()- for mob in self.get_mobject_family_members()- ],+ mob.has_time_based_updater()+ for mob in self.get_mobject_family_members()))wait_animation.is_static_wait = not should_updatediff --git a/manim/scene/three_d_scene.py b/manim/scene/three_d_scene.pyindex 4e619b7ff..6f9e7a651 100644--- a/manim/scene/three_d_scene.py+++ b/manim/scene/three_d_scene.py@@ -329,7 +329,7 @@ class ThreeDScene(Scene):camera_mobjects = self.renderer.camera.get_value_trackers() + [self.renderer.camera._frame_center,]- if any([cm in moving_mobjects for cm in camera_mobjects]):+ if any(cm in moving_mobjects for cm in camera_mobjects):return self.mobjectsreturn moving_mobjectsdiff --git a/manim/utils/iterables.py b/manim/utils/iterables.pyindex cc432d9e0..4b20cfe70 100644--- a/manim/utils/iterables.py+++ b/manim/utils/iterables.py@@ -65,7 +65,7 @@ def all_elements_are_instances(iterable: Iterable, Class) -> bool:"""Returns ``True`` if all elements of iterable are instances of Class.False otherwise."""- return all([isinstance(e, Class) for e in iterable])+ return all(isinstance(e, Class) for e in iterable)def batch_by_property(diff --git a/tests/module/mobject/text/test_numbers.py b/tests/module/mobject/text/test_numbers.pyindex 350a527b3..a9f16fde1 100644--- a/tests/module/mobject/text/test_numbers.py+++ b/tests/module/mobject/text/test_numbers.py@@ -44,4 +44,4 @@ def test_color_when_number_of_digits_changes():the number of digits changes."""mob = Integer(color=RED)mob.set_value(42)- assert all([submob.stroke_color == Color(RED) for submob in mob.submobjects])+ assert all(submob.stroke_color == Color(RED) for submob in mob.submobjects)