Skip to content

Fix successive calls of :meth:.LinearTransformationScene.apply_matrix #3675

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
e53a1c8
docs: improve installation FAQ's
SirJamesClarkMaxwell Apr 1, 2024
c7ebc5c
I have potentially resolved the issue when in LinearTransformationSce…
SirJamesClarkMaxwell Apr 4, 2024
5827a9a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 4, 2024
8b4b14f
added another solutions in comments, added tests and removed wrong fi…
SirJamesClarkMaxwell Apr 5, 2024
34d4767
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 5, 2024
7d2b8b1
yeah , i forgot to save the file xd
SirJamesClarkMaxwell Apr 5, 2024
7343592
Merge branch 'Linear_Transformation_scene' of https://github.com/SirJ…
SirJamesClarkMaxwell Apr 5, 2024
bfa5446
fixed the test, removed the comments my in changed file
SirJamesClarkMaxwell Apr 5, 2024
83629af
fix test and speed up test time for test_apply_matrix
JasonGrace2282 Apr 5, 2024
6a29409
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 5, 2024
24e2c4e
fixed the test, removed the comments my in changed file
SirJamesClarkMaxwell Apr 5, 2024
d918e4b
fixed the test
SirJamesClarkMaxwell Apr 5, 2024
a2b6192
Merge branch 'Linear_Transformation_scene' of https://github.com/SirJ…
SirJamesClarkMaxwell Apr 6, 2024
f9b24e1
Revert "docs: improve installation FAQ's"
JasonGrace2282 Apr 8, 2024
7550054
Merge branch 'main' into Linear_Transformation_scene
JasonGrace2282 Apr 8, 2024
4aba7e3
Merge branch 'main' into Linear_Transformation_scene
JasonGrace2282 Apr 8, 2024
f837873
Merge branch 'main' into Linear_Transformation_scene
JasonGrace2282 Apr 11, 2024
366860d
Merge branch 'main' into Linear_Transformation_scene
JasonGrace2282 Apr 13, 2024
b6ccdb4
Merge branch 'main' into Linear_Transformation_scene
JasonGrace2282 Apr 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Loading