* Add support for negative z-index in AnimationGroup
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Refactor animation unpacking logic for clarity
* Fix unpacking logic to handle Mobject instances correctly
* Fix mypy check
* Fix tests
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* fix: simplify AnimationGroup unpacking for moving mobjects
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Benjamin Hackl <devel@benjamin-hackl.at>
* Small touch-ups before fixing tip bugs
- fixed mutable default argument in Tipable VMobject constructor
- fixed typo in method name assign_tip_attr
- added two todo's which outline unexpected behavior in tip placement and how to solve
* refactor: align tip attr naming and remove TODO comments
---------
Co-authored-by: Benjamin Hackl <devel@benjamin-hackl.at>
* fixing #4591
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* ci: fix publish release workflow
- Add sudo to apt-get calls (runner is non-root)
- Add contents: write permission for uploading release assets
- Drop uv sync before uv build (unnecessary)
- Replace archived upload-release-asset action and redundant
Python/requests API script with gh release upload; tag name
is available directly from the release event context
- Strip leading v from tag name to match built artifact filename
* ci: set bash shell for release asset upload step
* fix: replace double-brace splitting regex with state-machine parser
The previous re.split(r'{{|}}', ...) call split on any occurrence of
{{ or }} in the input string, which broke strings whose only }} came
from closing two nested LaTeX brace groups (e.g. ^{\frac{Mq}{M+m}}).
The new _split_double_braces() static method uses a character-level
state machine with three guards:
* Escape priority: \\ is consumed before \{ / \}, so \\}} is
correctly read as an escaped backslash followed by a real }}, not
misinterpreted as \ + \} + lone }.
* Whitespace-gated opener: {{ is only treated as a Manim group opener
at the start of the string or after whitespace. Naturally-occurring
{{ in LaTeX is usually preceded by non-whitespace (e.g. \frac{{{n}}}
or a^{{2}}), so this eliminates the most common false positives.
* Depth-tracking closer: inside a Manim group, }} only closes the
group when the inner brace depth is zero, so {{ a^{b^{c}} }} is
handled correctly and nested LaTeX }} cannot trigger an early close.
Fixes#4601.
* docs: document double-brace whitespace requirement
Add a Notes section to the MathTex docstring explaining:
- how {{ }} splits a string into submobjects
- that {{ must be at start-of-string or preceded by whitespace
- that this leaves natural LaTeX like \frac{{{n}}}{k} untouched
- the { { ... } } escape hatch when a split is not wanted
Apply the same explanation to the double-brace paragraph in
docs/source/guides/using_text.rst.
* fix: use r-string for _split_double_braces docstring, halve backslash escaping
* fix: resolve parameter shadowing bug in release script changelog command
* chore: bump version to v0.20.0, regenerate lockfile, update citation
* generate v0.20.0 changelog, first round
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* a bit of copyediting, second pass
* include newly merged PR, apply suggestions from review
* Update docs/source/changelog/0.20.0-changelog.md
Co-authored-by: Francisco Manríquez Novoa <49853152+chopan050@users.noreply.github.com>
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Francisco Manríquez Novoa <49853152+chopan050@users.noreply.github.com>
When a single flat list or 1D numpy array was passed to
`Axes.coords_to_point()` (e.g. `ax.c2p([1, 2])` or
`ax.c2p(np.array([1, 2, 1]))`), the values were incorrectly
interpreted as multiple x-coordinates instead of a single (x, y) or
(x, y, z) point.
This happened because `np.asarray(([1, 2],))` produces a 2D array
with shape (1, N), which fell through to the code path that treats
`coords[0]` as a list of x-values. The fix detects this case
(ndim == 2, shape[0] == 1) and extracts the inner array so it is
handled identically to `c2p(1, 2)`.
Closes ManimCommunity#4073
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
* Add type annotations to point_cloud_mobject.py
* Make reset_points return Self instead of None
* Fix return type of get_array_attrs()
* Change return type of reset_points() to Self in image_mobject.py
* Fix 3D ImageMobject rotation
* Remove lanczos, box and hamming resampling algorithms
* Consider case where matrix A is singular (points are aligned)
* homographic_matrix -> homography_matrix
* Fix ImageInterpolationEx scene and increase height in ImageInterpolation test
* Regenerate unit test again
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* ManimFloat should probably not be used as dtype
* Import ImageMobject inside TYPE_CHECKING
* Add Camera.points_to_subpixel_coords() and do not render perpendicular images
* Modify algorithm to use height from longest side
* Prevent possible zero division
* Regenerate ImageMobject.npz
* Edit Image.transform() commentary
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Benjamin Hackl <devel@benjamin-hackl.at>
* Extracted the method get_mob_from_shape_element
* Moved more functionality to get_mob_from_shape_element
* More cleanup
* Parse the svg file while maintaining the group structure.
* Make the svg groups available
* Handle PERF401 issue
* [pre-commit.ci] pre-commit autoupdate (#4506)
updates:
- [github.com/astral-sh/ruff-pre-commit: v0.14.7 → v0.14.8](https://github.com/astral-sh/ruff-pre-commit/compare/v0.14.7...v0.14.8)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Added an example of the issue
* Experimenting with coloring elements from the latex equation
* ...
* Regular expression can now match more than one object
* Process the string by applying the substrings in the order they match
* Code refactoring and added type annotations
* ...
* Added a lot of test cases
* More examples
* More examples
* Use matched_strings_and_ids to simplify existing methods
* Remove unused code
* Update get_part_by_tex to use matched_strings_and_ids
* This is required for test_MathTable to pass
* Ensure that self.texstring is set.
* Added more examples from exising issues in the github repo
* Ensure that latex groups are maintained by adding an additional pair of curly braces around the extracted part
* ExampleScene -> Scene
* Added comment
* _break_up_by_substrings
* Refactor code
* Added comment to example
* Handle integer inputs well.
* Expose the original tex_string
* Do not treat the content of substrings_to_isolate as regular expressions.
* Updated examples
* Update examples
* Fix SVMobject caching issue.
* Remove traces from brace_notation_split_occurred
* Simplify MathTex::_break_up_by_substrings
* Fix small issue in tex that in some cases moved elements a tiny bit around
* No use of regular expressions for locate substrings.
* Updated notes to the set of test cases
* Handle issues with the center environment.
* Add example
* Fix issue with rectangles (e.g. from sqrt)
* ConvertToOpenGL
* Reduce the number of nesting levels.
* Use the specified arg_seperator
* Deal with the double curly brace markup
* Code cleanup
* Code cleanup
* Rollback a few changes
* Code cleanup
* Adjust paths the generated artefacts in tests that rely on MathTex
* Added a remark to the using text guide on enclosing snippets in curly braces for substrings_to_isolate to work
* Added space around the numerator argument to frac to avoid having double curly braces in the example.
This would otherwise trigger MathTex to split the string at that location.
* Log errors properly and display some information about the errors and their context.
* Code refactoring as suggested by Benjamin
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Benjamin Hackl <devel@benjamin-hackl.at>
* sub_alphas is derived directly from to_update so they're guaranteed to be of the same length.
* self.shapes is initialised as a direct copy of the mobject, guaranteed to be of same length.
* linspace in this case guarantees both arrays are of equal size (self.n_segments).
* Any transformation already requires that each datapoint in the first tuple has a corresponding datapoint in the second (ie same length)
* Replaced arange with linspace, eliminates risk of floating point errors and forces rgbas and offset to be the same size for strict=True
* all_arc_configs is either defined specifically by length of point_pairs or strictly forced to be the same length (n). In any case they'll always be the same length so strict=True works.
* There should always be an equal amount of start and end anchors; radius_list is defined directly from the length of vertex_group; both outer_vertices and inner_vertices posess n vertices.
* boundary_times always contains has an even length so both 'slices' in the zup function are the same length.
* colors_in_gradient is defined to be the same length as p_list_complete; labels and parts are seemingly user inputs with no guarantee of equal length; val_range is defined to be same lenght as self.bar_names; however there's no authentication that self.values has a fixed length after it's been defined ie user can append to the list creating a mismatch between len(self.values) and len(self.bars)
* In most cases here, the tuples are either defined to be of same length or manipulated to be by the align_data function. In the match_points function there is currently no validation to ensure both mobjects are the same length.
* Reverting _add_x_axis_labels() zip() function back
to strict=False due to failing test cases
* Reverted strict zip usage
* color_gradient is defined to be same length as p_list_complete & within _add_x_axis_labels we define val_range to be the same length as self.bar_names
* align_data and lock_matching_data have no validation to ensure tuples in the zip() function are of the same length. Every other time zip() is used here it is generally immediately manipulating or explicitly defining the tuples to be of same length
* All tuples in zip() functions here are either clearly the same size or manipulated to be the same size using the make_even function.
* The tuples in the zip() function will clearly be of equal length, the second tuple is simply a cyclic shift of the first.
* In the ingest_submobjects function arrays is a one to one mapping of attrs so they are guaranteed to have equal lengths.
* Every usage of zip() consists of tuples that are either manipulated to be equal size or defined to be equal size.
* the zip() function in bezier_remap will always consist of equal length tuples as current_number_of_curves is read directly from the shape of bezier_tuples and is used to dictate the size of split_factors.
* The zip() function color_gradient() will always consist of equal length tuples as floors is defined directly from alphas (which also defines alphas_mod1)
* The tuples in the zip() function in adjacent_n_tuples will always be the same length so strict=True.
* The find_intersection() contains a zip() function that has been set to strict=True. While it is technically possible to pass tuples to this function that are *not* the same length, this would result in generally unexpected behaviour anyway.
* Changed zip() function to have strict=True in __init__() as custom_labels is dependent on tick_range so guaranteed to have the same length.
* Several instances of zip() set to strict=True. In add_coordinates we have axis manipulated to be the same length as tick_range. In get_riemann_rectangles() we have colors dependent on of x_range_Array forcing them to be the same length. Finally in plot_line_graph() it is clearly intended that all inputs used in the zip() function are of the same length (except possibly z which may not exist and will be made equal length to x); while it is not guaranteed they will be the same length this would cause unintended behaviour.
* zip() function bool changed to strict=True in all these test cases. Most test cases either a) hardcode two things to be the same length, b) verify things are the same length before the function or c) explicitly exist to check whether two things are the same length.
* Add py.typed to declare manim as having type hints
This tells tools like Pyright that this package has its own type hints and it should try to look for them in typeshed.
Fixes#4552
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* type annotations and docs for opengl_renderer.py
* add missing self
* Fix RTD build: move Window import to TYPE_CHECKING block
The Window import was moved to module-level in a recent type annotation
commit, but this causes opengl_renderer_window.py to be imported at
load time, triggering pyglet which fails on headless systems (RTD) when
it tries to create a shadow window. Moving the import into TYPE_CHECKING
preserves type hints for mypy while avoiding runtime display dependency.
* Fix mypy errors in opengl_renderer.py
- Cast np.linalg.inv() result to correct type
- Convert quaternion list to ndarray before passing to rotation_matrix_transpose_from_quaternion
- Cast get_center return value
- Fix return type for pixel_coords_to_space_coords (ensure float dtype)
- Add type: ignore for moderngl.create_context backend arg (incorrect stubs)
- Add type: ignore for blend_func assignment (incorrect stubs)
* Fix mypy errors and runtime import issues in opengl_renderer.py
- Import MatrixMN and Point3D at runtime (needed for typing.cast)
- Cast np.linalg.inv() result to correct MatrixMN type
- Convert quaternion list to ndarray before passing to rotation_matrix_transpose_from_quaternion
- Cast get_center and pixel_coords_to_space_coords return values to Point3D
- Ensure float dtype in np.array literals for type consistency
* Add runtime import of Window in init_scene
The Window class is imported inside TYPE_CHECKING for type hints, but
needs to be imported at runtime when actually creating a window. This
import is deferred to avoid triggering pyglet display initialization
on headless systems (RTD build).
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---------
Co-authored-by: Benjamin Hackl <devel@benjamin-hackl.at>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* fix: infinite recursion caused by accessing color of a highlighted Table cell.
fix: removed type: ignore[attr-defined] mypy was not a fan of
* fix: added back needed mypy type ignore
* Add regression tests for Table/BackgroundRectangle color access
Tests for infinite recursion issue fixed in PR #4435 (issue #4419).
Refs: #4419
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Refactor BackgroundRectangle color test to geometry tests
Move test_background_rectangle_color from test_table.py to
test_unit_geometry.py since BackgroundRectangle lives in
geometry/shape_matchers.py, not in tables.
Regression test for ManimCommunity/manim#4419 (infinite recursion
when accessing BackgroundRectangle.color)
* Fix: Added missing manim GREEN import needed for test_BackgroundRectangle_color_access()
---------
Co-authored-by: Henrik Skov Midtiby <hemi@mmmi.sdu.dk>
Co-authored-by: Benjamin Hackl <mail@behackl.dev>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: bhearr <None>
* fill_color --> color for MathTeX
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Benjamin Hackl <devel@benjamin-hackl.at>
* feat: 'seed' option for reproducible outputs
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* enh: let Scene automatically pick global random seed, use arg as override
* chore: move import slightly
* chore: add test for color generator being reproducible with global config seed
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Benjamin Hackl <devel@benjamin-hackl.at>
* fix: correct Circle.point_at_angle calculation for accurate arc mapping
* chore: remove unused variable 'start_angle' to fix pre-commit CI
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* test: add test for Circle.point_at_angle()
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Henrik Skov Midtiby <hemi@mmmi.sdu.dk>
Co-authored-by: Benjamin Hackl <devel@benjamin-hackl.at>
Co-authored-by: Benjamin Hackl <mail@behackl.dev>