diff --git a/manim/_config/utils.py b/manim/_config/utils.py index cdbd62fce4..67522906fa 100644 --- a/manim/_config/utils.py +++ b/manim/_config/utils.py @@ -1172,7 +1172,7 @@ def quality(self): 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 qual return None diff --git a/manim/camera/camera.py b/manim/camera/camera.py index 84e7060e38..d5ebdc30a1 100644 --- a/manim/camera/camera.py +++ b/manim/camera/camera.py @@ -886,8 +886,10 @@ def display_point_cloud( 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 @@ def on_screen_pixels(self, pixel_coords: np.ndarray): ], ) - 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...unsystematic big_sum = op.add(config["pixel_height"], config["pixel_width"]) @@ -1141,7 +1145,8 @@ def adjusted_thickness(self, thickness: float): return 1 + (thickness - 1) * factor def get_thickening_nudges(self, thickness: float): - """ + """Determine a list of vectors used to nudge + two-dimensional pixel coordinates. Parameters ---------- @@ -1215,13 +1220,16 @@ def get_coords_of_all_pixels(self): # 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 = camera self.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.py index 894ca3d02b..3b8e228597 100644 --- a/manim/mobject/geometry/arc.py +++ b/manim/mobject/geometry/arc.py @@ -777,7 +777,9 @@ def __init__(self, width: float = 2, height: float = 1, **kwargs): class AnnularSector(Arc): - """ + """A sector of an annulus. + + Parameters ---------- inner_radius @@ -862,7 +864,8 @@ def generate_points(self): class Sector(AnnularSector): - """ + """A sector of a circle. + Examples -------- .. manim:: ExampleSector @@ -935,7 +938,8 @@ def generate_points(self): class CubicBezier(VMobject, metaclass=ConvertToOpenGL): - """ + """A cubic Bézier curve. + Example ------- .. manim:: BezierSplineExample diff --git a/manim/mobject/graphing/probability.py b/manim/mobject/graphing/probability.py index b38027ddf1..f0e3a2c3f3 100644 --- a/manim/mobject/graphing/probability.py +++ b/manim/mobject/graphing/probability.py @@ -34,7 +34,8 @@ class SampleSpace(Rectangle): - """ + """A mobject representing a twodimensional rectangular + sampling space. Examples -------- diff --git a/manim/mobject/graphing/scale.py b/manim/mobject/graphing/scale.py index a0797f7e9c..e1f88398a1 100644 --- a/manim/mobject/graphing/scale.py +++ b/manim/mobject/graphing/scale.py @@ -14,15 +14,15 @@ 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_labels def function(self, value: float) -> float: diff --git a/manim/mobject/matrix.py b/manim/mobject/matrix.py index f8cc6b0af2..25eb9e580b 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 @@ def __init__( 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_buff self.h_buff = h_buff self.bracket_h_buff = bracket_h_buff diff --git a/manim/mobject/opengl/opengl_mobject.py b/manim/mobject/opengl/opengl_mobject.py index 25159ab23c..583dd4ef7e 100644 --- a/manim/mobject/opengl/opengl_mobject.py +++ b/manim/mobject/opengl/opengl_mobject.py @@ -2725,7 +2725,7 @@ def throw_error_if_no_points(self): 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.py index 531423be58..6f1d879ae7 100644 --- a/manim/mobject/opengl/opengl_point_cloud_mobject.py +++ b/manim/mobject/opengl/opengl_point_cloud_mobject.py @@ -162,7 +162,7 @@ def get_mobject_type_class(): 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.py index 8858a422f6..d270ec6d40 100644 --- a/manim/mobject/opengl/opengl_vectorized_mobject.py +++ b/manim/mobject/opengl/opengl_vectorized_mobject.py @@ -1676,7 +1676,7 @@ def construct(self): """ 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.py index 7e8e45fca3..04e47b6663 100644 --- a/manim/mobject/table.py +++ b/manim/mobject/table.py @@ -89,6 +89,43 @@ def construct(self): class 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 @@ def __init__( 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_labels self.col_labels = col_labels self.top_left_entry = top_left_entry diff --git a/manim/mobject/text/tex_mobject.py b/manim/mobject/text/tex_mobject.py index 7c3bc53787..b92b5459e5 100644 --- a/manim/mobject/text/tex_mobject.py +++ b/manim/mobject/text/tex_mobject.py @@ -455,7 +455,8 @@ def __init__( class BulletedList(Tex): - """ + """A bulleted list. + Examples -------- @@ -508,7 +509,8 @@ def fade_all_but(self, index_or_string, opacity=0.5): class Title(Tex): - """ + """A mobject representing an underlined title. + Examples -------- .. manim:: TitleExample diff --git a/manim/mobject/types/point_cloud_mobject.py b/manim/mobject/types/point_cloud_mobject.py index 4a6b5302ac..354dff2e59 100644 --- a/manim/mobject/types/point_cloud_mobject.py +++ b/manim/mobject/types/point_cloud_mobject.py @@ -244,7 +244,8 @@ def __init__(self, density=DEFAULT_POINT_DENSITY_2D, **kwargs): class PGroup(PMobject): - """ + """A group for several point mobjects. + Examples -------- @@ -266,7 +267,7 @@ def construct(self): """ 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 @@ def fade_to(self, color, alpha, family=True): 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 @@ def generate_points(self): class Point(PMobject): - """ + """A mobject representing a point. Examples -------- diff --git a/manim/plugins/plugins_flags.py b/manim/plugins/plugins_flags.py index 44b0dce7fc..a1487e5774 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 annotations diff --git a/manim/scene/scene.py b/manim/scene/scene.py index b7cfb1c2b3..69f0f95848 100644 --- a/manim/scene/scene.py +++ b/manim/scene/scene.py @@ -385,10 +385,8 @@ def should_update_mobjects(self) -> bool: or self.updaters or wait_animation.stop_condition is not None or 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_update diff --git a/manim/scene/three_d_scene.py b/manim/scene/three_d_scene.py index 4e619b7ffd..6f9e7a651b 100644 --- a/manim/scene/three_d_scene.py +++ b/manim/scene/three_d_scene.py @@ -329,7 +329,7 @@ def get_moving_mobjects(self, *animations: Animation): 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.mobjects return moving_mobjects diff --git a/manim/utils/iterables.py b/manim/utils/iterables.py index cc432d9e06..4b20cfe704 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.py index 350a527b3b..a9f16fde1b 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)