From e53a1c8d6f14b77f389f79126f77bbcc48e6f869 Mon Sep 17 00:00:00 2001 From: Sir James Clark Maxwell <71722499+SirJamesClarkMaxwell@users.noreply.github.com> Date: Mon, 1 Apr 2024 17:59:07 +0200 Subject: [PATCH 01/12] docs: improve installation FAQ's --- docs/source/faq/installation.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/docs/source/faq/installation.md b/docs/source/faq/installation.md index c60044b66a..482125c04c 100644 --- a/docs/source/faq/installation.md +++ b/docs/source/faq/installation.md @@ -1,6 +1,7 @@ # FAQ: Installation (different-versions)= + ## Why are there different versions of Manim? Manim was originally created by Grant Sanderson as a personal project and for use @@ -20,6 +21,7 @@ Grant's old videos locally on your machine. It is still available in his GitHub repository in form of the `cairo-backend` branch. To summarize: + - [**Manim**, or **ManimCE**](https://manim.community) refers to the community maintained version of the library. This is the version documented on this website; the package name on PyPI is [`manim`](https://pypi.org/project/manim/). @@ -102,6 +104,17 @@ creator whose guide you have been watching has made a more recent version availa and otherwise please contact them directly. Asking for help in the community will likely lead to being suggested to follow our written guide. +## Windows problem with installation process + +If you are a Windows user, what you could try, from a helper point of view is, working in 99% of cases: + +1. Ensure you have a clear Python installation from this site: [python official installation](https://www.python.org/downloads/). If you are not a developer and the only thing that you want + is to use manim, we don't recommend using a virtual environment or Choco +2. Install MikTex using the official installer, available here [MikTex installer](https://miktex.org/download). It is an optional step if you want to use the LaTeX in manim. +3. Run `pip install manim` +4. Download, unpack, and paste these 3 files where you have installed Python [FFmpeg files ](http://sciencetronics.com/download/ffmpeg.zip)(in the installation process, you had to specify the path). Check the `Scripts` directory. These files should be pasted there. +5. Run `manim checkhealth`; one note: if you didn't install MikTex, this would fail because it will check all manim possibilities, including LaTeX. + --- ## Why does ManimPango fail to install when running `pip install manim`? @@ -153,7 +166,7 @@ your problem. See the {doc}`FAQ on getting help ` for instructions. Yes: you can remove these aliases with these steps: 1. Go to the Windows Setting. -2. Under *Apps and Features* you will find application execution aliases. +2. Under _Apps and Features_ you will find application execution aliases. 3. Within this menu, disable the alias(es) that are causing the issue (`python` and/or `python3`). From c7ebc5c7f666c84c0a50fb29988964dc3d610f23 Mon Sep 17 00:00:00 2001 From: Sir James Clark Maxwell <71722499+SirJamesClarkMaxwell@users.noreply.github.com> Date: Thu, 4 Apr 2024 23:24:25 +0200 Subject: [PATCH 02/12] I have potentially resolved the issue when in LinearTransformationScene between two animations of transforming space we invoke the self.wait() --- LinearTransformBug.py | 27 +++++++++++++++++++++++++++ manim/scene/vector_space_scene.py | 21 +++++++++++++-------- 2 files changed, 40 insertions(+), 8 deletions(-) create mode 100644 LinearTransformBug.py diff --git a/LinearTransformBug.py b/LinearTransformBug.py new file mode 100644 index 0000000000..cccc5951f3 --- /dev/null +++ b/LinearTransformBug.py @@ -0,0 +1,27 @@ +from manim import * +import os + + +class Test(LinearTransformationScene): + def construct(self): + matrix = [[3, 0], [1, -1]] + + self.add_unit_square() + c = Circle(radius=0.5) + self.add_moving_mobject(c) + self.apply_matrix(matrix) + self.wait() + self.apply_inverse(matrix) + + +class Test2(LinearTransformationScene): + def construct(self): + t = Text("Hello World!") + self.play(Write(t)) + self.wait() + self.play(Unwrite(t)) + + +if __name__ == "__main__": + with tempconfig({"quality": "low_quality", "preview": True}): + Test().render() diff --git a/manim/scene/vector_space_scene.py b/manim/scene/vector_space_scene.py index d39ce32895..fcaa0ed3e9 100644 --- a/manim/scene/vector_space_scene.py +++ b/manim/scene/vector_space_scene.py @@ -1000,17 +1000,21 @@ def get_piece_movement(self, pieces: list | tuple | np.ndarray): Returns ------- - Animation + Animation` The animation of the movement. """ - start = VGroup(*pieces) - target = VGroup(*(mob.target for mob in pieces)) + + v_pieces = [piece for piece in pieces if isinstance(piece, VMobject)] + start = VGroup(*v_pieces) + target = VGroup(*(mob.target for mob in v_pieces)) # don't add empty VGroups - if self.leave_ghost_vectors and start.submobjects: - # start.copy() gives a VGroup of Vectors - self.ghost_vectors.add(start.copy().fade(0.7)) - self.add(self.ghost_vectors[-1]) - return Transform(start, target, lag_ratio=0) + if v_pieces: + if self.leave_ghost_vectors and start.submobjects: + # start.copy() gives a VGroup of Vectors + self.ghost_vectors.add(start.copy().fade(0.7)) + self.add(self.ghost_vectors[-1]) + return Transform(start, target, lag_ratio=0) + return [] def get_moving_mobject_movement(self, func: Callable[[np.ndarray], np.ndarray]): """ @@ -1091,6 +1095,7 @@ def apply_matrix(self, matrix: np.ndarray | list | tuple, **kwargs): **kwargs Any valid keyword argument of self.apply_transposed_matrix() """ + self.apply_transposed_matrix(np.array(matrix).T, **kwargs) def apply_inverse(self, matrix: np.ndarray | list | tuple, **kwargs): From 5827a9a2273a6d67e2cd59af2c6a18a8b47c1310 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 4 Apr 2024 23:11:06 +0000 Subject: [PATCH 03/12] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- LinearTransformBug.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/LinearTransformBug.py b/LinearTransformBug.py index cccc5951f3..e52edb1537 100644 --- a/LinearTransformBug.py +++ b/LinearTransformBug.py @@ -1,6 +1,7 @@ -from manim import * import os +from manim import * + class Test(LinearTransformationScene): def construct(self): From 8b4b14fbb5707d21eb5f1c50953201e23587b2ac Mon Sep 17 00:00:00 2001 From: Sir James Clark Maxwell <71722499+SirJamesClarkMaxwell@users.noreply.github.com> Date: Fri, 5 Apr 2024 12:09:47 +0200 Subject: [PATCH 04/12] added another solutions in comments, added tests and removed wrong files from git --- LinearTransformBug.py | 28 ------------------- manim/scene/vector_space_scene.py | 20 +++++++------ .../test_graphical_units/test_vector_scene.py | 10 +++++++ 3 files changed, 22 insertions(+), 36 deletions(-) delete mode 100644 LinearTransformBug.py diff --git a/LinearTransformBug.py b/LinearTransformBug.py deleted file mode 100644 index e52edb1537..0000000000 --- a/LinearTransformBug.py +++ /dev/null @@ -1,28 +0,0 @@ -import os - -from manim import * - - -class Test(LinearTransformationScene): - def construct(self): - matrix = [[3, 0], [1, -1]] - - self.add_unit_square() - c = Circle(radius=0.5) - self.add_moving_mobject(c) - self.apply_matrix(matrix) - self.wait() - self.apply_inverse(matrix) - - -class Test2(LinearTransformationScene): - def construct(self): - t = Text("Hello World!") - self.play(Write(t)) - self.wait() - self.play(Unwrite(t)) - - -if __name__ == "__main__": - with tempconfig({"quality": "low_quality", "preview": True}): - Test().render() diff --git a/manim/scene/vector_space_scene.py b/manim/scene/vector_space_scene.py index fcaa0ed3e9..b804be3551 100644 --- a/manim/scene/vector_space_scene.py +++ b/manim/scene/vector_space_scene.py @@ -1000,21 +1000,25 @@ def get_piece_movement(self, pieces: list | tuple | np.ndarray): Returns ------- - Animation` + Animation The animation of the movement. """ v_pieces = [piece for piece in pieces if isinstance(piece, VMobject)] start = VGroup(*v_pieces) target = VGroup(*(mob.target for mob in v_pieces)) + # NOTE other possible solution: + """ + start = Group(*pieces) + target = Group(*(mob.target for mob in pieces)) + """ + # N # don't add empty VGroups - if v_pieces: - if self.leave_ghost_vectors and start.submobjects: - # start.copy() gives a VGroup of Vectors - self.ghost_vectors.add(start.copy().fade(0.7)) - self.add(self.ghost_vectors[-1]) - return Transform(start, target, lag_ratio=0) - return [] + if self.leave_ghost_vectors and start.submobjects: + # start.copy() gives a VGroup of Vectors + self.ghost_vectors.add(start.copy().fade(0.7)) + self.add(self.ghost_vectors[-1]) + return Transform(start, target, lag_ratio=0) def get_moving_mobject_movement(self, func: Callable[[np.ndarray], np.ndarray]): """ diff --git a/tests/test_graphical_units/test_vector_scene.py b/tests/test_graphical_units/test_vector_scene.py index 59dfda44a9..4bf4c92f7f 100644 --- a/tests/test_graphical_units/test_vector_scene.py +++ b/tests/test_graphical_units/test_vector_scene.py @@ -1,6 +1,8 @@ from __future__ import annotations + from manim.scene.vector_space_scene import VectorScene +from manim.scene.vector_space_scene import LinearTransformationScene from manim.utils.testing.frames_comparison import frames_comparison __module_test__ = "vector_scene" @@ -14,3 +16,11 @@ def test_vector_to_coords(scene): scene.add(basis) scene.vector_to_coords(vector=vector) scene.wait() + + +def test_apply_matrix(): + scene = LinearTransformationScene() + matrix = [[-1, 1], [1, 1]] + scene.apply_matrix(matrix) + scene.wait() + scene.apply_inverse_matrix(matrix) From 34d4767dbcb722a08b1765adc143d44d095e2cd2 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 5 Apr 2024 10:14:54 +0000 Subject: [PATCH 05/12] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_graphical_units/test_vector_scene.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/test_graphical_units/test_vector_scene.py b/tests/test_graphical_units/test_vector_scene.py index 4bf4c92f7f..f768e13c4f 100644 --- a/tests/test_graphical_units/test_vector_scene.py +++ b/tests/test_graphical_units/test_vector_scene.py @@ -1,8 +1,6 @@ from __future__ import annotations - -from manim.scene.vector_space_scene import VectorScene -from manim.scene.vector_space_scene import LinearTransformationScene +from manim.scene.vector_space_scene import LinearTransformationScene, VectorScene from manim.utils.testing.frames_comparison import frames_comparison __module_test__ = "vector_scene" From 7d2b8b1858dd291503f247d2a4dac1c459f4ced2 Mon Sep 17 00:00:00 2001 From: Sir James Clark Maxwell <71722499+SirJamesClarkMaxwell@users.noreply.github.com> Date: Fri, 5 Apr 2024 12:17:06 +0200 Subject: [PATCH 06/12] yeah , i forgot to save the file xd --- manim/scene/vector_space_scene.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/manim/scene/vector_space_scene.py b/manim/scene/vector_space_scene.py index b804be3551..47c80dbde3 100644 --- a/manim/scene/vector_space_scene.py +++ b/manim/scene/vector_space_scene.py @@ -1012,7 +1012,11 @@ def get_piece_movement(self, pieces: list | tuple | np.ndarray): start = Group(*pieces) target = Group(*(mob.target for mob in pieces)) """ - # N + # NOTE JasonGrace said that there is another possible solution + """ + - self.mobject = mobject if mobject is not None else Mobject() + + self.mobject = mobject if mobject is not None else VMobject() + """ # don't add empty VGroups if self.leave_ghost_vectors and start.submobjects: # start.copy() gives a VGroup of Vectors From bfa5446780848eff29a96efb9e09107efc173bce Mon Sep 17 00:00:00 2001 From: Sir James Clark Maxwell <71722499+SirJamesClarkMaxwell@users.noreply.github.com> Date: Fri, 5 Apr 2024 13:10:14 +0200 Subject: [PATCH 07/12] fixed the test, removed the comments my in changed file --- manim/scene/vector_space_scene.py | 11 +---------- tests/test_graphical_units/test_vector_scene.py | 1 + 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/manim/scene/vector_space_scene.py b/manim/scene/vector_space_scene.py index 47c80dbde3..e9304115ef 100644 --- a/manim/scene/vector_space_scene.py +++ b/manim/scene/vector_space_scene.py @@ -1007,16 +1007,7 @@ def get_piece_movement(self, pieces: list | tuple | np.ndarray): v_pieces = [piece for piece in pieces if isinstance(piece, VMobject)] start = VGroup(*v_pieces) target = VGroup(*(mob.target for mob in v_pieces)) - # NOTE other possible solution: - """ - start = Group(*pieces) - target = Group(*(mob.target for mob in pieces)) - """ - # NOTE JasonGrace said that there is another possible solution - """ - - self.mobject = mobject if mobject is not None else Mobject() - + self.mobject = mobject if mobject is not None else VMobject() - """ + # don't add empty VGroups if self.leave_ghost_vectors and start.submobjects: # start.copy() gives a VGroup of Vectors diff --git a/tests/test_graphical_units/test_vector_scene.py b/tests/test_graphical_units/test_vector_scene.py index f768e13c4f..19457ce3e0 100644 --- a/tests/test_graphical_units/test_vector_scene.py +++ b/tests/test_graphical_units/test_vector_scene.py @@ -18,6 +18,7 @@ def test_vector_to_coords(scene): def test_apply_matrix(): scene = LinearTransformationScene() + scene.setup() matrix = [[-1, 1], [1, 1]] scene.apply_matrix(matrix) scene.wait() From 83629af74d13ce877dab1dce1990a8d914051788 Mon Sep 17 00:00:00 2001 From: JasonGrace2282 Date: Fri, 5 Apr 2024 19:14:34 -0400 Subject: [PATCH 08/12] fix test and speed up test time for test_apply_matrix --- tests/test_graphical_units/test_vector_scene.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/test_graphical_units/test_vector_scene.py b/tests/test_graphical_units/test_vector_scene.py index 19457ce3e0..75bc1806d1 100644 --- a/tests/test_graphical_units/test_vector_scene.py +++ b/tests/test_graphical_units/test_vector_scene.py @@ -17,9 +17,10 @@ def test_vector_to_coords(scene): def test_apply_matrix(): - scene = LinearTransformationScene() + scene = LinearTransformationScene(include_background_plane=False) scene.setup() matrix = [[-1, 1], [1, 1]] - scene.apply_matrix(matrix) + # use short runtimes to speed up animation rendering + scene.apply_matrix(matrix, run_time=0.01) scene.wait() - scene.apply_inverse_matrix(matrix) + scene.apply_inverse(matrix, run_time=0.01) From 6a29409d1454153a86873023e51652e7284431bb Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 5 Apr 2024 10:14:54 +0000 Subject: [PATCH 09/12] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_graphical_units/test_vector_scene.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/test_graphical_units/test_vector_scene.py b/tests/test_graphical_units/test_vector_scene.py index 4bf4c92f7f..f768e13c4f 100644 --- a/tests/test_graphical_units/test_vector_scene.py +++ b/tests/test_graphical_units/test_vector_scene.py @@ -1,8 +1,6 @@ from __future__ import annotations - -from manim.scene.vector_space_scene import VectorScene -from manim.scene.vector_space_scene import LinearTransformationScene +from manim.scene.vector_space_scene import LinearTransformationScene, VectorScene from manim.utils.testing.frames_comparison import frames_comparison __module_test__ = "vector_scene" From 24e2c4e5bd8a34e22d04fa0142e8c1804fe46026 Mon Sep 17 00:00:00 2001 From: Sir James Clark Maxwell <71722499+SirJamesClarkMaxwell@users.noreply.github.com> Date: Fri, 5 Apr 2024 13:10:14 +0200 Subject: [PATCH 10/12] fixed the test, removed the comments my in changed file --- manim/scene/vector_space_scene.py | 11 +---------- tests/test_graphical_units/test_vector_scene.py | 1 + 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/manim/scene/vector_space_scene.py b/manim/scene/vector_space_scene.py index 47c80dbde3..e9304115ef 100644 --- a/manim/scene/vector_space_scene.py +++ b/manim/scene/vector_space_scene.py @@ -1007,16 +1007,7 @@ def get_piece_movement(self, pieces: list | tuple | np.ndarray): v_pieces = [piece for piece in pieces if isinstance(piece, VMobject)] start = VGroup(*v_pieces) target = VGroup(*(mob.target for mob in v_pieces)) - # NOTE other possible solution: - """ - start = Group(*pieces) - target = Group(*(mob.target for mob in pieces)) - """ - # NOTE JasonGrace said that there is another possible solution - """ - - self.mobject = mobject if mobject is not None else Mobject() - + self.mobject = mobject if mobject is not None else VMobject() - """ + # don't add empty VGroups if self.leave_ghost_vectors and start.submobjects: # start.copy() gives a VGroup of Vectors diff --git a/tests/test_graphical_units/test_vector_scene.py b/tests/test_graphical_units/test_vector_scene.py index f768e13c4f..19457ce3e0 100644 --- a/tests/test_graphical_units/test_vector_scene.py +++ b/tests/test_graphical_units/test_vector_scene.py @@ -18,6 +18,7 @@ def test_vector_to_coords(scene): def test_apply_matrix(): scene = LinearTransformationScene() + scene.setup() matrix = [[-1, 1], [1, 1]] scene.apply_matrix(matrix) scene.wait() From d918e4b97833c445d1077406a72662eb739a1ed7 Mon Sep 17 00:00:00 2001 From: Sir James Clark Maxwell <71722499+SirJamesClarkMaxwell@users.noreply.github.com> Date: Fri, 5 Apr 2024 14:32:09 +0200 Subject: [PATCH 11/12] fixed the test --- tests/test_graphical_units/test_vector_scene.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_graphical_units/test_vector_scene.py b/tests/test_graphical_units/test_vector_scene.py index 19457ce3e0..f6086fc2a3 100644 --- a/tests/test_graphical_units/test_vector_scene.py +++ b/tests/test_graphical_units/test_vector_scene.py @@ -22,4 +22,4 @@ def test_apply_matrix(): matrix = [[-1, 1], [1, 1]] scene.apply_matrix(matrix) scene.wait() - scene.apply_inverse_matrix(matrix) + scene.apply_inverse(matrix) From f9b24e119a3091244f744c6b87de971a744e2a3e Mon Sep 17 00:00:00 2001 From: JasonGrace2282 Date: Sun, 7 Apr 2024 21:30:17 -0400 Subject: [PATCH 12/12] Revert "docs: improve installation FAQ's" This reverts commit e53a1c8d6f14b77f389f79126f77bbcc48e6f869. --- docs/source/faq/installation.md | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/docs/source/faq/installation.md b/docs/source/faq/installation.md index 482125c04c..c60044b66a 100644 --- a/docs/source/faq/installation.md +++ b/docs/source/faq/installation.md @@ -1,7 +1,6 @@ # FAQ: Installation (different-versions)= - ## Why are there different versions of Manim? Manim was originally created by Grant Sanderson as a personal project and for use @@ -21,7 +20,6 @@ Grant's old videos locally on your machine. It is still available in his GitHub repository in form of the `cairo-backend` branch. To summarize: - - [**Manim**, or **ManimCE**](https://manim.community) refers to the community maintained version of the library. This is the version documented on this website; the package name on PyPI is [`manim`](https://pypi.org/project/manim/). @@ -104,17 +102,6 @@ creator whose guide you have been watching has made a more recent version availa and otherwise please contact them directly. Asking for help in the community will likely lead to being suggested to follow our written guide. -## Windows problem with installation process - -If you are a Windows user, what you could try, from a helper point of view is, working in 99% of cases: - -1. Ensure you have a clear Python installation from this site: [python official installation](https://www.python.org/downloads/). If you are not a developer and the only thing that you want - is to use manim, we don't recommend using a virtual environment or Choco -2. Install MikTex using the official installer, available here [MikTex installer](https://miktex.org/download). It is an optional step if you want to use the LaTeX in manim. -3. Run `pip install manim` -4. Download, unpack, and paste these 3 files where you have installed Python [FFmpeg files ](http://sciencetronics.com/download/ffmpeg.zip)(in the installation process, you had to specify the path). Check the `Scripts` directory. These files should be pasted there. -5. Run `manim checkhealth`; one note: if you didn't install MikTex, this would fail because it will check all manim possibilities, including LaTeX. - --- ## Why does ManimPango fail to install when running `pip install manim`? @@ -166,7 +153,7 @@ your problem. See the {doc}`FAQ on getting help ` for instructions. Yes: you can remove these aliases with these steps: 1. Go to the Windows Setting. -2. Under _Apps and Features_ you will find application execution aliases. +2. Under *Apps and Features* you will find application execution aliases. 3. Within this menu, disable the alias(es) that are causing the issue (`python` and/or `python3`).