file_path
stringlengths
29
93
content
stringlengths
0
117k
manim_ManimCommunity/tests/assert_utils.py
from __future__ import annotations import os from pathlib import Path from pprint import pformat def assert_file_exists(filepath: str | os.PathLike) -> None: """Assert that filepath points to an existing file. Print all the elements (files and dir) of the parent dir of the given filepath. This is mostly to ...
manim_ManimCommunity/tests/test_ipython_magic.py
from __future__ import annotations import re from manim import tempconfig from manim.utils.ipython_magic import _generate_file_name def test_jupyter_file_naming(): """Check the format of file names for jupyter""" scene_name = "SimpleScene" expected_pattern = r"[0-9a-zA-Z_]+[@_-]\d\d\d\d-\d\d-\d\d[@_-]\d...
manim_ManimCommunity/tests/test_config.py
from __future__ import annotations import os import tempfile from pathlib import Path import numpy as np from manim import WHITE, Scene, Square, Tex, Text, config, tempconfig from manim._config.utils import ManimConfig from tests.assert_utils import assert_dir_exists, assert_dir_filled, assert_file_exists def test...
manim_ManimCommunity/tests/template_generate_graphical_units_data.py
from __future__ import annotations from manim import * from tests.helpers.graphical_units import set_test_scene # Note: DO NOT COMMIT THIS FILE. The purpose of this template is to produce control data for graphical_units_data. As # soon as the test data is produced, please revert all changes you made to this file, so...
manim_ManimCommunity/tests/test_linear_transformation_scene.py
from manim import RIGHT, UP, LinearTransformationScene, Vector, VGroup __module_test__ = "vector_space_scene" def test_ghost_vectors_len_and_types(): scene = LinearTransformationScene() scene.leave_ghost_vectors = True # prepare vectors (they require a vmobject as their target) v1, v2 = Vector(RIGHT...
manim_ManimCommunity/tests/test_code_mobject.py
from manim.mobject.text.code_mobject import Code def test_code_indentation(): co = Code( code="""\ def test() print("Hi") """, language="Python", indentation_chars=" ", ) assert co.tab_spaces[0] == 1 assert co.tab_spaces[1] == 2
manim_ManimCommunity/tests/test_camera.py
from __future__ import annotations from manim import MovingCamera, Square def test_movingcamera_auto_zoom(): camera = MovingCamera() square = Square() margin = 0.5 camera.auto_zoom([square], margin=margin, animate=False) assert camera.frame.height == square.height + margin
manim_ManimCommunity/tests/helpers/__init__.py
manim_ManimCommunity/tests/helpers/video_utils.py
"""Helpers for dev to set up new tests that use videos.""" from __future__ import annotations import json from pathlib import Path from typing import Any from manim import get_dir_layout, get_video_metadata, logger def get_section_dir_layout(dirpath: Path) -> list[str]: """Return a list of all files in the sec...
manim_ManimCommunity/tests/helpers/graphical_units.py
"""Helpers functions for devs to set up new graphical-units data.""" from __future__ import annotations import tempfile from pathlib import Path import numpy as np from manim import config, logger from manim.scene.scene import Scene def set_test_scene(scene_object: type[Scene], module_name: str): """Function...
manim_ManimCommunity/tests/helpers/path_utils.py
from __future__ import annotations from pathlib import Path def get_project_root() -> Path: return Path(__file__).parent.parent.parent def get_svg_resource(filename): return str( get_project_root() / "tests/test_graphical_units/img_svg_resources" / filename, )
manim_ManimCommunity/tests/interface/test_commands.py
from __future__ import annotations import shutil import sys from pathlib import Path from textwrap import dedent from click.testing import CliRunner from manim import __version__, capture, tempconfig from manim.__main__ import main from manim.cli.checkhealth.checks import HEALTH_CHECKS def test_manim_version(): ...
manim_ManimCommunity/tests/utils/__init__.py
manim_ManimCommunity/tests/utils/testing_utils.py
from __future__ import annotations import inspect import sys def get_scenes_to_test(module_name: str): """Get all Test classes of the module from which it is called. Used to fetch all the SceneTest of the module. Parameters ---------- module_name The name of the module tested. Returns ...
manim_ManimCommunity/tests/utils/video_tester.py
from __future__ import annotations import json import os from functools import wraps from pathlib import Path from typing import Any from manim import get_video_metadata from ..assert_utils import assert_shallow_dict_compare from ..helpers.video_utils import get_section_dir_layout, get_section_index def load_contr...
manim_ManimCommunity/tests/utils/logging_tester.py
from __future__ import annotations import itertools import json import os from functools import wraps from pathlib import Path import pytest def _check_logs(reference_logfile_path: Path, generated_logfile_path: Path) -> None: with reference_logfile_path.open() as reference_logfile: reference_logs = refe...
manim_ManimCommunity/tests/miscellaneous/test_version.py
from __future__ import annotations from importlib.metadata import version from manim import __name__, __version__ def test_version(): assert __version__ == version(__name__)
manim_ManimCommunity/tests/opengl/test_stroke_opengl.py
from __future__ import annotations import manim.utils.color as C from manim.mobject.opengl.opengl_vectorized_mobject import OpenGLVMobject def test_stroke_props_in_ctor(using_opengl_renderer): m = OpenGLVMobject(stroke_color=C.ORANGE, stroke_width=10) assert m.stroke_color.to_hex() == C.ORANGE.to_hex() a...
manim_ManimCommunity/tests/opengl/test_unit_geometry_opengl.py
from __future__ import annotations import numpy as np from manim import Sector def test_get_arc_center(using_opengl_renderer): np.testing.assert_array_equal( Sector(arc_center=[1, 2, 0]).get_arc_center(), [1, 2, 0] )
manim_ManimCommunity/tests/opengl/test_override_animation_opengl.py
from __future__ import annotations import pytest from manim import Animation, override_animation from manim.mobject.opengl.opengl_mobject import OpenGLMobject from manim.utils.exceptions import MultiAnimationOverrideException class AnimationA1(Animation): pass class AnimationA2(Animation): pass class An...
manim_ManimCommunity/tests/opengl/test_coordinate_system_opengl.py
from __future__ import annotations import math import numpy as np import pytest from manim import LEFT, ORIGIN, PI, UR, Axes, Circle, ComplexPlane from manim import CoordinateSystem as CS from manim import NumberPlane, PolarPlane, ThreeDAxes, config, tempconfig def test_initial_config(using_opengl_renderer): "...
manim_ManimCommunity/tests/opengl/test_ipython_magic_opengl.py
from __future__ import annotations import re from manim import config, tempconfig from manim.utils.ipython_magic import _generate_file_name def test_jupyter_file_naming(): """Check the format of file names for jupyter""" scene_name = "SimpleScene" expected_pattern = r"[0-9a-zA-Z_]+[@_-]\d\d\d\d-\d\d-\d\...
manim_ManimCommunity/tests/opengl/__init__.py
manim_ManimCommunity/tests/opengl/test_markup_opengl.py
from __future__ import annotations from manim import MarkupText def test_good_markup(using_opengl_renderer): """Test creation of valid :class:`MarkupText` object""" try: MarkupText("<b>foo</b>") MarkupText("foo") success = True except ValueError: success = False assert...
manim_ManimCommunity/tests/opengl/test_composition_opengl.py
from __future__ import annotations from unittest.mock import MagicMock from manim.animation.animation import Animation, Wait from manim.animation.composition import AnimationGroup, Succession from manim.animation.fading import FadeIn, FadeOut from manim.constants import DOWN, UP from manim.mobject.geometry.arc import...
manim_ManimCommunity/tests/opengl/test_graph_opengl.py
from __future__ import annotations from manim import Dot, Graph, Line, Text def test_graph_creation(using_opengl_renderer): vertices = [1, 2, 3, 4] edges = [(1, 2), (2, 3), (3, 4), (4, 1)] layout = {1: [0, 0, 0], 2: [1, 1, 0], 3: [1, -1, 0], 4: [-1, 0, 0]} G_manual = Graph(vertices=vertices, edges=ed...
manim_ManimCommunity/tests/opengl/test_config_opengl.py
from __future__ import annotations import tempfile from pathlib import Path import numpy as np from manim import WHITE, Scene, Square, config, tempconfig def test_tempconfig(using_opengl_renderer): """Test the tempconfig context manager.""" original = config.copy() with tempconfig({"frame_width": 100,...
manim_ManimCommunity/tests/opengl/test_scene_opengl.py
from __future__ import annotations from manim import Scene, tempconfig from manim.mobject.opengl.opengl_mobject import OpenGLMobject def test_scene_add_remove(using_opengl_renderer): with tempconfig({"dry_run": True}): scene = Scene() assert len(scene.mobjects) == 0 scene.add(OpenGLMobjec...
manim_ManimCommunity/tests/opengl/test_opengl_surface.py
import numpy as np from manim.mobject.opengl.opengl_surface import OpenGLSurface from manim.mobject.opengl.opengl_three_dimensions import OpenGLSurfaceMesh def test_surface_initialization(using_opengl_renderer): surface = OpenGLSurface( lambda u, v: (u, v, u * np.sin(v) + v * np.cos(u)), u_range=...
manim_ManimCommunity/tests/opengl/test_sound_opengl.py
from __future__ import annotations import struct import wave from pathlib import Path import pytest from manim import Scene @pytest.mark.xfail(reason="Not currently implemented for opengl") def test_add_sound(using_opengl_renderer, tmpdir): # create sound file sound_loc = Path(tmpdir, "noise.wav") f = ...
manim_ManimCommunity/tests/opengl/test_axes_shift_opengl.py
from __future__ import annotations import numpy as np from manim.mobject.graphing.coordinate_systems import Axes def test_axes_origin_shift(using_opengl_renderer): ax = Axes(x_range=(5, 10, 1), y_range=(40, 45, 0.5)) np.testing.assert_allclose( ax.coords_to_point(5.0, 40.0), ax.x_axis.number_to_poin...
manim_ManimCommunity/tests/opengl/test_numbers_opengl.py
from __future__ import annotations from manim.mobject.text.numbers import DecimalNumber def test_font_size(): """Test that DecimalNumber returns the correct font_size value after being scaled.""" num = DecimalNumber(0).scale(0.3) assert round(num.font_size, 5) == 14.4 def test_font_size_vs_scale()...
manim_ManimCommunity/tests/opengl/test_opengl_vectorized_mobject.py
from __future__ import annotations import numpy as np import pytest from manim import Circle, Line, Square, VDict, VGroup from manim.mobject.opengl.opengl_mobject import OpenGLMobject from manim.mobject.opengl.opengl_vectorized_mobject import OpenGLVMobject def test_opengl_vmobject_point_from_propotion(using_opengl...
manim_ManimCommunity/tests/opengl/test_opengl_mobject.py
from __future__ import annotations import pytest from manim.mobject.opengl.opengl_mobject import OpenGLMobject def test_opengl_mobject_add(using_opengl_renderer): """Test OpenGLMobject.add().""" """Call this function with a Container instance to test its add() method.""" # check that obj.submobjects is ...
manim_ManimCommunity/tests/opengl/test_texmobject_opengl.py
from __future__ import annotations from pathlib import Path import pytest from manim import MathTex, SingleStringMathTex, Tex, config def test_MathTex(using_opengl_renderer): MathTex("a^2 + b^2 = c^2") assert Path(config.media_dir, "Tex", "e4be163a00cf424f.svg").exists() def test_SingleStringMathTex(usin...
manim_ManimCommunity/tests/opengl/test_family_opengl.py
from __future__ import annotations import numpy as np from manim import RIGHT, Circle from manim.mobject.opengl.opengl_mobject import OpenGLMobject def test_family(using_opengl_renderer): """Check that the family is gathered correctly.""" # Check that an empty OpenGLMobject's family only contains itself ...
manim_ManimCommunity/tests/opengl/test_animate_opengl.py
from __future__ import annotations import numpy as np import pytest from manim.animation.creation import Uncreate from manim.mobject.geometry.arc import Dot from manim.mobject.geometry.line import Line from manim.mobject.geometry.polygram import Square from manim.mobject.mobject import override_animate from manim.mob...
manim_ManimCommunity/tests/opengl/test_text_mobject_opengl.py
from __future__ import annotations from manim.mobject.text.text_mobject import MarkupText, Text def test_font_size(using_opengl_renderer): """Test that Text and MarkupText return the correct font_size value after being scaled.""" text_string = Text("0").scale(0.3) markuptext_string = MarkupText("0")....
manim_ManimCommunity/tests/opengl/test_color_opengl.py
from __future__ import annotations import numpy as np from manim import BLACK, BLUE, GREEN, PURE_BLUE, PURE_GREEN, PURE_RED, Scene from manim.mobject.opengl.opengl_mobject import OpenGLMobject from manim.mobject.opengl.opengl_vectorized_mobject import OpenGLVMobject def test_import_color(using_opengl_renderer): ...
manim_ManimCommunity/tests/opengl/test_ticks_opengl.py
from __future__ import annotations import numpy as np from manim import PI, Axes, NumberLine def test_duplicate_ticks_removed_for_axes(using_opengl_renderer): axis = NumberLine( x_range=[-10, 10], ) ticks = axis.get_tick_range() assert np.unique(ticks).size == ticks.size def test_ticks_not...
manim_ManimCommunity/tests/opengl/test_number_line_opengl.py
from __future__ import annotations import numpy as np from manim import NumberLine from manim.mobject.text.numbers import Integer def test_unit_vector(): """Check if the magnitude of unit vector along the NumberLine is equal to its unit_size.""" axis1 = NumberLine(unit_size=0.4) axis2 = NumberLine(x...
manim_ManimCommunity/tests/opengl/test_value_tracker_opengl.py
from __future__ import annotations from manim.mobject.value_tracker import ComplexValueTracker, ValueTracker def test_value_tracker_set_value(using_opengl_renderer): """Test ValueTracker.set_value()""" tracker = ValueTracker() tracker.set_value(10.0) assert tracker.get_value() == 10.0 def test_valu...
manim_ManimCommunity/tests/opengl/test_copy_opengl.py
from __future__ import annotations from pathlib import Path from manim import BraceLabel, config from manim.mobject.opengl.opengl_mobject import OpenGLMobject def test_opengl_mobject_copy(using_opengl_renderer): """Test that a copy is a deepcopy.""" orig = OpenGLMobject() orig.add(*(OpenGLMobject() for ...
manim_ManimCommunity/tests/opengl/test_svg_mobject_opengl.py
from __future__ import annotations from manim import * from tests.helpers.path_utils import get_svg_resource def test_set_fill_color(using_opengl_renderer): expected_color = "#FF862F" svg = SVGMobject(get_svg_resource("heart.svg"), fill_color=expected_color) assert svg.fill_color.to_hex() == expected_col...
manim_ManimCommunity/tests/test_logging/bad_tex_scene.py
from manim import Scene, Tex, TexTemplate class BadTex(Scene): def construct(self): tex_template = TexTemplate(preamble=r"\usepackage{notapackage}") some_tex = r"\frac{1}{0}" my_tex = Tex(some_tex, tex_template=tex_template) self.add(my_tex)
manim_ManimCommunity/tests/test_logging/basic_scenes_square_to_circle.py
from __future__ import annotations from manim import * # This module is used in the CLI tests in tests_CLi.py. class SquareToCircle(Scene): def construct(self): self.play(Transform(Square(), Circle()))
manim_ManimCommunity/tests/test_logging/__init__.py
manim_ManimCommunity/tests/test_logging/basic_scenes_error.py
from __future__ import annotations from manim import * # This module is intended to raise an error. class Error(Scene): def construct(self): raise Exception("An error has occurred")
manim_ManimCommunity/tests/test_logging/basic_scenes_write_stuff.py
from __future__ import annotations from manim import * # This module is used in the CLI tests in tests_CLi.py. class WriteStuff(Scene): def construct(self): example_text = Tex("This is a some text", tex_to_color_map={"text": YELLOW}) example_tex = MathTex( "\\sum_{k=1}^\\infty {1 \\o...
manim_ManimCommunity/tests/test_logging/test_logging.py
from __future__ import annotations from pathlib import Path from manim import capture from ..utils.logging_tester import * @logs_comparison( "BasicSceneLoggingTest.txt", "logs/basic_scenes_square_to_circle_SquareToCircle.log", ) def test_logging_to_file(tmp_path, python_version): path_basic_scene = Pat...
manim_ManimCommunity/tests/module/scene/test_auto_zoom.py
from __future__ import annotations from manim import * def test_zoom(): s1 = Square() s1.set_x(-10) s2 = Square() s2.set_x(10) with tempconfig({"dry_run": True, "quality": "low_quality"}): scene = MovingCameraScene() scene.add(s1, s2) scene.play(scene.camera.auto_zoom([s1...
manim_ManimCommunity/tests/module/scene/test_scene.py
from __future__ import annotations import datetime import pytest from manim import Circle, FadeIn, Group, Mobject, Scene, Square, tempconfig from manim.animation.animation import Wait def test_scene_add_remove(): with tempconfig({"dry_run": True}): scene = Scene() assert len(scene.mobjects) == ...
manim_ManimCommunity/tests/module/scene/test_sound.py
from __future__ import annotations import struct import wave from pathlib import Path from manim import Scene def test_add_sound(tmpdir): # create sound file sound_loc = Path(tmpdir, "noise.wav") f = wave.open(str(sound_loc), "w") f.setparams((2, 2, 44100, 0, "NONE", "not compressed")) for _ in ...
manim_ManimCommunity/tests/module/scene/test_threed_scene.py
from manim import Circle, Square, ThreeDScene def test_fixed_mobjects(): scene = ThreeDScene() s = Square() c = Circle() scene.add_fixed_in_frame_mobjects(s, c) assert set(scene.mobjects) == {s, c} assert set(scene.camera.fixed_in_frame_mobjects) == {s, c} scene.remove_fixed_in_frame_mobje...
manim_ManimCommunity/tests/module/mobject/test_graph.py
from __future__ import annotations import pytest from manim import DiGraph, Graph, Scene, Text, tempconfig def test_graph_creation(): vertices = [1, 2, 3, 4] edges = [(1, 2), (2, 3), (3, 4), (4, 1)] layout = {1: [0, 0, 0], 2: [1, 1, 0], 3: [1, -1, 0], 4: [-1, 0, 0]} G_manual = Graph(vertices=vertice...
manim_ManimCommunity/tests/module/mobject/test_boolean_ops.py
from __future__ import annotations import numpy as np import pytest from manim import Circle, Square from manim.mobject.geometry.boolean_ops import _BooleanOps @pytest.mark.parametrize( "test_input,expected", [ ( [(1.0, 2.0), (3.0, 4.0)], [ np.array([1.0, 2.0,...
manim_ManimCommunity/tests/module/mobject/test_image.py
import numpy as np import pytest from manim import ImageMobject @pytest.mark.parametrize("dtype", [np.uint8, np.uint16]) def test_invert_image(dtype): array = (255 * np.random.rand(10, 10, 4)).astype(dtype) image = ImageMobject(array, pixel_array_dtype=dtype, invert=True) assert image.pixel_array.dtype =...
manim_ManimCommunity/tests/module/mobject/test_value_tracker.py
from __future__ import annotations from manim.mobject.value_tracker import ComplexValueTracker, ValueTracker def test_value_tracker_set_value(): """Test ValueTracker.set_value()""" tracker = ValueTracker() tracker.set_value(10.0) assert tracker.get_value() == 10.0 def test_value_tracker_get_value()...
manim_ManimCommunity/tests/module/mobject/text/test_text_mobject.py
from __future__ import annotations from contextlib import redirect_stdout from io import StringIO from manim.mobject.text.text_mobject import MarkupText, Text def test_font_size(): """Test that Text and MarkupText return the correct font_size value after being scaled.""" text_string = Text("0").scale(0....
manim_ManimCommunity/tests/module/mobject/text/test_texmobject.py
from __future__ import annotations from pathlib import Path import numpy as np import pytest from manim import MathTex, SingleStringMathTex, Tex, TexTemplate, config, tempconfig from manim.mobject.types.vectorized_mobject import VMobject from manim.utils.color import RED def test_MathTex(): MathTex("a^2 + b^2 ...
manim_ManimCommunity/tests/module/mobject/text/test_markup.py
from __future__ import annotations from manim import MarkupText def test_good_markup(): """Test creation of valid :class:`MarkupText` object""" try: text1 = MarkupText("<b>foo</b>") text2 = MarkupText("foo") success = True except ValueError: success = False assert succ...
manim_ManimCommunity/tests/module/mobject/text/test_numbers.py
from __future__ import annotations from manim import RED, DecimalNumber, Integer def test_font_size(): """Test that DecimalNumber returns the correct font_size value after being scaled.""" num = DecimalNumber(0).scale(0.3) assert round(num.font_size, 5) == 14.4 def test_font_size_vs_scale(): "...
manim_ManimCommunity/tests/module/mobject/mobject/test_opengl_metaclass.py
from __future__ import annotations from manim import Mobject, config, tempconfig from manim.mobject.opengl.opengl_compatibility import ConvertToOpenGL from manim.mobject.opengl.opengl_mobject import OpenGLMobject def test_metaclass_registry(): class SomeTestMobject(Mobject, metaclass=ConvertToOpenGL): pa...
manim_ManimCommunity/tests/module/mobject/mobject/test_mobject.py
from __future__ import annotations import numpy as np import pytest from manim import DL, UR, Circle, Mobject, Rectangle, Square, VGroup def test_mobject_add(): """Test Mobject.add().""" """Call this function with a Container instance to test its add() method.""" # check that obj.submobjects is updated ...
manim_ManimCommunity/tests/module/mobject/mobject/test_copy.py
from __future__ import annotations from pathlib import Path from manim import BraceLabel, Mobject, config def test_mobject_copy(): """Test that a copy is a deepcopy.""" orig = Mobject() orig.add(*(Mobject() for _ in range(10))) copy = orig.copy() assert orig is orig assert orig is not copy ...
manim_ManimCommunity/tests/module/mobject/mobject/test_get_set.py
from __future__ import annotations import types import pytest from manim.mobject.mobject import Mobject def test_generic_set(): m = Mobject() m.set(test=0) assert m.test == 0 @pytest.mark.filterwarnings("ignore::DeprecationWarning") def test_get_compat_layer(): m = Mobject() assert isinstan...
manim_ManimCommunity/tests/module/mobject/mobject/test_family.py
from __future__ import annotations import numpy as np from manim import RIGHT, Circle, Mobject def test_family(): """Check that the family is gathered correctly.""" # Check that an empty mobject's family only contains itself mob = Mobject() assert mob.get_family() == [mob] # Check that all chil...
manim_ManimCommunity/tests/module/mobject/mobject/test_set_attr.py
from __future__ import annotations import numpy as np from manim import RendererType, config from manim.constants import RIGHT from manim.mobject.geometry.polygram import Square def test_Data(): config.renderer = RendererType.OPENGL a = Square().move_to(RIGHT) data_bb = a.data["bounding_box"] np.tes...
manim_ManimCommunity/tests/module/mobject/svg/test_svg_mobject.py
from __future__ import annotations from manim import * from tests.helpers.path_utils import get_svg_resource def test_set_fill_color(): expected_color = "#FF862F" svg = SVGMobject(get_svg_resource("heart.svg"), fill_color=expected_color) assert svg.fill_color.to_hex() == expected_color def test_set_str...
manim_ManimCommunity/tests/module/mobject/graphing/test_ticks.py
from __future__ import annotations import numpy as np from manim import PI, Axes, NumberLine def test_duplicate_ticks_removed_for_axes(): axis = NumberLine( x_range=[-10, 10], ) ticks = axis.get_tick_range() assert np.unique(ticks).size == ticks.size def test_elongated_ticks_float_equality...
manim_ManimCommunity/tests/module/mobject/graphing/test_number_line.py
from __future__ import annotations import numpy as np from manim import NumberLine from manim.mobject.text.numbers import Integer def test_unit_vector(): """Check if the magnitude of unit vector along the NumberLine is equal to its unit_size.""" axis1 = NumberLine(unit_size=0.4) axis2 = NumberLine(x...
manim_ManimCommunity/tests/module/mobject/graphing/test_axes_shift.py
from __future__ import annotations import numpy as np from manim.mobject.graphing.coordinate_systems import Axes, ThreeDAxes from manim.mobject.graphing.scale import LogBase def test_axes_origin_shift(): ax = Axes(x_range=(5, 10, 1), y_range=(40, 45, 0.5)) np.testing.assert_allclose(ax.coords_to_point(5, 40...
manim_ManimCommunity/tests/module/mobject/graphing/test_coordinate_system.py
from __future__ import annotations import math import numpy as np import pytest from manim import LEFT, ORIGIN, PI, UR, Axes, Circle, ComplexPlane from manim import CoordinateSystem as CS from manim import NumberPlane, PolarPlane, ThreeDAxes, config, tempconfig def test_initial_config(): """Check that all attr...
manim_ManimCommunity/tests/module/mobject/geometry/test_unit_geometry.py
from __future__ import annotations import logging import numpy as np logger = logging.getLogger(__name__) from manim import BackgroundRectangle, Circle, Sector def test_get_arc_center(): np.testing.assert_array_equal( Sector(arc_center=[1, 2, 0]).get_arc_center(), [1, 2, 0] ) def test_Background...
manim_ManimCommunity/tests/module/mobject/types/vectorized_mobject/test_vectorized_mobject.py
from math import cos, sin import numpy as np import pytest from manim import ( Circle, CurvesAsSubmobjects, Line, Mobject, Polygon, RegularPolygon, Square, VDict, VGroup, VMobject, ) from manim.constants import PI def test_vmobject_point_from_propotion(): obj = VMobject()...
manim_ManimCommunity/tests/module/mobject/types/vectorized_mobject/test_stroke.py
from __future__ import annotations import manim.utils.color as C from manim import VMobject from manim.mobject.vector_field import StreamLines def test_stroke_props_in_ctor(): m = VMobject(stroke_color=C.ORANGE, stroke_width=10) assert m.stroke_color.to_hex() == C.ORANGE.to_hex() assert m.stroke_width ==...
manim_ManimCommunity/tests/module/utils/test_tex.py
import pytest from manim.utils.tex import TexTemplate DEFAULT_BODY = r"""\documentclass[preview]{standalone} \usepackage[english]{babel} \usepackage{amsmath} \usepackage{amssymb} \begin{document} YourTextHere \end{document}""" BODY_WITH_ADDED_PREAMBLE = r"""\documentclass[preview]{standalone} \usepackage[english]{ba...
manim_ManimCommunity/tests/module/utils/test_deprecation.py
from __future__ import annotations import logging import pytest from manim.utils.deprecation import deprecated, deprecated_params def _get_caplog_record_msg(warn_caplog_manim): logger_name, level, message = warn_caplog_manim.record_tuples[0] return message @pytest.fixture() def warn_caplog_manim(caplog):...
manim_ManimCommunity/tests/module/utils/test_file_ops.py
from __future__ import annotations from pathlib import Path from manim import * from tests.assert_utils import assert_dir_exists, assert_file_not_exists from tests.utils.video_tester import * def test_guarantee_existence(tmp_path: Path): test_dir = tmp_path / "test" guarantee_existence(test_dir) # test ...
manim_ManimCommunity/tests/module/utils/test_manim_color.py
from __future__ import annotations import numpy as np import numpy.testing as nt from manim.utils.color import BLACK, WHITE, ManimColor, ManimColorDType def test_init_with_int() -> None: color = ManimColor(0x123456, 0.5) nt.assert_array_equal( color._internal_value, np.array([0x12, 0x34, 0x5...
manim_ManimCommunity/tests/module/utils/test_hashing.py
from __future__ import annotations import json from zlib import crc32 import pytest import manim.utils.hashing as hashing from manim import Square ALREADY_PROCESSED_PLACEHOLDER = hashing._Memoizer.ALREADY_PROCESSED_PLACEHOLDER @pytest.fixture(autouse=True) def reset_already_processed(): hashing._Memoizer.rese...
manim_ManimCommunity/tests/module/utils/test_space_ops.py
from __future__ import annotations import numpy as np import pytest from manim.utils.space_ops import * from manim.utils.space_ops import shoelace, shoelace_direction def test_rotate_vector(): vec = np.array([0, 1, 0]) rotated = rotate_vector(vec, np.pi / 2) assert np.round(rotated[0], 5) == -1.0 as...
manim_ManimCommunity/tests/module/utils/test_units.py
from __future__ import annotations import numpy as np import pytest from manim import PI, X_AXIS, Y_AXIS, Z_AXIS, config from manim.utils.unit import Degrees, Munits, Percent, Pixels def test_units(): # make sure we are using the right frame geometry assert config.pixel_width == 1920 np.testing.assert_...
manim_ManimCommunity/tests/module/utils/test_color.py
from __future__ import annotations import numpy as np from manim import BLACK, Mobject, Scene, VMobject def test_import_color(): import manim.utils.color as C C.WHITE def test_background_color(): S = Scene() S.camera.background_color = "#ff0000" S.renderer.update_frame(S) np.testing.asser...
manim_ManimCommunity/tests/module/animation/test_override_animation.py
from __future__ import annotations import pytest from manim import Animation, Mobject, override_animation from manim.utils.exceptions import MultiAnimationOverrideException class AnimationA1(Animation): pass class AnimationA2(Animation): pass class AnimationA3(Animation): pass class AnimationB1(An...
manim_ManimCommunity/tests/module/animation/test_composition.py
from __future__ import annotations from unittest.mock import MagicMock import pytest from manim.animation.animation import Animation, Wait from manim.animation.composition import AnimationGroup, Succession from manim.animation.creation import Create, Write from manim.animation.fading import FadeIn, FadeOut from mani...
manim_ManimCommunity/tests/module/animation/test_animate.py
from __future__ import annotations import numpy as np import pytest from manim.animation.creation import Uncreate from manim.mobject.geometry.arc import Dot from manim.mobject.geometry.line import Line from manim.mobject.geometry.polygram import Square from manim.mobject.mobject import override_animate from manim.mob...
manim_ManimCommunity/tests/module/animation/test_creation.py
from __future__ import annotations import numpy as np import pytest from manim import AddTextLetterByLetter, Text, config def test_non_empty_text_creation(): """Check if AddTextLetterByLetter works for non-empty text.""" s = Text("Hello") anim = AddTextLetterByLetter(s) assert anim.mobject.text == "...
manim_ManimCommunity/tests/test_plugins/__init__.py
manim_ManimCommunity/tests/test_plugins/simple_scenes.py
from __future__ import annotations from manim import * class SquareToCircle(Scene): def construct(self): square = Square() circle = Circle() self.play(Transform(square, circle))
manim_ManimCommunity/tests/test_plugins/test_plugins.py
from __future__ import annotations import random import string import textwrap from pathlib import Path import pytest from manim import capture plugin_pyproject_template = textwrap.dedent( """\ [tool.poetry] name = "{plugin_name}" authors = ["ManimCE Test Suite"] version = "0.1.0" descriptio...
manim_ManimCommunity/tests/test_graphical_units/test_boolops.py
from __future__ import annotations from manim import ( BLUE, Circle, Difference, Exclusion, Intersection, Rectangle, Square, Triangle, Union, ) # not exported by default, so directly import from manim.utils.testing.frames_comparison import frames_comparison __module_test__ = "bool...
manim_ManimCommunity/tests/test_graphical_units/test_vector_scene.py
from __future__ import annotations from manim.scene.vector_space_scene import VectorScene from manim.utils.testing.frames_comparison import frames_comparison __module_test__ = "vector_scene" @frames_comparison(base_scene=VectorScene, last_frame=False) def test_vector_to_coords(scene): scene.add_plane().add_coor...
manim_ManimCommunity/tests/test_graphical_units/test_axes.py
from __future__ import annotations from manim import * from manim.utils.testing.frames_comparison import frames_comparison __module_test__ = "plot" @frames_comparison def test_axes(scene): graph = Axes( x_range=[-10, 10, 1], y_range=[-10, 10, 1], x_length=6, y_length=6, c...
manim_ManimCommunity/tests/test_graphical_units/test_utils.py
from __future__ import annotations from manim.utils.testing.frames_comparison import frames_comparison __module_test__ = "utils" @frames_comparison def test_pixel_error_threshold(scene): """Scene produces black frame, control data has 11 modified pixel values.""" pass
manim_ManimCommunity/tests/test_graphical_units/test_movements.py
from __future__ import annotations from manim import * from manim.utils.testing.frames_comparison import frames_comparison __module_test__ = "movements" @frames_comparison(last_frame=False) def test_Homotopy(scene): def func(x, y, z, t): norm = np.linalg.norm([x, y]) tau = interpolate(5, -5, t) ...
manim_ManimCommunity/tests/test_graphical_units/test_opengl.py
from __future__ import annotations from manim import * from manim.renderer.opengl_renderer import OpenGLRenderer from manim.utils.testing.frames_comparison import frames_comparison __module_test__ = "opengl" @frames_comparison(renderer_class=OpenGLRenderer, renderer="opengl") def test_Circle(scene): circle = Ci...
manim_ManimCommunity/tests/test_graphical_units/test_polyhedra.py
from __future__ import annotations from manim import * from manim.utils.testing.frames_comparison import frames_comparison __module_test__ = "polyhedra" @frames_comparison def test_Tetrahedron(scene): scene.add(Tetrahedron()) @frames_comparison def test_Octahedron(scene): scene.add(Octahedron()) @frames...
manim_ManimCommunity/tests/test_graphical_units/conftest.py
from __future__ import annotations import pytest @pytest.fixture def show_diff(request): return request.config.getoption("show_diff") @pytest.fixture(params=[True, False]) def use_vectorized(request): yield request.param
manim_ManimCommunity/tests/test_graphical_units/__init__.py