instruction
stringclasses
100 values
code
stringlengths
78
193k
response
stringlengths
259
170k
file
stringlengths
59
203
Document functions with detailed explanations
from __future__ import annotations import cloup from manim.constants import CONTEXT_SETTINGS, EPILOG from manim.plugins.plugins_flags import list_plugins __all__ = ["plugins"] @cloup.command( context_settings=CONTEXT_SETTINGS, no_args_is_help=True, epilog=EPILOG, help="Manages Manim plugins.", ) @...
--- +++ @@ -1,3 +1,10 @@+"""Manim's plugin subcommand. + +Manim's plugin subcommand is accessed in the command-line interface via ``manim +plugin``. Here you can specify options, subcommands, and subgroups for the plugin +group. + +""" from __future__ import annotations @@ -23,5 +30,15 @@ help="List available ...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/cli/plugins/commands.py
Add docstrings to existing functions
from __future__ import annotations from collections.abc import Iterable from dataclasses import dataclass from types import MethodType from typing import Any @dataclass class MethodWithArgs: __slots__ = ["method", "args", "kwargs"] method: MethodType args: Iterable[Any] kwargs: dict[str, Any]
--- +++ @@ -1,3 +1,4 @@+"""Data classes and other necessary data structures for use in Manim.""" from __future__ import annotations @@ -9,9 +10,22 @@ @dataclass class MethodWithArgs: + """Object containing a :attr:`method` which is intended to be called later + with the positional arguments :attr:`args` a...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/data_structures.py
Add docstrings explaining edge cases
from __future__ import annotations import inspect import types from collections.abc import Callable from typing import TYPE_CHECKING from numpy import piecewise from ..animation.animation import Animation, Wait, prepare_animation from ..animation.composition import AnimationGroup from ..mobject.mobject import Mobje...
--- +++ @@ -1,3 +1,4 @@+"""Utilities for modifying the speed at which animations are played.""" from __future__ import annotations @@ -20,6 +21,75 @@ class ChangeSpeed(Animation): + """Modifies the speed of passed animation. + :class:`AnimationGroup` with different ``lag_ratio`` can also be used + whi...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/animation/speedmodifier.py
Write docstrings for this repository
from __future__ import annotations import click import cloup from manim import __version__ from manim._config import cli_ctx_settings, console from manim.cli.cfg.group import cfg from manim.cli.checkhealth.commands import checkhealth from manim.cli.default_group import DefaultGroup from manim.cli.init.commands import...
--- +++ @@ -15,6 +15,18 @@ def show_splash(ctx: click.Context, param: click.Option, value: str | None) -> None: + """When giving a value by console, show an initial message with the Manim + version before executing any other command: ``Manim Community vA.B.C``. + + Parameters + ---------- + ctx + ...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/__main__.py
Add detailed documentation for each class
from __future__ import annotations __all__ = [ "Create", "Uncreate", "DrawBorderThenFill", "Write", "Unwrite", "ShowPartial", "ShowIncreasingSubsets", "SpiralIn", "AddTextLetterByLetter", "RemoveTextLetterByLetter", "ShowSubmobjectsOneByOne", "AddTextWordByWord", "T...
--- +++ @@ -1,3 +1,59 @@+r"""Animate the display or removal of a mobject from a scene. + +.. manim:: CreationModule + :hide_source: + + from manim import ManimBanner + class CreationModule(Scene): + def construct(self): + s1 = Square() + s2 = Square() + s3 = Square() + ...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/animation/creation.py
Provide clean and structured docstrings
from __future__ import annotations __all__ = [ "assert_is_mobject_method", "always", "f_always", "always_redraw", "always_shift", "always_rotate", "turn_animation_into_updater", "cycle_animation", ] import inspect from collections.abc import Callable from typing import TYPE_CHECKING ...
--- +++ @@ -1,3 +1,4 @@+"""Utility functions for continuous animation of mobjects.""" from __future__ import annotations @@ -43,6 +44,11 @@ def f_always(method: Callable[[Mobject], None], *arg_generators, **kwargs) -> Mobject: + """ + More functional version of always, where instead + of taking in arg...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/animation/updaters/mobject_update_utils.py
Provide clean and structured docstrings
from __future__ import annotations import configparser from pathlib import Path from typing import Any import click import cloup from manim._config import console from manim.constants import CONTEXT_SETTINGS, EPILOG, QUALITIES from manim.utils.file_ops import ( add_import_statement, copy_template_files, ...
--- +++ @@ -1,3 +1,10 @@+"""Manim's init subcommand. + +Manim's init subcommand is accessed in the command-line interface via ``manim +init``. Here you can specify options, subcommands, and subgroups for the init +group. + +""" from __future__ import annotations @@ -29,6 +36,13 @@ def select_resolution() -> tu...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/cli/init/commands.py
Add docstrings for internal functions
from __future__ import annotations import http.client import json import sys import urllib.error import urllib.request from argparse import Namespace from pathlib import Path from typing import Any, cast import cloup from manim import __version__ from manim._config import ( config, console, error_consol...
--- +++ @@ -1,3 +1,10 @@+"""Manim's default subcommand, render. + +Manim's render subcommand is accessed in the command-line interface via +``manim``, but can be more explicitly accessed with ``manim render``. Here you +can specify options, and arguments for the render command. + +""" from __future__ import annotati...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/cli/render/commands.py
Write docstrings for utility functions
from __future__ import annotations from typing import TYPE_CHECKING, Any import numpy as np from pathops import Path as SkiaPath from pathops import PathVerb, difference, intersection, union, xor from manim import config from manim.mobject.opengl.opengl_compatibility import ConvertToOpenGL from manim.mobject.types....
--- +++ @@ -1,3 +1,4 @@+"""Boolean operations for two-dimensional mobjects.""" from __future__ import annotations @@ -20,12 +21,39 @@ class _BooleanOps(VMobject, metaclass=ConvertToOpenGL): + """This class contains some helper functions which + helps to convert to and from skia objects and manim + obj...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/mobject/geometry/boolean_ops.py
Create Google-style docstrings for my code
from __future__ import annotations __all__ = ["MultiCamera"] from collections.abc import Iterable from typing import Any, Self from manim.mobject.mobject import Mobject from manim.mobject.types.image_mobject import ImageMobjectFromCamera from ..camera.moving_camera import MovingCamera from ..utils.iterables impor...
--- +++ @@ -1,3 +1,4 @@+"""A camera supporting multiple perspectives.""" from __future__ import annotations @@ -15,6 +16,7 @@ class MultiCamera(MovingCamera): + """Camera Object that allows for multiple perspectives.""" def __init__( self, @@ -22,6 +24,15 @@ allow_cameras_to_capture_...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/camera/multi_camera.py
Add docstrings that explain inputs and outputs
from __future__ import annotations __all__ = ["ThreeDCamera"] from collections.abc import Callable, Iterable from typing import Any import numpy as np from manim.mobject.mobject import Mobject from manim.mobject.three_d.three_d_utils import ( get_3d_vmob_end_corner, get_3d_vmob_end_corner_unit_normal, ...
--- +++ @@ -1,3 +1,4 @@+"""A camera that can be positioned and oriented in three-dimensional space.""" from __future__ import annotations @@ -50,6 +51,13 @@ zoom: float = 1, **kwargs: Any, ): + """Initializes the ThreeDCamera + + Parameters + ---------- + *kwargs +...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/camera/three_d_camera.py
Generate docstrings for this script
from __future__ import annotations __all__ = [ "Line", "DashedLine", "TangentLine", "Elbow", "Arrow", "Vector", "DoubleArrow", "Angle", "RightAngle", ] from typing import TYPE_CHECKING, Any, Literal, cast import numpy as np from manim import config from manim.constants import * ...
--- +++ @@ -1,3 +1,4 @@+r"""Mobjects that are lines or variations of them.""" from __future__ import annotations @@ -62,6 +63,34 @@ class Line(TipableVMobject): + """A straight or curved line segment between two points or mobjects. + + Parameters + ---------- + start + The starting point or ...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/mobject/geometry/line.py
Write docstrings describing each step
from __future__ import annotations from manim.mobject.opengl.opengl_mobject import OpenGLMobject from .. import config, logger from ..constants import RendererType from ..mobject import mobject from ..mobject.mobject import Group, Mobject from ..mobject.opengl import opengl_mobject from ..utils.rate_functions import...
--- +++ @@ -1,3 +1,4 @@+"""Animate mobjects.""" from __future__ import annotations @@ -27,6 +28,83 @@ class Animation: + """An animation. + + Animations have a fixed time span. + + Parameters + ---------- + mobject + The mobject to be animated. This is not required for all types of animat...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/animation/animation.py
Add docstrings to existing functions
from __future__ import annotations import os import shutil from collections.abc import Callable from typing import Protocol, cast __all__ = ["HEALTH_CHECKS"] class HealthCheckFunction(Protocol): description: str recommendation: str skip_on_failed: list[str] post_fail_fix_hook: Callable[..., object]...
--- +++ @@ -1,3 +1,6 @@+"""Auxiliary module for the checkhealth subcommand, contains +the actual check implementations. +""" from __future__ import annotations @@ -28,6 +31,32 @@ skip_on_failed: list[HealthCheckFunction | str] | None = None, post_fail_fix_hook: Callable[..., object] | None = None, ) -> C...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/cli/checkhealth/checks.py
Add docstrings to improve readability
from __future__ import annotations __all__ = ["Rotating", "Rotate"] from collections.abc import Callable from typing import TYPE_CHECKING, Any from ..animation.animation import Animation from ..animation.transform import Transform from ..constants import OUT, PI, TAU from ..utils.rate_functions import linear if TY...
--- +++ @@ -1,3 +1,4 @@+"""Animations related to rotation.""" from __future__ import annotations @@ -18,6 +19,71 @@ class Rotating(Animation): + """Animation that rotates a Mobject. + + Parameters + ---------- + mobject + The mobject to be rotated. + angle + The rotation angle in r...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/animation/rotation.py
Generate docstrings for each module
from __future__ import annotations import warnings from collections.abc import Callable from typing import TYPE_CHECKING, Any import cloup from manim.utils.deprecation import deprecated __all__ = ["DefaultGroup"] if TYPE_CHECKING: from click import Command, Context class DefaultGroup(cloup.Group): def ...
--- +++ @@ -1,3 +1,14 @@+"""``DefaultGroup`` allows a subcommand to act as the main command. + +In particular, this class is what allows ``manim`` to act as ``manim render``. + +.. note:: + This is a vendored version of https://github.com/click-contrib/click-default-group/ + under the BSD 3-Clause "New" or "Revis...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/cli/default_group.py
Add well-formatted docstrings
from __future__ import annotations __all__ = ["ChangingDecimal", "ChangeDecimalToValue"] from collections.abc import Callable from typing import Any from manim.mobject.text.numbers import DecimalNumber from ..animation.animation import Animation from ..utils.bezier import interpolate class ChangingDecimal(Anima...
--- +++ @@ -1,3 +1,4 @@+"""Animations for changing numbers.""" from __future__ import annotations @@ -14,6 +15,40 @@ class ChangingDecimal(Animation): + """Animate a :class:`~.DecimalNumber` to values specified by a user-supplied function. + + Parameters + ---------- + decimal_mob + The :cla...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/animation/numbers.py
Document all public functions with docstrings
from __future__ import annotations __all__ = ["MovingCamera"] from collections.abc import Iterable from typing import Any, Literal, overload from cairo import Context from manim.typing import PixelArray, Point3D, Point3DLike from .. import config from ..camera.camera import Camera from ..constants import DOWN, LE...
--- +++ @@ -1,3 +1,9 @@+"""Defines the MovingCamera class, a camera that can pan and zoom through a scene. + +.. SEEALSO:: + + :mod:`.moving_camera_scene` +""" from __future__ import annotations @@ -19,6 +25,14 @@ class MovingCamera(Camera): + """A camera that follows and matches the size and position of...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/camera/moving_camera.py
Write proper docstrings for these functions
from __future__ import annotations __all__ = [ "FocusOn", "Indicate", "Flash", "ShowPassingFlash", "ShowPassingFlashWithThinningStrokeWidth", "ApplyWave", "Circumscribe", "Wiggle", "Blink", ] from collections.abc import Iterable from typing import Any, Self import numpy as np fr...
--- +++ @@ -1,3 +1,29 @@+"""Animations drawing attention to particular mobjects. + +Examples +-------- + +.. manim:: Indications + + class Indications(Scene): + def construct(self): + indications = [ApplyWave,Circumscribe,Flash,FocusOn,Indicate,ShowPassingFlash,Wiggle] + names = [Tex(i._...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/animation/indication.py
Create documentation strings for testing functions
from __future__ import annotations import contextlib from ast import literal_eval from pathlib import Path from typing import Any, cast import cloup from rich.errors import StyleSyntaxError from rich.style import Style from manim._config import cli_ctx_settings, console from manim._config.utils import config_file_p...
--- +++ @@ -1,3 +1,10 @@+"""Manim's cfg subcommand. + +Manim's cfg subcommand is accessed in the command-line interface via ``manim +cfg``. Here you can specify options, subcommands, and subgroups for the cfg +group. + +""" from __future__ import annotations @@ -35,6 +42,18 @@ def value_from_string(value: str)...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/cli/cfg/group.py
Document all endpoints with docstrings
from __future__ import annotations __all__ = [ "CoordinateSystem", "Axes", "ThreeDAxes", "NumberPlane", "PolarPlane", "ComplexPlane", ] import fractions as fr import numbers from collections.abc import Callable, Iterable, Sequence from typing import TYPE_CHECKING, Any, Self, TypeVar, overload...
--- +++ @@ -1,3 +1,4 @@+"""Mobjects that represent coordinate systems.""" from __future__ import annotations @@ -69,6 +70,54 @@ class CoordinateSystem: + r"""Abstract base class for Axes and NumberPlane. + + Examples + -------- + .. manim:: CoordSysExample + :save_last_frame: + + clas...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/mobject/graphing/coordinate_systems.py
Add docstrings for production code
from __future__ import annotations __all__ = [ "Graph", "DiGraph", ] import itertools as it from collections.abc import Hashable, Iterable, Sequence from copy import copy from typing import TYPE_CHECKING, Any, Literal, Protocol, cast import networkx as nx import numpy as np if TYPE_CHECKING: from typin...
--- +++ @@ -1,3 +1,4 @@+"""Mobjects used to represent mathematical graphs (think graph theory, not plotting).""" from __future__ import annotations @@ -35,6 +36,226 @@ class LayoutFunction(Protocol): + """A protocol for automatic layout functions that compute a layout for a graph to be used in :meth:`~.Grap...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/mobject/graph.py
Provide docstrings following PEP 257
from __future__ import annotations __all__ = [ "Transform", "ReplacementTransform", "TransformFromCopy", "ClockwiseTransform", "CounterclockwiseTransform", "MoveToTarget", "ApplyMethod", "ApplyPointwiseFunction", "ApplyPointwiseFunctionToCenter", "FadeToColor", "FadeTransfo...
--- +++ @@ -1,3 +1,4 @@+"""Animations transforming one mobject into another.""" from __future__ import annotations @@ -54,6 +55,81 @@ class Transform(Animation): + """A Transform transforms a Mobject into a target Mobject. + + Parameters + ---------- + mobject + The :class:`.Mobject` to be t...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/animation/transform.py
Improve my code by adding docstrings
from __future__ import annotations import logging import re import sys from typing import TYPE_CHECKING from cloup import Choice, option, option_group from manim.constants import QUALITIES, RendererType if TYPE_CHECKING: from click import Context, Option __all__ = ["render_options"] logger = logging.getLogger...
--- +++ @@ -20,6 +20,31 @@ def validate_scene_range( ctx: Context, param: Option, value: str | None ) -> tuple[int] | tuple[int, int] | None: + """If the ``value`` string is given, extract from it the scene range, which + should be in any of these formats: 'start', 'start;end', 'start,end' or + 'start-en...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/cli/render/render_options.py
Add clean documentation to messy code
from __future__ import annotations __all__ = ["Label", "LabeledLine", "LabeledArrow", "LabeledPolygram"] from typing import TYPE_CHECKING, Any import numpy as np from manim.constants import * from manim.mobject.geometry.line import Arrow, Line from manim.mobject.geometry.polygram import Polygram from manim.mobject...
--- +++ @@ -1,3 +1,4 @@+r"""Mobjects that inherit from lines and contain a label along the length.""" from __future__ import annotations @@ -25,6 +26,38 @@ class Label(VGroup): + """A Label consisting of text surrounded by a frame. + + Parameters + ---------- + label + Label that will be dis...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/mobject/geometry/labeled.py
Can you add docstrings to this Python file?
from __future__ import annotations import argparse import configparser import copy import errno import logging import os import re import sys from collections.abc import Iterator, Mapping, MutableMapping from pathlib import Path from typing import TYPE_CHECKING, Any, ClassVar, NoReturn import numpy as np from manim...
--- +++ @@ -1,3 +1,14 @@+"""Utilities to create and set the config. + +The main class exported by this module is :class:`ManimConfig`. This class +contains all configuration options, including frame geometry (e.g. frame +height/width, frame rate), output (e.g. directories, logging), styling +(e.g. background color, tr...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/_config/utils.py
Add documentation for all methods
from __future__ import annotations __all__ = ["ParametricFunction", "FunctionGraph", "ImplicitFunction"] from collections.abc import Callable, Iterable, Sequence from typing import TYPE_CHECKING import numpy as np from isosurfaces import plot_isoline from manim import config from manim.mobject.graphing.scale impo...
--- +++ @@ -1,3 +1,4 @@+"""Mobjects representing function graphs.""" from __future__ import annotations @@ -25,6 +26,82 @@ class ParametricFunction(VMobject, metaclass=ConvertToOpenGL): + """A parametric curve. + + Parameters + ---------- + function + The function to be plotted in the form o...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/mobject/graphing/functions.py
Add docstrings to improve collaboration
from __future__ import annotations __all__ = ["Camera", "BackgroundColoredVMobjectDisplayer"] import copy import itertools as it import operator as op import pathlib from collections.abc import Callable, Iterable from functools import reduce from typing import TYPE_CHECKING, Any, Self import cairo import numpy as n...
--- +++ @@ -1,3 +1,4 @@+"""A camera converts the mobjects contained in a Scene into an array of pixels.""" from __future__ import annotations @@ -58,6 +59,26 @@ class Camera: + """Base camera class. + + This is the object which takes care of what exactly is displayed + on screen at any given moment. +...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/camera/camera.py
Document functions with detailed explanations
from __future__ import annotations import configparser import copy import json import logging from typing import TYPE_CHECKING, Any from rich import color, errors from rich import print as printf from rich.console import Console from rich.logging import RichHandler from rich.theme import Theme if TYPE_CHECKING: ...
--- +++ @@ -1,3 +1,14 @@+"""Utilities to create and set the logger. + +Manim's logger can be accessed as ``manim.logger``, or as +``logging.getLogger("manim")``, once the library has been imported. Manim also +exports a second object, ``console``, which should be used to print on screen +messages that need not be logg...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/_config/logger_utils.py
Generate docstrings with examples
from __future__ import annotations from manim.utils.color import BLACK, ParsableManimColor __all__ = [ "SingleStringMathTex", "MathTex", "Tex", "BulletedList", "Title", ] import operator as op import re from collections.abc import Iterable from functools import reduce from textwrap import deden...
--- +++ @@ -1,3 +1,14 @@+r"""Mobjects representing text rendered using LaTeX. + +.. important:: + + See the corresponding tutorial :ref:`rendering-with-latex` + +.. note:: + + Just as you can use :class:`~.Text` (from the module :mod:`~.text_mobject`) to add text to your videos, you can use :class:`~.Tex` and :clas...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/mobject/text/tex_mobject.py
Create documentation strings for testing functions
from __future__ import annotations __all__ = [ "Homotopy", "SmoothedVectorizedHomotopy", "ComplexHomotopy", "PhaseFlow", "MoveAlongPath", ] from collections.abc import Callable from typing import TYPE_CHECKING, Any import numpy as np from ..animation.animation import Animation from ..utils.rate...
--- +++ @@ -1,3 +1,4 @@+"""Animations related to movement.""" from __future__ import annotations @@ -28,6 +29,49 @@ class Homotopy(Animation): + """A Homotopy. + + This is an animation transforming the points of a mobject according + to the specified transformation function. With the parameter :math:`...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/animation/movement.py
Help me add docstrings to my project
from __future__ import annotations __all__ = ["MappingCamera", "OldMultiCamera", "SplitScreenCamera"] import math import numpy as np from ..camera.camera import Camera from ..mobject.types.vectorized_mobject import VMobject from ..utils.config_ops import DictAsObject # TODO: Add an attribute to mobjects under whi...
--- +++ @@ -1,3 +1,4 @@+"""A camera module that supports spatial mapping between objects for distortion effects.""" from __future__ import annotations @@ -16,6 +17,17 @@ class MappingCamera(Camera): + """Parameters + ---------- + mapping_func : callable + Function to map 3D points to new 3D poi...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/camera/mapping_camera.py
Generate docstrings for exported functions
from __future__ import annotations __all__ = [ "Polygram", "Polygon", "RegularPolygram", "RegularPolygon", "Star", "Triangle", "Rectangle", "Square", "RoundedRectangle", "Cutout", "ConvexHull", ] from math import ceil from typing import TYPE_CHECKING, Any, Literal import...
--- +++ @@ -1,3 +1,4 @@+r"""Mobjects that are simple geometric shapes.""" from __future__ import annotations @@ -45,6 +46,39 @@ class Polygram(VMobject, metaclass=ConvertToOpenGL): + """A generalized :class:`Polygon`, allowing for disconnected sets of edges. + + Parameters + ---------- + vertex_gro...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/mobject/geometry/polygram.py
Generate helpful docstrings for debugging
from __future__ import annotations __all__ = [ "TipableVMobject", "Arc", "ArcBetweenPoints", "CurvedArrow", "CurvedDoubleArrow", "Circle", "Dot", "AnnotationDot", "LabeledDot", "Ellipse", "AnnularSector", "Sector", "Annulus", "CubicBezier", "ArcPolygon", ...
--- +++ @@ -1,3 +1,25 @@+r"""Mobjects that are curved. + +Examples +-------- +.. manim:: UsefulAnnotations + :save_last_frame: + + class UsefulAnnotations(Scene): + def construct(self): + m0 = Dot() + m1 = AnnotationDot() + m2 = LabeledDot("ii") + m3 = LabeledDot...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/mobject/geometry/arc.py
Provide docstrings following PEP 257
from __future__ import annotations from enum import Enum from typing import TypedDict import numpy as np from cloup import Context from PIL.Image import Resampling from manim.typing import Vector3D __all__ = [ "SCENE_NOT_FOUND_MESSAGE", "CHOOSE_NUMBER_MESSAGE", "INVALID_NUMBER_MESSAGE", "NO_SCENE_M...
--- +++ @@ -1,3 +1,4 @@+"""Constant definitions.""" from __future__ import annotations @@ -255,12 +256,54 @@ class RendererType(Enum): + """An enumeration of all renderer types that can be assigned to + the ``config.renderer`` attribute. + + Manim's configuration allows assigning string values to the ...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/constants.py
Write beginner-friendly docstrings
from __future__ import annotations __all__ = ["AnimatedBoundary", "TracedPath"] from collections.abc import Callable, Sequence from typing import Any, Self from manim.mobject.mobject import Mobject from manim.mobject.opengl.opengl_compatibility import ConvertToOpenGL from manim.mobject.types.vectorized_mobject impo...
--- +++ @@ -1,3 +1,4 @@+"""Animation of a mobject boundary and tracing of points.""" from __future__ import annotations @@ -21,6 +22,21 @@ class AnimatedBoundary(VGroup): + """Boundary of a :class:`.VMobject` with animated color change. + + Examples + -------- + .. manim:: AnimatedBoundaryExample +...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/animation/changing.py
Help me comply with documentation standards
from __future__ import annotations from collections.abc import Callable, Iterable, Sequence from typing import TYPE_CHECKING, Any import numpy as np from manim._config import config from manim.animation.animation import Animation, prepare_animation from manim.constants import RendererType from manim.mobject.mobject...
--- +++ @@ -1,3 +1,4 @@+"""Tools for displaying multiple animations at once.""" from __future__ import annotations @@ -27,6 +28,28 @@ class AnimationGroup(Animation): + """Plays a group or series of :class:`~.Animation`. + + Parameters + ---------- + animations + Sequence of :class:`~.Animat...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/animation/composition.py
Add detailed docstrings explaining each function
from __future__ import annotations import sys import timeit import click import cloup from manim.cli.checkhealth.checks import HEALTH_CHECKS, HealthCheckFunction __all__ = ["checkhealth"] @cloup.command( context_settings=None, ) def checkhealth() -> None: click.echo(f"Python executable: {sys.executable}\...
--- +++ @@ -1,3 +1,7 @@+"""A CLI utility helping to diagnose problems with +your Manim installation. + +""" from __future__ import annotations @@ -16,6 +20,9 @@ context_settings=None, ) def checkhealth() -> None: + """This subcommand checks whether Manim is installed correctly + and has access to its r...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/cli/checkhealth/commands.py
Generate docstrings for exported functions
from __future__ import annotations __all__ = ["SampleSpace", "BarChart"] from collections.abc import Iterable, MutableSequence, Sequence from typing import Any import numpy as np from manim import config, logger from manim.constants import * from manim.mobject.geometry.polygram import Rectangle from manim.mobject...
--- +++ @@ -1,3 +1,4 @@+"""Mobjects representing objects from probability theory and statistics.""" from __future__ import annotations @@ -34,6 +35,23 @@ class SampleSpace(Rectangle): + """A mobject representing a twodimensional rectangular + sampling space. + + Examples + -------- + .. manim:: ...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/mobject/graphing/probability.py
Turn comments into proper docstrings
from __future__ import annotations from manim.mobject.mobject import Mobject from manim.mobject.opengl.opengl_vectorized_mobject import OpenGLVMobject __all__ = ["NumberLine", "UnitInterval"] from collections.abc import Callable, Iterable, Sequence from typing import TYPE_CHECKING if TYPE_CHECKING: from typin...
--- +++ @@ -1,3 +1,4 @@+"""Mobject representing a number line.""" from __future__ import annotations @@ -32,6 +33,110 @@ class NumberLine(Line): + """Creates a number line with tick marks. + + Parameters + ---------- + x_range + The ``[x_min, x_max, x_step]`` values to create the line. + ...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/mobject/graphing/number_line.py
Generate docstrings for script automation
from __future__ import annotations from collections.abc import Hashable from typing import TYPE_CHECKING, Any import numpy as np from manim.mobject.geometry.polygram import Polygon from manim.mobject.graph import Graph from manim.mobject.three_d.three_dimensions import Dot3D from manim.mobject.types.vectorized_mobj...
--- +++ @@ -1,3 +1,4 @@+"""General polyhedral class and platonic solids.""" from __future__ import annotations @@ -27,6 +28,72 @@ class Polyhedron(VGroup): + """An abstract polyhedra class. + + In this implementation, polyhedra are defined with a list of vertex coordinates in space, and a list + of fa...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/mobject/three_d/polyhedra.py
Help me add docstrings to my project
from __future__ import annotations __all__ = [ "ArrowTip", "ArrowCircleFilledTip", "ArrowCircleTip", "ArrowSquareTip", "ArrowSquareFilledTip", "ArrowTriangleTip", "ArrowTriangleFilledTip", "StealthTip", ] from typing import TYPE_CHECKING, Any import numpy as np from manim.constants ...
--- +++ @@ -1,3 +1,4 @@+r"""A collection of tip mobjects for use with :class:`~.TipableVMobject`.""" from __future__ import annotations @@ -28,16 +29,124 @@ class ArrowTip(VMobject, metaclass=ConvertToOpenGL): + r"""Base class for arrow tips. + + .. seealso:: + :class:`ArrowTriangleTip` + :...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/mobject/geometry/tips.py
Generate docstrings with examples
from __future__ import annotations __all__ = ["ManimBanner"] from typing import Any import svgelements as se from manim.animation.updaters.update import UpdateFromAlphaFunc from manim.mobject.geometry.arc import Circle from manim.mobject.geometry.polygram import Square, Triangle from manim.mobject.mobject import M...
--- +++ @@ -1,3 +1,4 @@+"""Utilities for Manim's logo and banner.""" from __future__ import annotations @@ -104,6 +105,41 @@ class ManimBanner(VGroup): + r"""Convenience class representing Manim's banner. + + Can be animated using custom methods. + + Parameters + ---------- + dark_theme + ...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/mobject/logo.py
Annotate my code with docstrings
from __future__ import annotations __all__ = ["TransformMatchingShapes", "TransformMatchingTex"] from typing import TYPE_CHECKING import numpy as np from manim.mobject.opengl.opengl_mobject import OpenGLGroup, OpenGLMobject from manim.mobject.opengl.opengl_vectorized_mobject import OpenGLVGroup, OpenGLVMobject fr...
--- +++ @@ -1,3 +1,4 @@+"""Animations that try to transform Mobjects while keeping track of identical parts.""" from __future__ import annotations @@ -23,6 +24,48 @@ class TransformMatchingAbstractBase(AnimationGroup): + """Abstract base class for transformations that keep track of matching parts. + + Su...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/animation/transform_matching_parts.py
Replace inline comments with docstrings
from __future__ import annotations __all__ = [ "ThreeDVMobject", "Surface", "Sphere", "Dot3D", "Cube", "Prism", "Cone", "Arrow3D", "Cylinder", "Line3D", "Torus", ] from collections.abc import Callable, Iterable, Sequence from typing import TYPE_CHECKING, Any, Literal, Self...
--- +++ @@ -1,3 +1,4 @@+"""Three-dimensional mobjects.""" from __future__ import annotations @@ -58,6 +59,56 @@ class Surface(VGroup, metaclass=ConvertToOpenGL): + """Creates a Parametric Surface using a checkerboard pattern. + + Parameters + ---------- + func + The function defining the :cl...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/mobject/three_d/three_dimensions.py
Document functions with detailed explanations
from __future__ import annotations __all__ = ["AbstractImageMobject", "ImageMobject", "ImageMobjectFromCamera"] import pathlib from typing import TYPE_CHECKING, Any import numpy as np from PIL import Image from PIL.Image import Resampling from manim.mobject.geometry.shape_matchers import SurroundingRectangle from...
--- +++ @@ -1,3 +1,4 @@+"""Mobjects representing raster images.""" from __future__ import annotations @@ -39,6 +40,18 @@ class AbstractImageMobject(Mobject): + """ + Automatically filters out black pixels + + Parameters + ---------- + scale_to_resolution + At this resolution the image is ...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/mobject/types/image_mobject.py
Add professional docstrings to my codebase
from __future__ import annotations __all__ = ["Mobject", "Group", "override_animate"] import copy import inspect import itertools as it import math import operator as op import random import sys import types import warnings from collections.abc import Callable, Iterable, Iterator, Sequence from functools import par...
--- +++ @@ -1,3 +1,4 @@+"""Base classes for objects that can be displayed.""" from __future__ import annotations @@ -69,6 +70,24 @@ class Mobject: + """Mathematical Object: base class for objects that can be displayed on screen. + + There is a compatibility layer that allows for + getting and setting ...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/mobject/mobject.py
Create docstrings for API functions
from __future__ import annotations __all__ = ["PMobject", "Mobject1D", "Mobject2D", "PGroup", "PointCloudDot", "Point"] from collections.abc import Callable from typing import TYPE_CHECKING, Any import numpy as np from manim.mobject.opengl.opengl_compatibility import ConvertToOpenGL from manim.mobject.opengl.openg...
--- +++ @@ -1,3 +1,4 @@+"""Mobjects representing point clouds.""" from __future__ import annotations @@ -44,6 +45,33 @@ class PMobject(Mobject, metaclass=ConvertToOpenGL): + """A disc made of a cloud of Dots + + Examples + -------- + + .. manim:: PMobjectExample + :save_last_frame: + + ...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/mobject/types/point_cloud_mobject.py
Add docstrings for production code
from __future__ import annotations __all__ = [ "Matrix", "DecimalMatrix", "IntegerMatrix", "MobjectMatrix", "matrix_to_tex_string", "matrix_to_mobject", "get_det_text", ] import itertools as it from collections.abc import Callable, Iterable from typing import Any, Self import numpy as n...
--- +++ @@ -1,3 +1,30 @@+r"""Mobjects representing matrices. + +Examples +-------- + +.. manim:: MatrixExamples + :save_last_frame: + + class MatrixExamples(Scene): + def construct(self): + m0 = Matrix([["\\pi", 0], [-1, 1]]) + m1 = IntegerMatrix([[1.5, 0.], [12, -1.3]], + ...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/mobject/matrix.py
Write docstrings for algorithm functions
from __future__ import annotations __all__ = [ "VectorField", "ArrowVectorField", "StreamLines", ] import itertools as it import random from collections.abc import Callable, Iterable, Sequence from math import ceil, floor from typing import TYPE_CHECKING import numpy as np from PIL import Image from ma...
--- +++ @@ -1,3 +1,4 @@+"""Mobjects representing vector fields.""" from __future__ import annotations @@ -55,6 +56,30 @@ class VectorField(VGroup): + """A vector field. + + Vector fields are based on a function defining a vector at every position. + This class does by default not include any visible e...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/mobject/vector_field.py
Generate docstrings for each module
from __future__ import annotations from collections.abc import Iterable from typing import TYPE_CHECKING, Any import numpy as np from manim.utils.hashing import get_hash_from_play_call from .. import config, logger from ..camera.camera import Camera from ..mobject.mobject import Mobject, _AnimationBuilder from ..sc...
--- +++ @@ -24,6 +24,16 @@ class CairoRenderer: + """A renderer using Cairo. + + Attributes + ---------- + num_plays : int + Number of play() functions in the scene. + + time : float + Time elapsed since initialisation of scene. + """ def __init__( self, @@ -120,6 +13...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/renderer/cairo_renderer.py
Create documentation for each function signature
from __future__ import annotations import contextlib import itertools as it import time import typing from functools import cached_property from typing import TYPE_CHECKING, Any, Self import moderngl import numpy as np from moderngl import Framebuffer from PIL import Image from typing_extensions import override from...
--- +++ @@ -66,6 +66,31 @@ class OpenGLCamera(OpenGLMobject): + """ + An OpenGL-based camera for 3D scene rendering. + + + Attributes + ---------- + frame_shape : tuple[float, float] + The width and height of the camera frame. + center_point : np.ndarray + The center point of the cam...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/renderer/opengl_renderer.py
Auto-generate documentation strings for this file
from __future__ import annotations __all__ = ["MovingCameraScene"] from typing import Any from manim.animation.animation import Animation from manim.mobject.mobject import Mobject from ..camera.camera import Camera from ..camera.moving_camera import MovingCamera from ..scene.scene import Scene from ..utils.family ...
--- +++ @@ -1,3 +1,89 @@+"""A scene whose camera can be moved around. + +.. SEEALSO:: + + :mod:`.moving_camera` + + +Examples +-------- + +.. manim:: ChangingCameraWidthAndRestore + + class ChangingCameraWidthAndRestore(MovingCameraScene): + def construct(self): + text = Text("Hello World").set_...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/scene/moving_camera_scene.py
Document all public functions with docstrings
from __future__ import annotations import math from collections.abc import Iterable from typing import TYPE_CHECKING, Any, overload import numpy as np __all__ = ["LogBase", "LinearBase"] from manim.mobject.text.numbers import Integer if TYPE_CHECKING: from collections.abc import Callable from manim.mobjec...
--- +++ @@ -17,6 +17,13 @@ class _ScaleBase: + """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): self.custom_la...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/mobject/graphing/scale.py
Add docstrings to improve readability
from __future__ import annotations __all__ = ["SceneFileWriter"] import json import shutil import warnings from fractions import Fraction from pathlib import Path from queue import Queue from tempfile import NamedTemporaryFile, _TemporaryFileWrapper from threading import Thread from typing import TYPE_CHECKING, Any ...
--- +++ @@ -1,3 +1,4 @@+"""The interface between scenes and ffmpeg.""" from __future__ import annotations @@ -90,6 +91,32 @@ class SceneFileWriter: + """SceneFileWriter is the object that actually writes the animations + played, into video files, using FFMPEG. + This is mostly for Manim's internal use...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/scene/scene_file_writer.py
Turn comments into proper docstrings
from __future__ import annotations __all__ = ["VectorScene", "LinearTransformationScene"] from collections.abc import Callable, Iterable from typing import TYPE_CHECKING, Any, cast import numpy as np from manim.animation.creation import DrawBorderThenFill, Group from manim.camera.camera import Camera from manim.mo...
--- +++ @@ -1,3 +1,4 @@+"""A scene suitable for vector spaces.""" from __future__ import annotations @@ -73,6 +74,21 @@ self.basis_vector_stroke_width = basis_vector_stroke_width def add_plane(self, animate: bool = False, **kwargs: Any) -> NumberPlane: + """ + Adds a NumberPlane object...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/scene/vector_space_scene.py
Add minimal docstrings for each function
from __future__ import annotations __all__ = ["ZoomedScene"] from typing import TYPE_CHECKING, Any from ..animation.transform import ApplyMethod from ..camera.camera import Camera from ..camera.moving_camera import MovingCamera from ..camera.multi_camera import MultiCamera from ..constants import * from ..mobject.t...
--- +++ @@ -1,3 +1,49 @@+"""A scene supporting zooming in on a specified section. + + +Examples +-------- + +.. manim:: UseZoomedScene + + class UseZoomedScene(ZoomedScene): + def construct(self): + dot = Dot().set_color(GREEN) + self.add(dot) + self.wait(1) + self....
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/scene/zoomed_scene.py
Turn comments into proper docstrings
from __future__ import annotations __all__ = ["ThreeDScene", "SpecialThreeDScene"] import warnings from collections.abc import Iterable, Sequence import numpy as np from manim.mobject.geometry.line import Line from manim.mobject.graphing.coordinate_systems import ThreeDAxes from manim.mobject.opengl.opengl_mobjec...
--- +++ @@ -1,3 +1,4 @@+"""A scene suitable for rendering three-dimensional objects and animations.""" from __future__ import annotations @@ -28,6 +29,10 @@ class ThreeDScene(Scene): + """ + This is a Scene, with special configurations and properties that + make it suitable for Three Dimensional Scene...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/scene/three_d_scene.py
Create Google-style docstrings for my code
from __future__ import annotations from enum import Enum from pathlib import Path from typing import Any from manim import get_video_metadata __all__ = ["Section", "DefaultSectionType"] class DefaultSectionType(str, Enum): NORMAL = "default.normal" class Section: def __init__( self, type_: str...
--- +++ @@ -1,3 +1,4 @@+"""building blocks of segmented video API""" from __future__ import annotations @@ -11,11 +12,52 @@ class DefaultSectionType(str, Enum): + """The type of a section can be used for third party applications. + A presentation system could for example use the types to created loops. +...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/scene/section.py
Write documentation strings for class attributes
from __future__ import annotations import colorsys # logger = _config.logger import random import re from collections.abc import Iterable, Sequence from typing import Self, TypeAlias, TypeVar, overload import numpy as np import numpy.typing as npt from typing_extensions import TypeIs, override from manim.typing im...
--- +++ @@ -1,3 +1,66 @@+"""Manim's (internal) color data structure and some utilities for color conversion. + +This module contains the implementation of :class:`.ManimColor`, the data structure +internally used to represent colors. + +The preferred way of using these colors is by importing their constants from Manim:...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/utils/color/core.py
Help me comply with documentation standards
from __future__ import annotations __all__ = [ "bezier", "partial_bezier_points", "split_bezier", "subdivide_bezier", "bezier_remap", "interpolate", "integer_interpolate", "mid", "inverse_interpolate", "match_interpolate", "get_smooth_cubic_bezier_handle_points", "is_cl...
--- +++ @@ -1,3 +1,4 @@+"""Utility functions related to Bézier curves.""" from __future__ import annotations @@ -63,6 +64,56 @@ def bezier( points: Point3D_Array | Sequence[Point3D_Array], ) -> Callable[[float | ColVector], Point3D_Array]: + """Classic implementation of a Bézier curve. + + Parameters +...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/utils/bezier.py
Expand my code with proper documentation strings
from __future__ import annotations __all__ = ["deprecated", "deprecated_params"] import inspect import logging import re from collections.abc import Callable, Iterable from typing import Any, TypeVar, overload from decorator import decorate, decorator logger = logging.getLogger("manim") def _get_callable_info(c...
--- +++ @@ -1,3 +1,4 @@+"""Decorators for deprecating classes, functions and function parameters.""" from __future__ import annotations @@ -16,6 +17,19 @@ def _get_callable_info(callable_: Callable[..., Any], /) -> tuple[str, str]: + """Returns type and name of a callable. + + Parameters + ---------- ...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/utils/deprecation.py
Write docstrings for utility functions
from __future__ import annotations __all__ = [ "merge_dicts_recursively", "update_dict_recursively", "DictAsObject", ] import itertools as it from typing import Any, Generic, Protocol, cast import numpy.typing as npt from typing_extensions import TypeVar def merge_dicts_recursively(*dicts: dict[Any, ...
--- +++ @@ -1,3 +1,4 @@+"""Utilities that might be useful for configuration dictionaries.""" from __future__ import annotations @@ -16,6 +17,15 @@ def merge_dicts_recursively(*dicts: dict[Any, Any]) -> dict[Any, Any]: + """ + Creates a dict whose keyset is the union of all the + input dictionaries. T...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/utils/config_ops.py
Expand my code with proper documentation strings
from __future__ import annotations from collections.abc import Iterable from pathlib import Path from typing import TYPE_CHECKING import moderngl import numpy as np from PIL import Image from manim.constants import * from manim.mobject.opengl.opengl_mobject import OpenGLMobject from manim.utils.bezier import integer...
--- +++ @@ -26,6 +26,36 @@ class OpenGLSurface(OpenGLMobject): + r"""Creates a Surface. + + Parameters + ---------- + uv_func + The function that defines the surface. + u_range + The range of the ``u`` variable: ``(u_min, u_max)``. + v_range + The range of the ``v`` variable: ...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/mobject/opengl/opengl_surface.py
Add docstrings to existing functions
from __future__ import annotations from typing import TYPE_CHECKING from docutils import nodes from docutils.parsers.rst import Directive from docutils.statemachine import StringList from manim.utils.docbuild.module_parsing import parse_module_attributes if TYPE_CHECKING: from sphinx.application import Sphinx ...
--- +++ @@ -1,3 +1,4 @@+"""A directive for documenting type aliases and other module-level attributes.""" from __future__ import annotations @@ -25,6 +26,24 @@ def smart_replace(base: str, alias: str, substitution: str) -> str: + """Auxiliary function for substituting type aliases into a base + string, w...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/utils/docbuild/autoaliasattr_directive.py
Add docstrings for production code
from __future__ import annotations __all__ = ["OpenGLPMobject", "OpenGLPGroup", "OpenGLPMPoint"] from typing import TYPE_CHECKING import moderngl import numpy as np from manim.constants import * from manim.mobject.opengl.opengl_mobject import OpenGLMobject from manim.utils.bezier import interpolate from manim.utils...
--- +++ @@ -73,6 +73,11 @@ color: ParsableManimColor | None = None, opacity: float | None = None, ) -> Self: + """Add points. + + Points must be a Nx3 numpy array. + Rgbas must be a Nx4 numpy array if it is not None. + """ if rgbas is None and color is None: ...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/mobject/opengl/opengl_point_cloud_mobject.py
Document helper functions with docstrings
from __future__ import annotations from typing import Any, Self, cast import numpy as np from manim.constants import * from manim.mobject.mobject import Mobject from manim.mobject.opengl.opengl_vectorized_mobject import ( OpenGLDashedVMobject, OpenGLMobject, OpenGLVGroup, OpenGLVMobject, ) from manim...
--- +++ @@ -67,6 +67,23 @@ class OpenGLTipableVMobject(OpenGLVMobject): + """ + Meant for shared functionality between Arc and Line. + Functionality can be classified broadly into these groups: + + * Adding, Creating, Modifying tips + - add_tip calls create_tip, before pushing the new tip...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/mobject/opengl/opengl_geometry.py
Add missing documentation to my Python functions
from __future__ import annotations import copy import inspect import itertools as it import random import sys import types from collections.abc import Callable, Iterable, Iterator, Sequence from functools import partialmethod, wraps from math import ceil from typing import ( TYPE_CHECKING, Any, ClassVar, ...
--- +++ @@ -113,6 +113,20 @@ class OpenGLMobject: + """Mathematical Object: base class for objects that can be displayed on screen. + + Attributes + ---------- + submobjects : List[:class:`OpenGLMobject`] + The contained objects. + points : :class:`numpy.ndarray` + The points of the obj...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/mobject/opengl/opengl_mobject.py
Provide docstrings following PEP 257
from __future__ import annotations import os from pathlib import Path from typing import Any from xml.etree import ElementTree as ET import numpy as np import svgelements as se from manim import config, logger from manim.utils.color import ManimColor, ParsableManimColor from ...constants import RIGHT from ...utils...
--- +++ @@ -1,3 +1,4 @@+"""Mobjects generated from an SVG file.""" from __future__ import annotations @@ -33,6 +34,65 @@ class SVGMobject(VMobject, metaclass=ConvertToOpenGL): + """A vectorized mobject created from importing an SVG file. + + Parameters + ---------- + file_name + The path to ...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/mobject/svg/svg_mobject.py
Write docstrings that follow conventions
from __future__ import annotations __all__ = [ "Code", ] import re from pathlib import Path from typing import Any, Literal from bs4 import BeautifulSoup, Tag from pygments import highlight from pygments.formatters.html import HtmlFormatter from pygments.lexers import get_lexer_by_name, guess_lexer, guess_lexer...
--- +++ @@ -1,3 +1,4 @@+"""Mobject representing highlighted source code listings.""" from __future__ import annotations @@ -25,6 +26,83 @@ class Code(VMobject, metaclass=ConvertToOpenGL): + """A highlighted source code listing. + + Examples + -------- + + Normal usage:: + + listing = Code( +...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/mobject/text/code_mobject.py
Create simple docstrings for beginners
from __future__ import annotations __all__ = [ "adjacent_n_tuples", "adjacent_pairs", "all_elements_are_instances", "concatenate_lists", "list_difference_update", "list_update", "listify", "make_even", "make_even_by_cycling", "remove_list_redundancies", "remove_nones", ...
--- +++ @@ -1,3 +1,4 @@+"""Operations on iterables.""" from __future__ import annotations @@ -42,20 +43,64 @@ def adjacent_n_tuples(objects: Sequence[T], n: int) -> zip[tuple[T, ...]]: + """Returns the Sequence objects cyclically split into n length tuples. + + See Also + -------- + adjacent_pairs ...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/utils/iterables.py
Generate docstrings for this script
from __future__ import annotations __all__ = [ "Table", "MathTable", "MobjectTable", "IntegerTable", "DecimalTable", ] import itertools as it from collections.abc import Callable, Iterable, Sequence from manim.mobject.geometry.line import Line from manim.mobject.geometry.polygram import Polygon...
--- +++ @@ -1,3 +1,57 @@+r"""Mobjects representing tables. + +Examples +-------- + +.. manim:: TableExamples + :save_last_frame: + + class TableExamples(Scene): + def construct(self): + t0 = Table( + [["First", "Second"], + ["Third","Fourth"]], + row_...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/mobject/table.py
Create simple docstrings for beginners
from __future__ import annotations import itertools as it import operator as op from collections.abc import Callable, Iterable, Sequence from functools import reduce, wraps from typing import Any, Self import moderngl import numpy as np from manim import config from manim.constants import * from manim.mobject.opengl...
--- +++ @@ -65,6 +65,7 @@ class OpenGLVMobject(OpenGLMobject): + """A vectorized mobject.""" fill_dtype = [ ("point", np.float32, (3,)), @@ -213,6 +214,41 @@ opacity: float | None = None, recurse: bool = True, ) -> OpenGLVMobject: + """Set the fill color and fill opac...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/mobject/opengl/opengl_vectorized_mobject.py
Create Google-style docstrings for my code
from __future__ import annotations import ast import sys from ast import Attribute, Name, Subscript from pathlib import Path from typing import Any, TypeAlias __all__ = ["parse_module_attributes"] AliasInfo: TypeAlias = dict[str, str] """Dictionary with a `definition` key containing the definition of a :class:`Typ...
--- +++ @@ -1,3 +1,4 @@+"""Read and parse all the Manim modules and extract documentation from them.""" from __future__ import annotations @@ -59,6 +60,25 @@ def parse_module_attributes() -> tuple[AliasDocsDict, DataDict, TypeVarDict]: + """Read all files, generate Abstract Syntax Trees from them, and + ...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/utils/docbuild/module_parsing.py
Improve my code by adding docstrings
from __future__ import annotations import csv import itertools as it import re import shutil import sys import textwrap from pathlib import Path from timeit import timeit from typing import TYPE_CHECKING, Any, TypedDict import jinja2 from docutils import nodes from docutils.parsers.rst import Directive, directives f...
--- +++ @@ -1,3 +1,82 @@+r""" +A directive for including Manim videos in a Sphinx document +=========================================================== + +When rendering the HTML documentation, the ``.. manim::`` directive +implemented here allows to include rendered videos. + +Its basic usage that allows processing **...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/utils/docbuild/manim_directive.py
Create docstrings for all classes and functions
from __future__ import annotations import mimetypes import shutil from datetime import datetime from pathlib import Path from typing import Any from manim import config, logger, tempconfig from manim.__main__ import main from manim.renderer.shader import shader_program_cache from ..constants import RendererType __...
--- +++ @@ -1,3 +1,4 @@+"""Utilities for using Manim with IPython (in particular: Jupyter notebooks)""" from __future__ import annotations @@ -43,6 +44,79 @@ cell: str | None = None, local_ns: dict[str, Any] | None = None, ) -> None: + r"""Render Manim scenes contained ...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/utils/ipython_magic.py
Write docstrings describing functionality
from __future__ import annotations __all__ = [ "add_extension_if_not_present", "guarantee_existence", "guarantee_empty_existence", "seek_full_path_from_defaults", "modify_atime", "open_file", "is_mp4_format", "is_gif_format", "is_png_format", "is_webm_format", "is_mov_forma...
--- +++ @@ -1,3 +1,4 @@+"""Utility functions for interacting with the file system.""" from __future__ import annotations @@ -37,31 +38,86 @@ def is_mp4_format() -> bool: + """ + Determines if output format is .mp4 + + Returns + ------- + class:`bool` + ``True`` if format is set as mp4 + +...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/utils/file_ops.py
Add return value explanations in docstrings
from __future__ import annotations import copy import inspect import json import zlib from collections.abc import Callable, Hashable, Iterable, Sequence from time import perf_counter from types import FunctionType, MappingProxyType, MethodType, ModuleType from typing import TYPE_CHECKING, Any, overload import numpy ...
--- +++ @@ -1,3 +1,4 @@+"""Utilities for scene caching.""" from __future__ import annotations @@ -34,6 +35,17 @@ class _Memoizer: + """Implements the memoization logic to optimize the hashing procedure and prevent + the circular references within iterable processed. + + Keeps a record of all the proce...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/utils/hashing.py
Replace inline comments with docstrings
from __future__ import annotations __all__ = ["DecimalNumber", "Integer", "Variable"] from typing import Any, Self import numpy as np from manim import config from manim.constants import * from manim.mobject.opengl.opengl_compatibility import ConvertToOpenGL from manim.mobject.text.tex_mobject import MathTex, Sing...
--- +++ @@ -1,3 +1,4 @@+"""Mobjects representing numbers.""" from __future__ import annotations @@ -20,6 +21,64 @@ class DecimalNumber(VMobject, metaclass=ConvertToOpenGL): + r"""An mobject representing a decimal number. + + Parameters + ---------- + number + The numeric value to be displaye...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/mobject/text/numbers.py
Write docstrings for data processing functions
from __future__ import annotations __all__ = ["Brace", "BraceLabel", "ArcBrace", "BraceText", "BraceBetweenPoints"] from typing import TYPE_CHECKING, Any, Self import numpy as np import svgelements as se from manim._config import config from manim.mobject.geometry.arc import Arc from manim.mobject.geometry.line im...
--- +++ @@ -1,3 +1,4 @@+"""Mobject representing curly braces.""" from __future__ import annotations @@ -31,6 +32,39 @@ class Brace(VMobjectFromSVGPath): + """Takes a mobject and draws a brace adjacent to it. + + Passing a direction vector determines the direction from which the + brace is drawn. By de...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/mobject/svg/brace.py
Add documentation for all methods
from __future__ import annotations from manim.utils.parameter_parsing import flatten_iterable_parameters from ..mobject.mobject import _AnimationBuilder __all__ = ["Scene"] import copy import datetime import inspect import platform import random import threading import time from dataclasses import dataclass from p...
--- +++ @@ -1,3 +1,4 @@+"""Basic canvas for animations.""" from __future__ import annotations @@ -84,6 +85,17 @@ @dataclass class SceneInteractContinue: + """Object which, when encountered in :meth:`.Scene.interact`, triggers + the end of the scene interaction, continuing with the rest of the + animati...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/scene/scene.py
Add docstrings to improve code quality
from __future__ import annotations __all__ = [ "get_mobject_class", "get_point_mobject_class", "get_vectorized_mobject_class", ] from .._config import config from ..constants import RendererType from .mobject import Mobject from .opengl.opengl_mobject import OpenGLMobject from .opengl.opengl_point_cloud_...
--- +++ @@ -1,3 +1,4 @@+"""Utilities for working with mobjects.""" from __future__ import annotations @@ -18,6 +19,25 @@ def get_mobject_class() -> type: + """Gets the base mobject class, depending on the currently active renderer. + + .. NOTE:: + + This method is intended to be used in the code b...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/mobject/utils.py
Write beginner-friendly docstrings
from __future__ import annotations __all__ = [ "VMobject", "VGroup", "VDict", "VectorizedPoint", "CurvesAsSubmobjects", "DashedVMobject", ] import itertools as it import sys from collections.abc import Callable, Hashable, Iterable, Mapping, Sequence from typing import TYPE_CHECKING, Any, Lite...
--- +++ @@ -1,3 +1,4 @@+"""Mobjects that use vector graphics.""" from __future__ import annotations @@ -78,6 +79,29 @@ class VMobject(Mobject): + """A vectorized mobject. + + Parameters + ---------- + background_stroke_color + The purpose of background stroke is to have something + th...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/mobject/types/vectorized_mobject.py
Add docstrings to clarify complex logic
from __future__ import annotations __all__ = ["ValueTracker", "ComplexValueTracker"] from typing import TYPE_CHECKING, Any import numpy as np from manim.mobject.mobject import Mobject from manim.mobject.opengl.opengl_compatibility import ConvertToOpenGL from manim.utils.paths import straight_path if TYPE_CHECKING...
--- +++ @@ -1,3 +1,4 @@+"""Simple mobjects that can be used for storing (and updating) a value.""" from __future__ import annotations @@ -18,6 +19,61 @@ class ValueTracker(Mobject, metaclass=ConvertToOpenGL): + """A mobject that can be used for tracking (real-valued) parameters. + Useful for animating pa...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/mobject/value_tracker.py
Create Google-style docstrings for my code
from __future__ import annotations import hashlib import re import subprocess import unicodedata from collections.abc import Generator, Iterable, Sequence from pathlib import Path from re import Match from typing import Any from manim.utils.tex import TexTemplate from .. import config, logger __all__ = ["tex_to_sv...
--- +++ @@ -1,3 +1,10 @@+"""Interface for writing, compiling, and converting ``.tex`` files. + +.. SEEALSO:: + + :mod:`.mobject.svg.tex_mobject` + +""" from __future__ import annotations @@ -30,6 +37,22 @@ environment: str | None = None, tex_template: TexTemplate | None = None, ) -> Path: + r"""Tak...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/utils/tex_file_writing.py
Add well-formatted docstrings
#!/usr/bin/env python3 from __future__ import annotations import re import subprocess import sys from datetime import datetime from pathlib import Path from typing import TYPE_CHECKING import click if TYPE_CHECKING: from collections.abc import Sequence # ========================================================...
--- +++ @@ -1,4 +1,29 @@ #!/usr/bin/env python3 +""" +Release management tools for Manim. + +This script provides commands for preparing and managing Manim releases: +- Generate changelogs from GitHub's release notes API +- Update CITATION.cff with new version information +- Fetch existing release notes for documentati...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/scripts/release.py
Add docstrings following best practices
from __future__ import annotations __all__ = [ "TexTemplateLibrary", "TexFontTemplates", ] from .tex import * # This file makes TexTemplateLibrary and TexFontTemplates available for use in manim Tex and MathTex objects. def _new_ams_template() -> TexTemplate: preamble = r""" \usepackage[english]{babel...
--- +++ @@ -1,3 +1,4 @@+"""A library of LaTeX templates.""" from __future__ import annotations @@ -12,6 +13,7 @@ def _new_ams_template() -> TexTemplate: + """Returns a simple Tex Template with only basic AMS packages""" preamble = r""" \usepackage[english]{babel} \usepackage{amsmath} @@ -48,6 +50,16 ...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/utils/tex_templates.py
Write docstrings describing functionality
from __future__ import annotations __all__ = [ "TexTemplate", ] import copy import re import warnings from dataclasses import dataclass, field from pathlib import Path from typing import TYPE_CHECKING, Any if TYPE_CHECKING: from typing import Self from manim.typing import StrPath _DEFAULT_PREAMBLE = r...
--- +++ @@ -1,3 +1,4 @@+"""Utilities for processing LaTeX templates.""" from __future__ import annotations @@ -27,6 +28,7 @@ @dataclass(eq=True) class TexTemplate: + """TeX templates are used to create ``Tex`` and ``MathTex`` objects.""" _body: str = field(default="", init=False) """A custom body...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/utils/tex.py
Turn comments into proper docstrings
from __future__ import annotations import functools __all__ = ["Text", "Paragraph", "MarkupText", "register_font"] import copy import hashlib import re from collections.abc import Iterable, Iterator, Sequence from contextlib import contextmanager from itertools import chain from pathlib import Path from typing imp...
--- +++ @@ -1,3 +1,51 @@+"""Mobjects used for displaying (non-LaTeX) text. + +.. note:: + Just as you can use :class:`~.Tex` and :class:`~.MathTex` (from the module :mod:`~.tex_mobject`) + to insert LaTeX to your videos, you can use :class:`~.Text` to to add normal text. + +.. important:: + + See the correspondin...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/mobject/text/text_mobject.py
Create documentation for each function signature
from __future__ import annotations __all__ = [ "straight_path", "path_along_arc", "clockwise_path", "counterclockwise_path", ] from typing import TYPE_CHECKING import numpy as np from ..constants import OUT from ..utils.bezier import interpolate from ..utils.space_ops import normalize, rotation_ma...
--- +++ @@ -1,3 +1,4 @@+"""Functions determining transformation paths between sets of points.""" from __future__ import annotations @@ -30,12 +31,112 @@ def straight_path() -> PathFuncType: + """Simplest path function. Each point in a set goes in a straight path toward its destination. + + Examples + ...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/utils/paths.py
Document functions with detailed explanations
from __future__ import annotations __all__ = [ "linear", "smooth", "smoothstep", "smootherstep", "smoothererstep", "rush_into", "rush_from", "slow_into", "double_smooth", "there_and_back", "there_and_back_with_pause", "running_start", "not_quite_there", "wiggle"...
--- +++ @@ -1,3 +1,87 @@+"""A selection of rate functions, i.e., *speed curves* for animations. +Please find a standard list at https://easings.net/. Here is a picture +for the non-standard ones + +.. manim:: RateFuncExample + :save_last_frame: + + class RateFuncExample(Scene): + def construct(self): + ...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/utils/rate_functions.py
Write docstrings describing functionality
#!/usr/bin/env python from __future__ import annotations from queue import PriorityQueue from typing import TYPE_CHECKING import numpy as np if TYPE_CHECKING: from collections.abc import Sequence from manim.typing import ( Point2D, Point2D_Array, Point2DLike, Point2DLike_Arra...
--- +++ @@ -19,6 +19,15 @@ class Polygon: + """ + Initializes the Polygon with the given rings. + + Parameters + ---------- + rings + A sequence of points, where each sequence represents the rings of the polygon. + Typically, multiple rings indicate holes in the polygon. + """ ...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/utils/polylabel.py
Document this script properly
from __future__ import annotations __all__ = [ "binary_search", "choose", "clip", "sigmoid", ] import math from collections.abc import Callable from functools import lru_cache from typing import Any, Protocol, TypeVar import numpy as np def binary_search( function: Callable[[float], float], ...
--- +++ @@ -1,3 +1,4 @@+"""A collection of simple functions.""" from __future__ import annotations @@ -23,6 +24,34 @@ upper_bound: float, tolerance: float = 1e-4, ) -> float | None: + """Searches for a value in a range by repeatedly dividing the range in half. + + To be more precise, performs numer...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/utils/simple_functions.py
Generate docstrings for each module
from __future__ import annotations import itertools as it from collections.abc import Callable, Sequence from typing import TYPE_CHECKING import numpy as np from mapbox_earcut import triangulate_float32 as earcut from scipy.spatial.transform import Rotation from manim.constants import DOWN, OUT, PI, RIGHT, TAU, UP ...
--- +++ @@ -1,3 +1,4 @@+"""Utility functions for two- and three-dimensional vectors.""" from __future__ import annotations @@ -87,6 +88,15 @@ def quaternion_mult( *quats: Sequence[float], ) -> np.ndarray | list[float | np.ndarray]: + """Gets the Hamilton product of the quaternions provided. + For more ...
https://raw.githubusercontent.com/ManimCommunity/manim/HEAD/manim/utils/space_ops.py
Add docstrings to improve readability
import copy from typing import Sequence import gym from gym import spaces class FilterObservation(gym.ObservationWrapper): def __init__(self, env: gym.Env, filter_keys: Sequence[str] = None): super().__init__(env) wrapped_observation_space = env.observation_space if not isinstance(wrapp...
--- +++ @@ -1,3 +1,4 @@+"""A wrapper for filtering dictionary observations by their keys.""" import copy from typing import Sequence @@ -6,8 +7,34 @@ class FilterObservation(gym.ObservationWrapper): + """Filter Dict observation space by the keys. + + Example: + >>> import gym + >>> env = gym...
https://raw.githubusercontent.com/openai/gym/HEAD/gym/wrappers/filter_observation.py
Write docstrings describing functionality
class EzPickle: def __init__(self, *args, **kwargs): self._ezpickle_args = args self._ezpickle_kwargs = kwargs def __getstate__(self): return { "_ezpickle_args": self._ezpickle_args, "_ezpickle_kwargs": self._ezpickle_kwargs, } def __setstate__(se...
--- +++ @@ -1,17 +1,35 @@+"""Class for pickling and unpickling objects via their constructor arguments.""" class EzPickle: + """Objects that are pickled and unpickled via their constructor arguments. + + Example:: + + >>> class Dog(Animal, EzPickle): + ... def __init__(self, furcolor, tailki...
https://raw.githubusercontent.com/openai/gym/HEAD/gym/utils/ezpickle.py
Create docstrings for API functions
from typing import NamedTuple, Optional, Sequence, Tuple, Union import numpy as np from gym.logger import warn from gym.spaces.box import Box from gym.spaces.discrete import Discrete from gym.spaces.multi_discrete import MultiDiscrete from gym.spaces.space import Space class GraphInstance(NamedTuple): nodes: n...
--- +++ @@ -1,3 +1,4 @@+"""Implementation of a space that represents graph information where nodes and edges can be represented with euclidean space.""" from typing import NamedTuple, Optional, Sequence, Tuple, Union import numpy as np @@ -10,6 +11,12 @@ class GraphInstance(NamedTuple): + """A Graph space in...
https://raw.githubusercontent.com/openai/gym/HEAD/gym/spaces/graph.py
Generate docstrings for script automation
import math from typing import Optional, Union import numpy as np import gym from gym import logger, spaces from gym.envs.classic_control import utils from gym.error import DependencyNotInstalled class CartPoleEnv(gym.Env[np.ndarray, Union[int, np.ndarray]]): metadata = { "render_modes": ["human", "rgb...
--- +++ @@ -1,3 +1,8 @@+""" +Classic cart-pole system implemented by Rich Sutton et al. +Copied from http://incompleteideas.net/sutton/book/code/pole.c +permalink: https://perma.cc/C9ZM-652R +""" import math from typing import Optional, Union @@ -10,6 +15,71 @@ class CartPoleEnv(gym.Env[np.ndarray, Union[int, n...
https://raw.githubusercontent.com/openai/gym/HEAD/gym/envs/classic_control/cartpole.py
Write docstrings for backend logic
color2num = dict( gray=30, red=31, green=32, yellow=33, blue=34, magenta=35, cyan=36, white=37, crimson=38, ) def colorize( string: str, color: str, bold: bool = False, highlight: bool = False ) -> str: attr = [] num = color2num[color] if highlight: num += ...
--- +++ @@ -1,3 +1,7 @@+"""A set of common utilities used within the environments. + +These are not intended as API functions, and will not remain stable over time. +""" color2num = dict( gray=30, @@ -15,6 +19,17 @@ def colorize( string: str, color: str, bold: bool = False, highlight: bool = False ) -> st...
https://raw.githubusercontent.com/openai/gym/HEAD/gym/utils/colorize.py
Turn comments into proper docstrings
import sys from typing import ( TYPE_CHECKING, Any, Dict, Generic, List, Optional, SupportsFloat, Tuple, TypeVar, Union, ) import numpy as np from gym import spaces from gym.logger import warn from gym.utils import seeding if TYPE_CHECKING: from gym.envs.registration impor...
--- +++ @@ -1,3 +1,4 @@+"""Core API for Environment, Wrapper, ActionWrapper, RewardWrapper and ObservationWrapper.""" import sys from typing import ( TYPE_CHECKING, @@ -32,6 +33,30 @@ class Env(Generic[ObsType, ActType]): + r"""The main OpenAI Gym class. + + It encapsulates an environment with arbitrar...
https://raw.githubusercontent.com/openai/gym/HEAD/gym/core.py