Skip to content

The animation engine for agents: blazingly fast math and 3D videos with Manim's Python API, on a Rust GPU core.

Python

Make the package's names exactly what its modules declare

Sina Atalaybcde99c838a3
diff --git a/LICENSE-THIRD-PARTY b/LICENSE-THIRD-PARTY
index b12e6f85..69b8f918 100644
--- a/LICENSE-THIRD-PARTY
+++ b/LICENSE-THIRD-PARTY
@@ -8174,7 +8174,6 @@ manimgx 0.1.1: manimgx/animation/easing.py (MIT)
manimgx 0.1.1: manimgx/animation/matching.py (MIT)
manimgx 0.1.1: manimgx/animation/motion.py (MIT)
manimgx 0.1.1: manimgx/animation/updaters.py (MIT)
-manimgx 0.1.1: manimgx/config.py (MIT)
manimgx 0.1.1: manimgx/drawing/geometry.py (MIT)
manimgx 0.1.1: manimgx/drawing/paint.py (MIT)
manimgx 0.1.1: manimgx/mobject.py (MIT)
@@ -8189,6 +8188,7 @@ manimgx 0.1.1: manimgx/mobjects/svg.py (MIT)
manimgx 0.1.1: manimgx/mobjects/three_d.py (MIT)
manimgx 0.1.1: manimgx/mobjects/vector_field.py (MIT)
manimgx 0.1.1: manimgx/scene.py (MIT)
+manimgx 0.1.1: manimgx/settings.py (MIT)
-------------------------------------------------------------------------------
MIT License
diff --git a/browser/src/director.ts b/browser/src/director.ts
index b82e1dc8..5dd0b618 100644
--- a/browser/src/director.ts
+++ b/browser/src/director.ts
@@ -139,7 +139,7 @@ import dataclasses, importlib.util, json, linecache, shutil, sys, traceback
from pathlib import Path
from pyodide.ffi import to_js
from manimgx import _engine
-from manimgx.config import Config, config
+from manimgx.settings import Config, config
from manimgx.scene import Scene
FILMS = Path("/home/pyodide/films")
diff --git a/docs/content/changelog.md b/docs/content/changelog.md
index 6d883df1..b864def3 100644
--- a/docs/content/changelog.md
+++ b/docs/content/changelog.md
@@ -22,6 +22,7 @@ The notable changes to ManimGX, release by release. The format follows
- Add a preview image and social metadata when sharing website and documentation links.
- Credit Academa and the creators in the README.
+- Add Manim CE's `partial_bezier_points`, `subdivide_bezier`, `bezier_remap`, `integer_interpolate`, `is_closed` and `get_smooth_cubic_bezier_handle_points` to the package.
### Changed
@@ -36,9 +37,13 @@ The notable changes to ManimGX, release by release. The format follows
- Make `become` give a mobject another's value, member by member: each member takes its counterpart's points, shape and whole style (its joint and cap styles and 3D shading too), and stays itself, updaters and all, where the other has a member drawn as it is in its place; the members it gains come without updaters, and those it has beyond the other's go. What it was never shows through, becoming the same value again changes nothing, the other is left as it was, and a mobject can become itself or one of its own members. A group or a point cloud that becomes a shape holds the shape in a first member. It is faster too.
- End a transform as its target: its mobject becomes the keyframe its last frame shows, so the points and parts its frames gained on the way never outlive it. A morph that follows another starts from the shape the first ended on, not from that shape divided as the first needed it; `Restore` brings back exactly what was saved, and a remover leaves its mobject as it was. Transforms played together on one mobject still compose. Films that chain morphs change slightly.
- Play `TransformFromCopy` forward: the target turns from the mobject's copy into itself as any transform does, its rate function, `path_arc` and `lag_ratio` running from the copy to the target (they ran backward, the arcs bending the other way), and it ends exactly as itself.
+- Take NumPy out of the package: a scene imports it itself (`import numpy as np`), and `from manimgx import *` no longer brings `np`.
+- Make the voices' names the package's, as every other name is: `m.Fal`, `m.Voice`, `m.Word`, `m.timed`, `m.estimate` and `m.cached`, where they were `m.voices.Fal` and `manimgx.audio.Voice`. `m.voices` is gone.
+- Name the settings' module `manimgx.settings`. `manimgx.config` is the settings themselves, as `m.config` is: after `import manimgx.config`, `manimgx.config.Config` failed.
### Fixed
+- Give a type checker the package's names: each module lists the names it gives in `__all__`, and each package takes in its children's and gathers their lists, so `m.Scene`, `m.Text`, `m.config` and every other name are the package's, where they were reported as not exported ([#38](https://github.com/academa-labs/manimgx/issues/38)). `from manimgx import *` binds exactly those names, no longer the package's modules too: `manimgx.typing` took the place of the standard library's `typing`.
- Redraw a shape that empties with `always_redraw` without a RecursionError, and keep a mobject's updaters off the member its points move into when a transform aligns it, so a relative updater such as `always_shift` no longer runs twice on them ([#32](https://github.com/academa-labs/manimgx/issues/32)).
- Measure a text's size in `inspect` and `render` at 1080p, which is 1080 px on a video's short side, so a tall video (1080x1920) no longer reports readable text as small ([#37](https://github.com/academa-labs/manimgx/issues/37)).
- Make the folder a video or a storyboard is written in when it is missing (`render -o new/out.mp4`, `inspect -o new/sheet.png` and `Scene.render`), instead of failing with "No such file or directory" ([#34](https://github.com/academa-labs/manimgx/issues/34)).
diff --git a/docs/content/reference/mobjects/paths.md b/docs/content/reference/mobjects/paths.md
index 980153ff..7b76096e 100644
--- a/docs/content/reference/mobjects/paths.md
+++ b/docs/content/reference/mobjects/paths.md
@@ -193,6 +193,26 @@ corners, as a smooth curve through them, or one line and curve at a time.
options:
heading_level: 3
+::: manimgx.partial_bezier_points
+ options:
+ heading_level: 3
+
+::: manimgx.subdivide_bezier
+ options:
+ heading_level: 3
+
+::: manimgx.bezier_remap
+ options:
+ heading_level: 3
+
+::: manimgx.get_smooth_cubic_bezier_handle_points
+ options:
+ heading_level: 3
+
+::: manimgx.is_closed
+ options:
+ heading_level: 3
+
## Paths made from paths
::: manimgx.CubicBezier
diff --git a/docs/content/reference/mobjects/positions.md b/docs/content/reference/mobjects/positions.md
index 4a16bb4d..ee19b531 100644
--- a/docs/content/reference/mobjects/positions.md
+++ b/docs/content/reference/mobjects/positions.md
@@ -268,6 +268,10 @@ often needs.
options:
heading_level: 3
+::: manimgx.integer_interpolate
+ options:
+ heading_level: 3
+
::: manimgx.midpoint
options:
heading_level: 3
diff --git a/docs/content/reference/rendering/configuration.md b/docs/content/reference/rendering/configuration.md
index 47dece65..7a82bfdc 100644
--- a/docs/content/reference/rendering/configuration.md
+++ b/docs/content/reference/rendering/configuration.md
@@ -31,10 +31,10 @@ the scene is made; the command line's options set it too (`-r 1080x1920`, `--fps
The frame has the video's shape, and its short side is 8 units: a wide video shows about
14.2 × 8 units, a tall one 8 × 14.2, and the 8 × 8 square in the middle is in both.
-::: manimgx.config.config
+::: manimgx.config
options:
heading_level: 2
-::: manimgx.config.Config
+::: manimgx.settings.Config
options:
heading_level: 2
diff --git a/docs/content/reference/sound/voice.md b/docs/content/reference/sound/voice.md
index 14a724a1..d532a864 100644
--- a/docs/content/reference/sound/voice.md
+++ b/docs/content/reference/sound/voice.md
@@ -51,10 +51,10 @@ captions.
## Voices
-The voices ManimGX brings are fal.ai's: `m.voices.Fal`, with the model you choose and its
+The voices ManimGX brings are fal.ai's: `m.Fal`, with the model you choose and its
settings. Your editor shows each model's settings.
-::: manimgx.audio.fal.Fal
+::: manimgx.Fal
options:
heading_level: 3
@@ -111,22 +111,22 @@ settings. Your editor shows each model's settings.
A voice is any function from a text to a [Speech][manimgx.Speech]: a sound that knows its
words, and when each is said. Any text-to-speech service can be one.
-::: manimgx.audio.Voice
+::: manimgx.Voice
options:
heading_level: 3
-::: manimgx.audio.Word
+::: manimgx.Word
options:
heading_level: 3
-::: manimgx.audio.timed
+::: manimgx.timed
options:
heading_level: 3
-::: manimgx.audio.estimate
+::: manimgx.estimate
options:
heading_level: 3
-::: manimgx.audio.cached
+::: manimgx.cached
options:
heading_level: 3
diff --git a/docs/content/user-guide/coming-from-manim-ce.md b/docs/content/user-guide/coming-from-manim-ce.md
index 81141bbf..b2f69d48 100644
--- a/docs/content/user-guide/coming-from-manim-ce.md
+++ b/docs/content/user-guide/coming-from-manim-ce.md
@@ -10,6 +10,8 @@ code behaves. This page shows where it is different.
- Every name is in the package: `import manimgx as m`, then `m.Circle`, or
`from manimgx import *`. Manim CE's modules are not there: write
`from manimgx import polylabel`, not `from manimgx.utils.polylabel import polylabel`.
+- NumPy is not in the package: import it yourself (`import numpy as np`). Manim CE's
+ `from manim import *` brings `np` with it; ManimGX's brings only ManimGX's names.
- Render with `manimgx render scene.py MyScene`. Manim CE's quality flags (`-ql`, `-qh`,
…) become `-r` (`--resolution`) and `--fps`. `manimgx inspect` writes a storyboard and checks 2D layouts without a video. See
[Rendering and sharing](rendering.md).
diff --git a/docs/content/user-guide/sound-and-voice.md b/docs/content/user-guide/sound-and-voice.md
index 59142b5f..9ec105f1 100644
--- a/docs/content/user-guide/sound-and-voice.md
+++ b/docs/content/user-guide/sound-and-voice.md
@@ -73,13 +73,13 @@ fal.ai key in the `FAL_KEY` environment variable. To choose a different voice, s
`voice` in the scene's class, next to `construct`:
```py
-voice = m.voices.Fal(
+voice = m.Fal(
"fal-ai/minimax/speech-2.8-hd",
voice_setting={"voice_id": "Calm_Woman", "emotion": "happy"},
)
```
-[`Fal`][manimgx.audio.fal.Fal] speaks with [five models][manimgx.audio.fal], and your
+[`Fal`][manimgx.Fal] speaks with [five models][manimgx.audio.fal], and your
editor shows the settings of each one. Any other text-to-speech service can be a voice
too: a voice is a function from text to a [`Speech`][manimgx.Speech]. For a dialogue,
give `say` a voice for one line: `self.say("Hello!", voice=other)`.
diff --git a/docs/templates/python/material/class.html.jinja b/docs/templates/python/material/class.html.jinja
index 8c5ad703..9a0200ff 100644
--- a/docs/templates/python/material/class.html.jinja
+++ b/docs/templates/python/material/class.html.jinja
@@ -42,13 +42,11 @@
{% with obj = class, docstring_sections = sections %}
{% include "mx/lead.html.jinja" with context %}
{% endwith %}
- {# the call, by the name a scene reaches the class by: `m.Circle`, `m.voices.Fal`; a class
+ {# the call, by the name a scene reaches the class by: `m.Circle`, `m.Fal`; a class
the package doesn't export (a configuration's, a clip's) is not made by a scene #}
{% set top = class.package.members %}
{% if class.name in top and not top[class.name].is_module %}
{% set reach = "m." %}
- {% elif "audio" in top and class.name in top["audio"].members %}
- {% set reach = "m.voices." %}
{% else %}
{% set reach = none %}
{% endif %}
diff --git a/docs/templates/python/material/mx/name.html.jinja b/docs/templates/python/material/mx/name.html.jinja
index 87488d13..69d19522 100644
--- a/docs/templates/python/material/mx/name.html.jinja
+++ b/docs/templates/python/material/mx/name.html.jinja
@@ -15,7 +15,6 @@
{%- if parent is none or not parent.is_class -%}
{%- set top = obj.package.members -%}
{%- if obj.name in top -%}m.
- {%- elif "audio" in top and obj.name in top["audio"].members -%}m.voices.
{%- else -%}{{ parent.path }}.
{%- endif -%}
{%- elif "classmethod" in obj.labels or "staticmethod" in obj.labels -%}
diff --git a/docs/zensical.toml b/docs/zensical.toml
index bf7c878d..0a033c9c 100644
--- a/docs/zensical.toml
+++ b/docs/zensical.toml
@@ -220,7 +220,7 @@ Open the video for the user, and tell them its path: `open SquareToCircle.mp4` o
- Style: `color=m.YELLOW`, `fill_opacity=0.5`, `stroke_width=6`, `font_size=48`. A white background: `m.config.background_color = m.WHITE` after the import.
- Graphs: `axes = m.Axes(x_range=[-3, 3], y_range=[-2, 2])`, then `axes.plot(lambda x: x**2, color=m.BLUE)`.
- Sound: `self.add_sound("click.wav")` starts a sound now; `self.play(m.FadeIn(mob), m.Sound("whoosh.mp3"))` plays one with an animation.
-- Narration: `self.say("The derivative of [x squared] is [two x].", m.Indicate(a), m.Write(b))` speaks and plays each animation during its bracketed words; a scene's voice is `voice = m.voices.Fal("<model>", ...)` (fal.ai's text-to-speech, keyed by the environment variable FAL_KEY), by default ElevenLabs' Eleven v3, or any function from text to `m.Speech`.
+- Narration: `self.say("The derivative of [x squared] is [two x].", m.Indicate(a), m.Write(b))` speaks and plays each animation during its bracketed words; a scene's voice is `voice = m.Fal("<model>", ...)` (fal.ai's text-to-speech, keyed by the environment variable FAL_KEY), by default ElevenLabs' Eleven v3, or any function from text to `m.Speech`.
- Slides: `self.next_section("name")` between plays; `manimgx present scene.py` opens them in the browser.
## 6. Look it up
diff --git a/pyproject.toml b/pyproject.toml
index 06f24ac8..762905cb 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -244,8 +244,8 @@ ignore = [
]
[tool.ruff.lint.per-file-ignores]
-# the re-export hub: the package's public names
-"src/manimgx/__init__.py" = ["F401", "F403"]
+# the packages' re-exports: each takes in its children's names
+"src/manimgx/**/__init__.py" = ["F403"]
# the command line starts the GPU for a command that draws before its modules load
"src/manimgx/cli/__init__.py" = ["E402"]
# the benchmark's scenes in Manim CE and ManimGL, in their idioms: everything from one import,
diff --git a/src/manimgx/__init__.py b/src/manimgx/__init__.py
index 560b2f8d..9c47244a 100644
--- a/src/manimgx/__init__.py
+++ b/src/manimgx/__init__.py
@@ -1,127 +1,37 @@
-"""Manim's authoring API, backed by ManimGX's scene, object and animation models."""
+"""Manim's authoring API, backed by ManimGX's scene, object and animation models.
-import numpy as np
+Each module lists the names it gives in `__all__`, and each package, this one too, takes in
+its children's names with a star import and gathers their lists in its own.
+"""
-from manimgx import audio as voices
-from manimgx.animation.easing import *
-from manimgx.animation.matching import *
-from manimgx.animation.motion import *
-from manimgx.animation.timeline import *
-from manimgx.animation.transform import Animate
-from manimgx.animation.updaters import *
-from manimgx.audio import Speech
-from manimgx.audio.sound import Sound
-from manimgx.config import Degrees, Munits, Percent, Pixels, config
-from manimgx.constants import *
-from manimgx.drawing.geometry import (
- STRAIGHT_PATH_THRESHOLD,
- Coefficients,
- Floats,
- Path,
- QuickHull,
- R3_to_complex,
- Step,
- angle_axis_from_quaternion,
- angle_between_vectors,
- angle_of_vector,
- bezier,
- carried,
- cartesian_to_spherical,
- center_of_mass,
- clockwise_path,
- compass_directions,
- complex_func_to_R3_func,
- complex_to_R3,
- counterclockwise_path,
- cross2d,
- earclip_triangulation,
- find_intersection,
- get_unit_normal,
- get_winding_number,
- interpolate,
- inverse_interpolate,
- line_intersection,
- midpoint,
- norm_squared,
- normalize,
- normalize_along_axis,
- path_along_arc,
- path_along_circles,
- perpendicular_bisector,
- polylabel,
- quaternion_conjugate,
- quaternion_from_angle_axis,
- quaternion_mult,
- regular_vertices,
- rotate_vector,
- rotation_about_z,
- rotation_matrix,
- rotation_matrix_from_quaternion,
- rotation_matrix_transpose,
- rotation_matrix_transpose_from_quaternion,
- shoelace,
- shoelace_direction,
- sigmoid,
- spherical_to_cartesian,
- spiral_path,
- straight_path,
- thick_diagonal,
- z_to_vector,
-)
-from manimgx.drawing.paint import *
-from manimgx.drawing.paint import stretch_array_to_length
-from manimgx.mobject import (
- ComplexValueTracker,
- Group,
- MeshMobject,
- Mobject,
- Mobject1D,
- PGroup,
- PMobject,
- Point,
- ValueTracker,
- VDict,
- VectorizedPoint,
- VGroup,
- VMobject,
- override_animate,
- override_animation,
- remove_list_redundancies,
-)
-from manimgx.mobjects.annotations import *
-from manimgx.mobjects.code import *
-from manimgx.mobjects.graph import *
-from manimgx.mobjects.grid import *
-from manimgx.mobjects.images import ImageMobject, ImageMobjectFromCamera
-from manimgx.mobjects.lights import *
-from manimgx.mobjects.logo import *
-from manimgx.mobjects.numbers import DecimalNumber, Integer, Variable, index_labels
-from manimgx.mobjects.plotting import *
-from manimgx.mobjects.shapes import *
-from manimgx.mobjects.shapes import PointCloudDot
-from manimgx.mobjects.svg import SVGMobject, VMobjectFromSVGPath
-from manimgx.mobjects.text import (
- BulletedList,
- MathTex,
- MathTexPart,
- MathTypst,
- Paragraph,
- SingleStringMathTex,
- Tex,
- Text,
- Title,
- Typst,
-)
-from manimgx.mobjects.three_d import *
-from manimgx.mobjects.vector_field import *
-from manimgx.rendering.film import Film
-from manimgx.rendering.window import Window
-from manimgx.scene import (
- Camera,
- LinearTransformationScene,
- MovingCameraScene,
- Scene,
- ThreeDScene,
- VectorScene,
- ZoomedScene,
+from manimgx import (
+ animation,
+ audio,
+ constants,
+ drawing,
+ mobject,
+ mobjects,
+ rendering,
+ scene,
+ settings,
)
+from manimgx.animation import *
+from manimgx.audio import *
+from manimgx.constants import *
+from manimgx.drawing import *
+from manimgx.mobject import *
+from manimgx.mobjects import *
+from manimgx.rendering import *
+from manimgx.scene import *
+from manimgx.settings import *
+
+__all__ = []
+__all__ += animation.__all__
+__all__ += audio.__all__
+__all__ += constants.__all__
+__all__ += drawing.__all__
+__all__ += mobject.__all__
+__all__ += mobjects.__all__
+__all__ += rendering.__all__
+__all__ += scene.__all__
+__all__ += settings.__all__
diff --git a/src/manimgx/animation/__init__.py b/src/manimgx/animation/__init__.py
index e69de29b..9c3066ba 100644
--- a/src/manimgx/animation/__init__.py
+++ b/src/manimgx/animation/__init__.py
@@ -0,0 +1,15 @@
+from manimgx.animation import easing, matching, motion, timeline, transform, updaters
+from manimgx.animation.easing import *
+from manimgx.animation.matching import *
+from manimgx.animation.motion import *
+from manimgx.animation.timeline import *
+from manimgx.animation.transform import *
+from manimgx.animation.updaters import *
+
+__all__ = []
+__all__ += easing.__all__
+__all__ += matching.__all__
+__all__ += motion.__all__
+__all__ += timeline.__all__
+__all__ += transform.__all__
+__all__ += updaters.__all__
diff --git a/src/manimgx/animation/motion.py b/src/manimgx/animation/motion.py
index 0f44a263..61a0eec6 100644
--- a/src/manimgx/animation/motion.py
+++ b/src/manimgx/animation/motion.py
@@ -38,7 +38,6 @@ from manimgx.animation.timeline import (
Succession,
_gathered,
)
-from manimgx.config import config
from manimgx.constants import (
DEFAULT_POINTWISE_FUNCTION_RUN_TIME,
DEFAULT_STROKE_WIDTH,
@@ -61,6 +60,7 @@ from manimgx.drawing.geometry import (
)
from manimgx.drawing.paint import GREY, PURE_YELLOW, ParsableManimColor
from manimgx.mobject import Group, Mobject, Pivot, VGroup, VMobject
+from manimgx.settings import config
from manimgx.typing import Point3D, Point3DLike, Vector3DLike
if TYPE_CHECKING:
@@ -120,7 +120,6 @@ __all__ = [
"SpinInFromNothing",
"SpiralIn",
"Swap",
- "Transform",
"TransformFromCopy",
"TypeWithCursor",
"Uncreate",
diff --git a/src/manimgx/animation/updaters.py b/src/manimgx/animation/updaters.py
index 8301c392..a07a900a 100644
--- a/src/manimgx/animation/updaters.py
+++ b/src/manimgx/animation/updaters.py
@@ -486,7 +486,7 @@ class TracedPath(VMobject):
`traced_point_func` gives the point. The path records where it is at every tick of
the simulation clock
- ([`config.simulation_rate`][manimgx.config.Config.simulation_rate] times a second)
+ ([`config.simulation_rate`][manimgx.settings.Config.simulation_rate] times a second)
and at the end of each play and wait, so it is the same path at any frame rate; at a
frame between two ticks, it runs on to where the point is then. It traces while it
is in the scene, from when it joins it, and at each instant once everything else
diff --git a/src/manimgx/audio/__init__.py b/src/manimgx/audio/__init__.py
index c20199b3..33f407b6 100644
--- a/src/manimgx/audio/__init__.py
+++ b/src/manimgx/audio/__init__.py
@@ -1,38 +1,20 @@
"""Audio: editable sounds, timed speech, and the voices that produce it.
-A voice is any function from text to [`Speech`][manimgx.audio.Speech]: a sound that knows its
+A voice is any function from text to [`Speech`][manimgx.Speech]: a sound that knows its
words and when each is said. [`Scene.say`][manimgx.Scene.say] speaks through the scene's voice
and plays animations during the words they belong to: `self.say("Here is [a circle].",
m.Create(circle))` draws the circle as "a circle" is said, and the film waits for the sentence.
What a voice says is kept (`cached`), so a scene renders again without speaking again.
The voices ManimGX brings are text-to-speech services', a module each: [`fal`][manimgx.audio.fal]
-(fal.ai's models, [`Fal`][manimgx.audio.fal.Fal]). Any other is a few lines away (see
-[`Voice`][manimgx.audio.Voice]).
+(fal.ai's models, [`Fal`][manimgx.Fal]). Any other is a few lines away (see
+[`Voice`][manimgx.Voice]).
"""
-from manimgx.audio.fal import Fal
-from manimgx.audio.sound import (
- Speech,
- Voice,
- Word,
- cached,
- estimate,
- lines,
- spans,
- timed,
- times,
-)
+from manimgx.audio import fal, sound
+from manimgx.audio.fal import *
+from manimgx.audio.sound import *
-__all__ = [
- "Fal",
- "Speech",
- "Voice",
- "Word",
- "cached",
- "estimate",
- "lines",
- "spans",
- "timed",
- "times",
-]
+__all__ = []
+__all__ += fal.__all__
+__all__ += sound.__all__
diff --git a/src/manimgx/audio/fal.py b/src/manimgx/audio/fal.py
index f41a1ff5..bdae8663 100644
--- a/src/manimgx/audio/fal.py
+++ b/src/manimgx/audio/fal.py
@@ -28,6 +28,8 @@ from typing_extensions import TypedDict
from manimgx.audio.sound import Speech, timed
+__all__ = ["Fal"]
+
# ── the models' settings, as their schemas on fal have them ────────────────────────────────
@@ -457,7 +459,7 @@ class Fal:
A scene's voice, in its class:
```py
- voice = m.voices.Fal(
+ voice = m.Fal(
"fal-ai/minimax/speech-2.8-hd",
voice_setting={"voice_id": "Calm_Woman", "speed": 1.1},
)
diff --git a/src/manimgx/audio/sound.py b/src/manimgx/audio/sound.py
index 4b17a0f8..71d1dfcd 100644
--- a/src/manimgx/audio/sound.py
+++ b/src/manimgx/audio/sound.py
@@ -28,6 +28,8 @@ import json
import re
from collections.abc import Sequence
+__all__ = ["Sound", "Speech", "Voice", "Word", "cached", "estimate", "timed"]
+
RATE = 48_000
"""The soundtrack's sample rate: 48,000 samples a second, as video's sound has."""
CUT = 0.005
@@ -139,7 +141,7 @@ class Sound(Animation[Mobject]):
def duck(self, decibels: float = 12) -> Self:
"""This sound dipping by `decibels` while anything speaks (while a
- [`Speech`][manimgx.audio.Speech] plays): music under a narration. It eases down
+ [`Speech`][manimgx.Speech] plays): music under a narration. It eases down
`DUCK_ATTACK` seconds before the speech and back up over `DUCK_RELEASE` after.
"""
return self._but(duck=decibels)
@@ -368,7 +370,7 @@ class Speech(Sound):
Args:
source: The audio: a file's path, a file's bytes, or samples.
text: What it says.
- words: Each word and when it is said, if the voice knows ([`timed`][manimgx.audio.timed]
+ words: Each word and when it is said, if the voice knows ([`timed`][manimgx.timed]
makes them from a voice's own timing); otherwise they are estimated from the audio.
rate: The samples' rate; only for samples.
"""
@@ -408,7 +410,7 @@ class Speech(Sound):
type Voice = Callable[[str], Speech]
-"""Anything that speaks: a function from text to [`Speech`][manimgx.audio.Speech]. Bring any
+"""Anything that speaks: a function from text to [`Speech`][manimgx.Speech]. Bring any
text-to-speech: wrap its call in a function that returns `Speech(audio, text=text)`."""
diff --git a/src/manimgx/cli/diagnostics.py b/src/manimgx/cli/diagnostics.py
index f2f69785..d7221fcb 100644
--- a/src/manimgx/cli/diagnostics.py
+++ b/src/manimgx/cli/diagnostics.py
@@ -9,11 +9,11 @@ from types import FrameType
import numpy as np
import manimgx
-from manimgx.config import config
from manimgx.constants import DL, UR
from manimgx.drawing.geometry import subpath_ranges
from manimgx.mobject import Mobject
from manimgx.scene import Scene
+from manimgx.settings import config
PACKAGE = str(Path(manimgx.__file__).parent)
diff --git a/src/manimgx/cli/export.py b/src/manimgx/cli/export.py
index 1c1f8eba..7851bfe3 100644
--- a/src/manimgx/cli/export.py
+++ b/src/manimgx/cli/export.py
@@ -29,7 +29,6 @@ from manimgx.cli.scenes import (
take,
)
from manimgx.cli.storyboard import Sheets, Watch, line
-from manimgx.config import config
from manimgx.rendering.film import (
DEFAULT_ENCODER_CRF,
DEFAULT_ENCODER_PRESET,
@@ -40,6 +39,7 @@ from manimgx.rendering.film import (
X264Preset,
)
from manimgx.scene import Scene
+from manimgx.settings import config
if TYPE_CHECKING:
from manimgx.animation.transform import Transform
diff --git a/src/manimgx/cli/preview.py b/src/manimgx/cli/preview.py
index d1b1e0ee..e45f2340 100644
--- a/src/manimgx/cli/preview.py
+++ b/src/manimgx/cli/preview.py
@@ -37,9 +37,9 @@ from manimgx.cli.scenes import (
report_error,
scenes,
)
-from manimgx.config import config
from manimgx.rendering.film import Cut
from manimgx.rendering.window import Window
+from manimgx.settings import config
POLL = 0.02 # seconds between looks at the files
diff --git a/src/manimgx/cli/scenes.py b/src/manimgx/cli/scenes.py
index 80bd80cb..76e18886 100644
--- a/src/manimgx/cli/scenes.py
+++ b/src/manimgx/cli/scenes.py
@@ -20,7 +20,6 @@ from rich.console import Console
import manimgx
from manimgx.animation.timeline import Animation
-from manimgx.config import Config, config
from manimgx.rendering.film import (
DEFAULT_ENCODER_CRF,
DEFAULT_ENCODER_PRESET,
@@ -30,6 +29,7 @@ from manimgx.rendering.film import (
X264Preset,
)
from manimgx.scene import Scene
+from manimgx.settings import Config, config
@dataclass(frozen=True, slots=True)
diff --git a/src/manimgx/cli/storyboard.py b/src/manimgx/cli/storyboard.py
index fdeb913e..ff9a69af 100644
--- a/src/manimgx/cli/storyboard.py
+++ b/src/manimgx/cli/storyboard.py
@@ -22,9 +22,9 @@ from manimgx.cli.diagnostics import (
text_of,
view,
)
-from manimgx.config import config
from manimgx.rendering.film import Film, Play
from manimgx.scene import Scene, _written
+from manimgx.settings import config
# a tile's area: 1080p halved each way (reduced exactly: sharp text), two to a sheet's row — in
# the scene's shape, so a sheet costs the same image tokens whatever the shape
diff --git a/src/manimgx/drawing/__init__.py b/src/manimgx/drawing/__init__.py
index e69de29b..49b88313 100644
--- a/src/manimgx/drawing/__init__.py
+++ b/src/manimgx/drawing/__init__.py
@@ -0,0 +1,7 @@
+from manimgx.drawing import geometry, paint
+from manimgx.drawing.geometry import *
+from manimgx.drawing.paint import *
+
+__all__ = []
+__all__ += geometry.__all__
+__all__ += paint.__all__
diff --git a/src/manimgx/drawing/paint.py b/src/manimgx/drawing/paint.py
index cb522d6b..124df023 100644
--- a/src/manimgx/drawing/paint.py
+++ b/src/manimgx/drawing/paint.py
@@ -25,7 +25,7 @@ from typing_extensions import TypedDict
from manimgx.caches import Memo, unchanged
from manimgx.constants import UL, CapStyleType, LineJointType
-from manimgx.drawing.geometry import interpolate
+from manimgx.drawing.geometry import Floats, interpolate
from manimgx.typing import RGBA_Array, Vector3D, Vector3DLike
__all__ = [
@@ -121,7 +121,6 @@ __all__ = [
"YELLOW_D",
"YELLOW_E",
"Colorscale",
- "Floats",
"ManimColor",
"Material",
"ParsableManimColor",
@@ -139,12 +138,10 @@ __all__ = [
"random_color",
"rgb_to_color",
"rgbas_by_value",
+ "stretch_array_to_length",
"to_oklab",
]
-type Floats = npt.NDArray[np.float64]
-"""A NumPy array of floats."""
-
# ── mixing: one rule for every blend of colors ─────────────────────────────────
# Colors mix in OKLab, where lightness moves evenly (the midpoint of two colors sits exactly
# halfway in perceived lightness), premultiplied by opacity so an invisible color never tints
diff --git a/src/manimgx/mobject.py b/src/manimgx/mobject.py
index 93648b48..f9af06c0 100644
--- a/src/manimgx/mobject.py
+++ b/src/manimgx/mobject.py
@@ -39,7 +39,6 @@ from typing_extensions import TypedDict
from manimgx import caches
from manimgx.animation import clock
from manimgx.caches import Memo, unchanged
-from manimgx.config import config
from manimgx.constants import (
DEFAULT_MOBJECT_TO_EDGE_BUFFER,
DEFAULT_MOBJECT_TO_MOBJECT_BUFFER,
@@ -103,6 +102,7 @@ from manimgx.drawing.paint import (
parse_colors,
stretch_array,
)
+from manimgx.settings import config
from manimgx.typing import (
MatrixMN,
PathFunc,
diff --git a/src/manimgx/mobjects/__init__.py b/src/manimgx/mobjects/__init__.py
index e69de29b..003ddf08 100644
--- a/src/manimgx/mobjects/__init__.py
+++ b/src/manimgx/mobjects/__init__.py
@@ -0,0 +1,46 @@
+from manimgx.mobjects import (
+ annotations,
+ code,
+ graph,
+ grid,
+ images,
+ lights,
+ logo,
+ numbers,
+ plotting,
+ shapes,
+ svg,
+ text,
+ three_d,
+ vector_field,
+)
+from manimgx.mobjects.annotations import *
+from manimgx.mobjects.code import *
+from manimgx.mobjects.graph import *
+from manimgx.mobjects.grid import *
+from manimgx.mobjects.images import *
+from manimgx.mobjects.lights import *
+from manimgx.mobjects.logo import *
+from manimgx.mobjects.numbers import *
+from manimgx.mobjects.plotting import *
+from manimgx.mobjects.shapes import *
+from manimgx.mobjects.svg import *
+from manimgx.mobjects.text import *
+from manimgx.mobjects.three_d import *
+from manimgx.mobjects.vector_field import *
+
+__all__ = []
+__all__ += annotations.__all__
+__all__ += code.__all__
+__all__ += graph.__all__
+__all__ += grid.__all__
+__all__ += images.__all__
+__all__ += lights.__all__
+__all__ += logo.__all__
+__all__ += numbers.__all__
+__all__ += plotting.__all__
+__all__ += shapes.__all__
+__all__ += svg.__all__
+__all__ += text.__all__
+__all__ += three_d.__all__
+__all__ += vector_field.__all__
diff --git a/src/manimgx/mobjects/annotations.py b/src/manimgx/mobjects/annotations.py
index 2a07d945..a7303cb5 100644
--- a/src/manimgx/mobjects/annotations.py
+++ b/src/manimgx/mobjects/annotations.py
@@ -29,7 +29,6 @@ from typing import TYPE_CHECKING, ClassVar, Self, Unpack
import numpy as np
-from manimgx.config import config
from manimgx.constants import (
DEFAULT_FONT_SIZE,
DEFAULT_MOBJECT_TO_MOBJECT_BUFFER,
@@ -71,6 +70,7 @@ from manimgx.mobjects.text import (
Text,
TypstOptions,
)
+from manimgx.settings import config
from manimgx.typing import ManimTextLabel
if TYPE_CHECKING:
diff --git a/src/manimgx/mobjects/images.py b/src/manimgx/mobjects/images.py
index 55aeec5e..fbde29ab 100644
--- a/src/manimgx/mobjects/images.py
+++ b/src/manimgx/mobjects/images.py
@@ -6,7 +6,6 @@ from warnings import deprecated
import numpy as np
-from manimgx.config import config
from manimgx.constants import DOWN, LEFT, RIGHT, UP, Resampling
from manimgx.drawing.paint import (
WHITE,
@@ -19,6 +18,7 @@ from manimgx.drawing.paint import (
_Style,
)
from manimgx.mobject import MeshMobject
+from manimgx.settings import config
__all__ = ["ImageMobject", "ImageMobjectFromCamera"]
diff --git a/src/manimgx/mobjects/plotting.py b/src/manimgx/mobjects/plotting.py
index 0b983ccb..14fd1385 100644
--- a/src/manimgx/mobjects/plotting.py
+++ b/src/manimgx/mobjects/plotting.py
@@ -44,7 +44,6 @@ import numpy.typing as npt
from isosurfaces import plot_isoline
from typing_extensions import TypedDict
-from manimgx.config import config
from manimgx.constants import (
DEFAULT_ARROW_TIP_LENGTH,
DEFAULT_DOT_RADIUS,
@@ -103,6 +102,7 @@ from manimgx.mobjects.shapes import (
_Tipped,
)
from manimgx.mobjects.text import MathTex, MathTexOptions, Tex, Typst
+from manimgx.settings import config
from manimgx.typing import ManimTextLabel, Vector3D
if TYPE_CHECKING:
diff --git a/src/manimgx/mobjects/shapes.py b/src/manimgx/mobjects/shapes.py
index f342849a..c67cc55e 100644
--- a/src/manimgx/mobjects/shapes.py
+++ b/src/manimgx/mobjects/shapes.py
@@ -17,7 +17,6 @@ from warnings import deprecated
import numpy as np
-from manimgx.config import config
from manimgx.constants import (
DEFAULT_ARROW_TIP_LENGTH,
DEFAULT_DASH_LENGTH,
@@ -78,6 +77,7 @@ from manimgx.mobject import (
prototype,
style_defaults,
)
+from manimgx.settings import config
from manimgx.typing import Point3DLike
__all__ = [
diff --git a/src/manimgx/mobjects/text.py b/src/manimgx/mobjects/text.py
index 5514568f..39219577 100644
--- a/src/manimgx/mobjects/text.py
+++ b/src/manimgx/mobjects/text.py
@@ -24,18 +24,14 @@ from warnings import deprecated
__all__ = [
"BulletedList",
"MathTex",
- "MathTexOptions",
"MathTexPart",
"MathTypst",
"Paragraph",
"SingleStringMathTex",
"Tex",
"Text",
- "TextOptions",
"Title",
"Typst",
- "TypstGlyph",
- "TypstOptions",
]
import bisect
@@ -1902,9 +1898,9 @@ class Title(Tex):
underline_buff: float = MED_SMALL_BUFF,
**kwargs: Unpack[MathTexOptions],
) -> None:
- from manimgx.config import config
from manimgx.constants import DOWN, LEFT, RIGHT, UP
from manimgx.mobjects.shapes import Line
+ from manimgx.settings import config
super().__init__(*text_parts, **kwargs)
self.to_edge(UP)
diff --git a/src/manimgx/mobjects/vector_field.py b/src/manimgx/mobjects/vector_field.py
index 73127126..8f61dce1 100644
--- a/src/manimgx/mobjects/vector_field.py
+++ b/src/manimgx/mobjects/vector_field.py
@@ -32,7 +32,6 @@ from manimgx.animation.timeline import (
Succession,
Untimed,
)
-from manimgx.config import config
from manimgx.constants import OUT, RIGHT, UP
from manimgx.drawing.geometry import interpolate, inverse_interpolate, sigmoid
from manimgx.drawing.paint import (
@@ -50,6 +49,7 @@ from manimgx.drawing.paint import (
from manimgx.mobject import Mobject, VGroup, VMobject, flow
from manimgx.mobjects.plotting import Axes
from manimgx.mobjects.shapes import ArrowTips, Vector
+from manimgx.settings import config
if TYPE_CHECKING:
from manimgx.typing import FloatRGB, FloatRGB_Array, Point3D, Vector3D
diff --git a/src/manimgx/rendering/__init__.py b/src/manimgx/rendering/__init__.py
index e69de29b..b75bf2c9 100644
--- a/src/manimgx/rendering/__init__.py
+++ b/src/manimgx/rendering/__init__.py
@@ -0,0 +1,7 @@
+from manimgx.rendering import film, window
+from manimgx.rendering.film import *
+from manimgx.rendering.window import *
+
+__all__ = []
+__all__ += film.__all__
+__all__ += window.__all__
diff --git a/src/manimgx/rendering/film.py b/src/manimgx/rendering/film.py
index 3d9329e7..26d951c7 100644
--- a/src/manimgx/rendering/film.py
+++ b/src/manimgx/rendering/film.py
@@ -17,9 +17,11 @@ from warnings import deprecated
from manimgx import _engine
from manimgx.animation import clock
-from manimgx.config import config
from manimgx.rendering import feed
from manimgx.rendering.feed import CameraView, Feeder
+from manimgx.settings import config
+
+__all__ = ["Film"]
if TYPE_CHECKING:
import numpy as np
@@ -382,7 +384,7 @@ class Film:
def captions(self) -> list[Caption]:
"""The film's captions, in order of their start: those the scene added, and its
speech's, a line of a few words at a time as they are said."""
- from manimgx.audio import Speech, lines
+ from manimgx.audio.sound import Speech, lines
spoken = [
Caption(float(clip.start) + a, float(clip.start) + b, text)
diff --git a/src/manimgx/rendering/window.py b/src/manimgx/rendering/window.py
index 46947a43..1f4bc7c3 100644
--- a/src/manimgx/rendering/window.py
+++ b/src/manimgx/rendering/window.py
@@ -27,6 +27,8 @@ from warnings import deprecated
from manimgx import _engine
from manimgx.rendering.film import Cut
+__all__ = ["Window"]
+
class Window:
"""ManimGX's player in a window on this machine's screen, which plays the takes it is sent.
diff --git a/src/manimgx/scene.py b/src/manimgx/scene.py
index c997a42c..7cd4598b 100644
--- a/src/manimgx/scene.py
+++ b/src/manimgx/scene.py
@@ -12,10 +12,10 @@ from typing import TYPE_CHECKING, Literal, overload
from typing_extensions import TypedDict
-from manimgx.config import config
from manimgx.constants import DEGREES, DOWN, LEFT, OUT, RIGHT, UP
from manimgx.drawing.paint import ManimColor, ParsableManimColor
from manimgx.mobject import Mobject, ValueTracker
+from manimgx.settings import config
if TYPE_CHECKING:
from manimgx.animation.transform import Animate
@@ -643,7 +643,7 @@ class Scene:
Args:
video: The MP4 file to write, if any, at the size and frame rate of
- [`config`][manimgx.config.config] (a whole number of frames a second,
+ [`config`][manimgx.config] (a whole number of frames a second,
and an even width and height); its folder is made if it is missing.
preset: The x264 encoding preset; faster presets make larger files.
crf: The x264 constant rate factor, from 0 to 51; lower values give
@@ -1163,7 +1163,7 @@ class Scene:
It is handed `dt`, the scene time in seconds since it last ran (or was added),
at each instant the scene computes, after the updaters of the mobjects. It steps
as a mobject's time-based updater does: on the simulation clock
- ([`config.simulation_rate`][manimgx.config.Config.simulation_rate] ticks a
+ ([`config.simulation_rate`][manimgx.settings.Config.simulation_rate] ticks a
second, and the end of each play and wait), unless it is a
[flow][manimgx.mobject.flow], which runs at every frame. What it returns is
ignored.
@@ -1642,7 +1642,7 @@ class Scene:
```
"""
from manimgx.animation.timeline import AnimationGroup, Succession, Wait
- from manimgx.audio import spans, times
+ from manimgx.audio.sound import spans, times
text, found = spans(script)
if found and len(found) != len(animations):
@@ -1687,8 +1687,8 @@ class Scene:
voice: Voice | None = None
"""Who speaks the scene's [`say`][manimgx.Scene.say]: any
- [voice][manimgx.audio.Voice]; None for fal.ai's default model
- ([`Fal()`][manimgx.audio.fal.Fal])."""
+ [voice][manimgx.Voice]; None for fal.ai's default model
+ ([`Fal()`][manimgx.Fal])."""
def add_sound(
self,
diff --git a/src/manimgx/config.py b/src/manimgx/settings.py
similarity index 97%
rename from src/manimgx/config.py
rename to src/manimgx/settings.py
index c7b32efc..d0230a7b 100644
--- a/src/manimgx/config.py
+++ b/src/manimgx/settings.py
@@ -15,13 +15,15 @@ from manimgx import constants
from manimgx.drawing.paint import BLACK, ManimColor, ParsableManimColor
from manimgx.typing import Point3D, Vector3D
+__all__ = ["Degrees", "Munits", "Percent", "Pixels", "config"]
+
@dataclass
class Config:
"""The configuration scenes are made and rendered with: the video's size, frame rate
and background, and the frame's size in scene units.
- There is one, [`config`][manimgx.config.config]. Set its fields before making a
+ There is one, [`config`][manimgx.config]. Set its fields before making a
scene: a scene's camera, and the mobjects that fill the frame, take their sizes and
the background from it when they are made, and [`render`][manimgx.Scene.render]
takes the video's size and frame rate when it starts. It can be read and set as a
@@ -173,7 +175,7 @@ class Config:
config = Config()
"""The configuration every scene is made and rendered with, as `m.config`: a
-[`Config`][manimgx.config.Config]. Set its fields before making a scene:
+[`Config`][manimgx.settings.Config]. Set its fields before making a scene:
`m.config.pixel_width, m.config.pixel_height = 1280, 720`."""
diff --git a/tests/benchmarks/test_laws.py b/tests/benchmarks/test_laws.py
index 32800dc7..de18b307 100644
--- a/tests/benchmarks/test_laws.py
+++ b/tests/benchmarks/test_laws.py
@@ -48,8 +48,8 @@ from tests.strategies import MOBJECTS, angles
import manimgx as m
from manimgx import caches
from manimgx.animation import clock
-from manimgx.config import config
from manimgx.drawing.geometry import bezier_remap
+from manimgx.settings import config
SLACK = 0.1
"""A law's allowance over proportion, for what a thing's fixed costs and manimgx's memories
diff --git a/tests/conftest.py b/tests/conftest.py
index 0ef05eb5..77b9c9e8 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -21,7 +21,7 @@ from hypothesis import HealthCheck, Phase, settings
from manimgx import caches
from manimgx.animation import clock
-from manimgx.config import config
+from manimgx.settings import config
settings.register_profile(
"default", deadline=None
diff --git a/tests/integration/corpus/run_manimgx.py b/tests/integration/corpus/run_manimgx.py
index cf337dc1..b149193d 100644
--- a/tests/integration/corpus/run_manimgx.py
+++ b/tests/integration/corpus/run_manimgx.py
@@ -27,8 +27,8 @@ from tests.integration.corpus.frames import Comparison, Difference, Movie, Recor
from tests.integration.corpus.runtime import load, seed, the_scene, write_result
import manimgx
-from manimgx.config import Config, config
from manimgx.rendering.film import Frame
+from manimgx.settings import Config, config
def render(
diff --git a/tests/integration/test_banner.py b/tests/integration/test_banner.py
index 627ed4c7..cb0a0937 100644
--- a/tests/integration/test_banner.py
+++ b/tests/integration/test_banner.py
@@ -20,7 +20,7 @@ import pytest
from tests import scenes
import manimgx as m
-from manimgx.config import config
+from manimgx.settings import config
type Direction = Literal["left", "right", "center"]
type Place = tuple[float, float, float] # scale, then shift x, y
diff --git a/tests/integration/test_drawing.py b/tests/integration/test_drawing.py
index 947d1426..4f6013ee 100644
--- a/tests/integration/test_drawing.py
+++ b/tests/integration/test_drawing.py
@@ -24,8 +24,8 @@ import pytest
from tests import oracles, scenes
import manimgx as m
-from manimgx.config import config
from manimgx.constants import Resampling
+from manimgx.settings import config
W, H = 640, 360
WIDTH = 40 # stroke width: h = 0.2 units
diff --git a/tests/integration/test_film.py b/tests/integration/test_film.py
index 70d0b6b3..346702f3 100644
--- a/tests/integration/test_film.py
+++ b/tests/integration/test_film.py
@@ -9,9 +9,9 @@ from typing import cast
import pytest
import manimgx as m
-from manimgx.config import config
from manimgx.rendering import feed
from manimgx.rendering.film import Cut, Film, Frame, X264Preset
+from manimgx.settings import config
class Held(m.Scene):
diff --git a/tests/integration/test_perspective.py b/tests/integration/test_perspective.py
index 8d616702..b3940536 100644
--- a/tests/integration/test_perspective.py
+++ b/tests/integration/test_perspective.py
@@ -10,7 +10,7 @@ import pytest
from tests import scenes
import manimgx as m
-from manimgx.config import config
+from manimgx.settings import config
SIZE = (320, 180)
pytestmark = pytest.mark.config(pixel_width=SIZE[0], pixel_height=SIZE[1])
diff --git a/tests/integration/test_reveal.py b/tests/integration/test_reveal.py
index 7a013e45..03eba2af 100644
--- a/tests/integration/test_reveal.py
+++ b/tests/integration/test_reveal.py
@@ -16,8 +16,8 @@ import numpy as np
import pytest
import manimgx as m
-from manimgx.config import config
from manimgx.rendering.film import Frame
+from manimgx.settings import config
W, H = 640, 360
diff --git a/tests/integration/test_sound.py b/tests/integration/test_sound.py
index e927240f..0a672928 100644
--- a/tests/integration/test_sound.py
+++ b/tests/integration/test_sound.py
@@ -18,8 +18,8 @@ import pytest
import manimgx as m
from manimgx._engine import decode_audio, resample_audio
from manimgx.audio.sound import RATE
-from manimgx.config import config
from manimgx.rendering.film import X264Preset
+from manimgx.settings import config
def impulse() -> m.Sound:
diff --git a/tests/integration/test_time.py b/tests/integration/test_time.py
index f06d3817..0b789bbb 100644
--- a/tests/integration/test_time.py
+++ b/tests/integration/test_time.py
@@ -18,9 +18,9 @@ import pytest
import manimgx as m
from manimgx.animation import clock
-from manimgx.config import config
from manimgx.mobject import flow
from manimgx.scene import Act
+from manimgx.settings import config
type Story = Callable[[Probe], None]
type Trajectory = Callable[[Fraction], Fraction]
diff --git a/tests/scenes.py b/tests/scenes.py
index 18297f36..c95f8581 100644
--- a/tests/scenes.py
+++ b/tests/scenes.py
@@ -22,11 +22,11 @@ from hypothesis import strategies as st
import manimgx as m
from manimgx.animation import easing as rf
-from manimgx.config import config
from manimgx.drawing.geometry import bezier_remap
from manimgx.drawing.paint import Paint
from manimgx.rendering.film import Frame
from manimgx.scene import _tracks
+from manimgx.settings import config
if TYPE_CHECKING:
from manimgx.animation.transform import Transform
diff --git a/tests/unit/audio/test_fal.py b/tests/unit/audio/test_fal.py
index b0046fd2..4a9e85e1 100644
--- a/tests/unit/audio/test_fal.py
+++ b/tests/unit/audio/test_fal.py
@@ -25,8 +25,8 @@ from hypothesis import strategies as st
import manimgx as m
from manimgx.audio import fal
-from manimgx.audio import sound as voices
from manimgx.audio.fal import Fal
+from manimgx.audio.sound import _identity, _wav
AUDIO_URL = "https://v3b.fal.media/files/b/speech.wav"
SECOND_TENTH = 4800 # samples: a tenth of a second at the film's rate
@@ -50,7 +50,7 @@ class Service:
) -> bytes:
self.asked.append((url, body, headers))
if body is None:
- return voices._wav(np.full((SECOND_TENTH, 1), 0.1, np.float32))
+ return _wav(np.full((SECOND_TENTH, 1), 0.1, np.float32))
return json.dumps({"audio": {"url": AUDIO_URL}, **self.reply}).encode()
@property
@@ -142,14 +142,14 @@ class TestNaming:
other = data.draw(settings_of(model), label="other settings")
voice = untyped(model, key=key, **settings)
again = untyped(model, **written_otherwise(settings))
- assert voices._identity(voice) == voices._identity(again)
+ assert _identity(voice) == _identity(again)
assert repr(voice) == repr(again)
assert voice == again
same = json.dumps(other, sort_keys=True) == json.dumps(settings, sort_keys=True)
- named = voices._identity(untyped(model, **other))
- assert (named == voices._identity(voice)) == same
+ named = _identity(untyped(model, **other))
+ assert (named == _identity(voice)) == same
for another in fal._MODELS.keys() - {model}:
- assert voices._identity(Fal(another)) != voices._identity(voice)
+ assert _identity(Fal(another)) != _identity(voice)
class TestTiming:
diff --git a/tests/unit/audio/test_sound.py b/tests/unit/audio/test_sound.py
index 7af43fd3..ca05b31b 100644
--- a/tests/unit/audio/test_sound.py
+++ b/tests/unit/audio/test_sound.py
@@ -1,4 +1,4 @@
-"""Sound placement and edits, and speech timing, captions and voices."""
+"""Sound placement and edits, and speech timing, captions and sound."""
import re
import unicodedata
@@ -14,14 +14,15 @@ from hypothesis import strategies as st
import manimgx as m
from manimgx.animation import clock
-from manimgx.audio import sound as voices
from manimgx.audio.sound import (
CUT,
RATE,
Clip,
Speech,
Word,
+ _identity,
_pieces,
+ _wav,
cached,
estimate,
lines,
@@ -30,7 +31,7 @@ from manimgx.audio.sound import (
timed,
times,
)
-from manimgx.config import config
+from manimgx.settings import config
def tone(seconds: float = 0.1, level: float = 0.5) -> m.Sound:
@@ -542,7 +543,7 @@ class TestSay:
@pytest.mark.parametrize("speaker", [spelled, untimed], ids=["timed", "estimated"])
def test_an_animation_starts_on_its_character_in_text_without_spaces(
- self, speaker: voices.Voice
+ self, speaker: m.Voice
) -> None:
begun: list[Fraction] = []
spoken: list[Speech] = []
@@ -578,7 +579,7 @@ class TestVoice:
@pytest.mark.usefixtures("cache_here")
class TestCache:
def test_function_identity_keeps_code_but_not_source_locations(self) -> None:
- def voice(source: str, filename: str) -> voices.Voice:
+ def voice(source: str, filename: str) -> m.Voice:
scope: dict[str, object] = {
"__name__": "recorded_voice",
"speak": said,
@@ -586,20 +587,17 @@ class TestCache:
"second_speaker": said,
}
exec(compile(source, filename, "exec"), scope)
- return cast("voices.Voice", scope["voice"])
+ return cast("m.Voice", scope["voice"])
source = (
"def voice(text):\n return speak(' '.join(w for w in text.split()))\n"
)
- original = voices._identity(voice(source, "first.py"))
- assert voices._identity(voice("\n\n" + source, "second.py")) == original
- assert (
- voices._identity(voice(source.replace("' '", "'_'"), "first.py"))
- != original
- )
+ original = _identity(voice(source, "first.py"))
+ assert _identity(voice("\n\n" + source, "second.py")) == original
+ assert _identity(voice(source.replace("' '", "'_'"), "first.py")) != original
first = "def voice(text):\n return first_speaker(text)\n"
second = first.replace("first_speaker", "second_speaker")
- assert voices._identity(voice(first, "voice.py")) != voices._identity(
+ assert _identity(voice(first, "voice.py")) != _identity(
voice(second, "voice.py")
)
@@ -608,7 +606,7 @@ class TestCache:
self, kind: str, cache_here: Path, tmp_path: Path
) -> None:
samples = np.linspace(-0.5, 0.5, RATE, dtype=np.float32)
- audio = voices._wav(samples)
+ audio = _wav(samples)
path = tmp_path / "source.wav"
path.write_bytes(audio)
@@ -664,7 +662,7 @@ class TestCache:
silence_then_sound = np.concatenate(
[np.zeros(RATE, np.float32), np.full(RATE, 0.5, np.float32)]
)
- audio.write_bytes(voices._wav(silence_then_sound[:, None]))
+ audio.write_bytes(_wav(silence_then_sound[:, None]))
again = cached(said, "hello there", cache_here)
assert again.words[0].start >= 0.9 # estimated from the recording, not kept
@@ -676,8 +674,8 @@ class TestCache:
return voice
slow, fast, again = speaking(1.0), speaking(1.5), speaking(1.0)
- assert voices._identity(slow) != voices._identity(fast)
- assert voices._identity(slow) == voices._identity(again)
+ assert _identity(slow) != _identity(fast)
+ assert _identity(slow) == _identity(again)
class Called: # a callable object: named by its fields, not its address
def __init__(self, voice_id: str) -> None:
@@ -686,8 +684,8 @@ class TestCache:
def __call__(self, text: str) -> Speech:
return said(text)
- assert voices._identity(Called("a")) == voices._identity(Called("a"))
- assert voices._identity(Called("a")) != voices._identity(Called("b"))
+ assert _identity(Called("a")) == _identity(Called("a"))
+ assert _identity(Called("a")) != _identity(Called("b"))
@pytest.mark.usefixtures("cache_here")
diff --git a/tests/unit/cli/test_scenes.py b/tests/unit/cli/test_scenes.py
index c1167f99..5ad5e20f 100644
--- a/tests/unit/cli/test_scenes.py
+++ b/tests/unit/cli/test_scenes.py
@@ -8,7 +8,7 @@ from pathlib import Path
import pytest
from manimgx.cli.scenes import load, report_error, scene
-from manimgx.config import Config, config
+from manimgx.settings import Config, config
def test_scene_edits_are_read_even_when_bytecode_metadata_matches(
diff --git a/tests/unit/rendering/test_film.py b/tests/unit/rendering/test_film.py
index ad969b3b..7c7214d1 100644
--- a/tests/unit/rendering/test_film.py
+++ b/tests/unit/rendering/test_film.py
@@ -19,8 +19,8 @@ from hypothesis import strategies as st
import manimgx as m
from manimgx.audio import Speech, Word
from manimgx.audio.sound import RATE
-from manimgx.config import config
from manimgx.rendering.film import Frame
+from manimgx.settings import config
def film_of(
diff --git a/tests/unit/test_config.py b/tests/unit/test_settings.py
similarity index 99%
rename from tests/unit/test_config.py
rename to tests/unit/test_settings.py
index a59bfa7f..ed02420d 100644
--- a/tests/unit/test_config.py
+++ b/tests/unit/test_settings.py
@@ -19,7 +19,7 @@ from hypothesis import given
from hypothesis import strategies as st
import manimgx as m
-from manimgx.config import Config
+from manimgx.settings import Config
pixels = st.integers(16, 4096)
diff --git a/tests/unit/test_typing.py b/tests/unit/test_typing.py
index e50e45d4..c8365693 100644
--- a/tests/unit/test_typing.py
+++ b/tests/unit/test_typing.py
@@ -9,15 +9,21 @@
methods there as the mobject's.
- Mutable mappings and numbers retain their key and value types through construction,
updates, and animation proxies.
+- A package's names are those its modules declare in `__all__`, each once, so ty and
+ `from manimgx import *` find the same names, and no module or undeclared name among them.
"""
import importlib
import re
from pathlib import Path
+from types import ModuleType
+import pytest
from tests.typecheck import check
from typing_extensions import is_typeddict
+import manimgx
+
PACKAGE = Path(__file__).parents[2] / "src" / "manimgx"
@@ -232,3 +238,38 @@ def test_real_tracker_construction_cannot_claim_complex_storage(tmp_path: Path)
encoding="utf-8",
)
assert [line for _, line, _, _ in check([source])] == [2, 3, 5]
+
+
+ "package",
+ [
+ manimgx,
+ manimgx.animation,
+ manimgx.audio,
+ manimgx.drawing,
+ manimgx.mobjects,
+ manimgx.rendering,
+ ],
+ ids=lambda package: package.__name__,
+)
+def test_a_package_gives_exactly_the_names_it_declares(package: ModuleType) -> None:
+ public = {
+ name
+ for name, value in vars(package).items()
+ if not name.startswith("_") and not isinstance(value, ModuleType)
+ }
+ assert len(set(package.__all__)) == len(package.__all__)
+ assert set(package.__all__) == public
+
+
+def test_ty_finds_every_name_of_the_package_through_its_star_import(
+ tmp_path: Path,
+) -> None:
+ scene = tmp_path / "scene.py"
+ scene.write_text(
+ "from manimgx import *\n\n"
+ + "".join(f"_ = {name}\n" for name in manimgx.__all__),
+ encoding="utf-8",
+ )
+ # deprecated names say so, and nothing else is reported
+ assert set(_ty(scene).values()) <= {"deprecated"}