Skip to content

Commit

Permalink
Fix successive calls of :meth:`.LinearTransformationScene.apply_matri…
Browse files Browse the repository at this point in the history
…x` (#3675)

* docs: improve installation FAQ's

* I have potentially resolved the issue when in LinearTransformationScene between two animations of transforming space we invoke the self.wait()

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* added another solutions in comments, added tests and removed wrong files from git

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* yeah , i forgot to save the file xd

* fixed the test, removed the comments my in changed file

* fix test and speed up test time for test_apply_matrix

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fixed the test, removed the comments my in changed file

* fixed the test

* Revert "docs: improve installation FAQ's"

This reverts commit e53a1c8.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: JasonGrace2282 <aarush.deshpande@gmail.com>
Co-authored-by: adeshpande <110117391+JasonGrace2282@users.noreply.github.com>
  • Loading branch information
4 people committed Apr 14, 2024
1 parent 2a4c2da commit 2776612
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
8 changes: 6 additions & 2 deletions manim/scene/vector_space_scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -1003,8 +1003,11 @@ def get_piece_movement(self, pieces: list | tuple | np.ndarray):
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
Expand Down Expand Up @@ -1091,6 +1094,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):
Expand Down
12 changes: 11 additions & 1 deletion tests/test_graphical_units/test_vector_scene.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from manim.scene.vector_space_scene import VectorScene
from manim.scene.vector_space_scene import LinearTransformationScene, VectorScene
from manim.utils.testing.frames_comparison import frames_comparison

__module_test__ = "vector_scene"
Expand All @@ -14,3 +14,13 @@ def test_vector_to_coords(scene):
scene.add(basis)
scene.vector_to_coords(vector=vector)
scene.wait()


def test_apply_matrix():
scene = LinearTransformationScene(include_background_plane=False)
scene.setup()
matrix = [[-1, 1], [1, 1]]
# use short runtimes to speed up animation rendering
scene.apply_matrix(matrix, run_time=0.01)
scene.wait()
scene.apply_inverse(matrix, run_time=0.01)

0 comments on commit 2776612

Please sign in to comment.