Skip to content

Cannot perform successive apply_matrix() in LinearTransformationScene #2713

Closed
@wlg1

Description

@wlg1

Description of bug / unexpected behavior

4 months ago, I was able to run code to perform successive apply_matrix() in LinearTransformationScene, and created videos of them. I added self.wait(0) in between each.

However, after revisiting manim today, now it gives an error when performing the second apply_matrix(), even though the code is the same. It is able to perform one apply_matrix().

Expected behavior

The code was able to create a video last time.

How to reproduce the issue

Code for reproducing the problem
from manim import *
class test(LinearTransformationScene):
    def __init__(self):
        LinearTransformationScene.__init__(
            self,
        )
    def construct(self):
        matrix = [[-0.3, 0.9], [0.7, 0.4]]
        self.apply_matrix(matrix)
        self.wait(0)
        
        matrix = [[1, -1], [1, 1]]
        self.apply_matrix(matrix)
        self.wait(0)

Or the code from this link's solutions:
https://stackoverflow.com/questions/69203723/how-to-apply-two-tranformations-one-after-the-other-in-manimce

Logs

Terminal output
Manim Community v0.15.2

[05/09/22 00:05:39] INFO     Animation 0 : Using cached data (hash :                               cairo_renderer.py:75
                             2724823860_80563834_388161424)
                    INFO     Animation 1 : Using cached data (hash :                               cairo_renderer.py:75
                             1164547788_1764062066_2625276077)
┌─────────────────────────────── Traceback (most recent call last) ────────────────────────────────┐
│                                                                                                  │
│ C:\Users\a\Documents\github\.conda\envs\manim\lib\site-packages\manim\cli\render\comma │
│ nds.py:118 in render                                                                             │
│                                                                                                  │
│   115 │   │   for SceneClass in scene_classes_from_file(file):                                   │
│   116 │   │   │   try:                                                                           │
│   117 │   │   │   │   scene = SceneClass()                                                       │
│ > 118 │   │   │   │   scene.render()                                                             │
│   119 │   │   │   except Exception:                                                              │
│   120 │   │   │   │   error_console.print_exception()                                            │
│   121 │   │   │   │   sys.exit(1)                                                                │
│ C:\Users\a\Documents\github\.conda\envs\manim\lib\site-packages\manim\scene\scene.py:2 │
│ 22 in render                                                                                     │
│                                                                                                  │
│    219 │   │   """                                                                               │
│    220 │   │   self.setup()                                                                      │
│    221 │   │   try:                                                                              │
│ >  222 │   │   │   self.construct()                                                              │
│    223 │   │   except EndSceneEarlyException:                                                    │
│    224 │   │   │   pass                                                                          │
│    225 │   │   except RerunSceneException as e:                                                  │
│                                                                                                  │
│ D:\Documents\\manim\test.py:13 in construct                                │
│                                                                                                  │
│   10 │   │   self.wait(0)                                                                        │
│   11 │   │                                                                                       │
│   12 │   │   matrix = [[1, -1], [1, 1]]                                                          │
│ > 13 │   │   self.apply_matrix(matrix)                                                           │
│   14 │   │   self.wait(0)                                                                        │
│                                                                                                  │
│ C:\Users\a\Documents\github\.conda\envs\manim\lib\site-packages\manim\scene\vector_spa │
│ ce_scene.py:1042 in apply_matrix                                                                 │
│                                                                                                  │
│   1039 │   │   **kwargs                                                                          │
│   1040 │   │   │   Any valid keyword argument of self.apply_transposed_matrix()                  │
│   1041 │   │   """                                                                               │
│ > 1042 │   │   self.apply_transposed_matrix(np.array(matrix).T, **kwargs)                        │
│   1043 │                                                                                         │
│   1044 │   def apply_inverse(self, matrix, **kwargs):                                            │
│   1045 │   │   """                                                                               │
│                                                                                                  │
│ C:\Users\a\Documents\github\.conda\envs\manim\lib\site-packages\manim\scene\vector_spa │
│ ce_scene.py:1078 in apply_transposed_matrix                                                      │
│                                                                                                  │
│   1075 │   │   │   │   [angle_of_vector(func(RIGHT)), angle_of_vector(func(UP)) - np.pi / 2],    │
│   1076 │   │   │   )                                                                             │
│   1077 │   │   │   kwargs["path_arc"] = net_rotation                                             │
│ > 1078 │   │   self.apply_function(func, **kwargs)                                               │
│   1079 │                                                                                         │
│   1080 │   def apply_inverse_transpose(self, t_matrix, **kwargs):                                │
│   1081 │   │   """                                                                               │
│                                                                                                  │
│ C:\Users\a\Documents\github\.conda\envs\manim\lib\site-packages\manim\scene\vector_spa │
│ ce_scene.py:1141 in apply_function                                                               │
│                                                                                                  │
│   1138 │   │   │   + [                                                                           │
│   1139 │   │   │   │   self.get_vector_movement(function),                                       │
│   1140 │   │   │   │   self.get_transformable_label_movement(),                                  │
│ > 1141 │   │   │   │   self.get_moving_mobject_movement(function),                               │
│   1142 │   │   │   ]                                                                             │
│   1143 │   │   │   + [Animation(f_mob) for f_mob in self.foreground_mobjects]                    │
│   1144 │   │   │   + added_anims                                                                 │
│                                                                                                  │
│ C:\Users\a\Documents\github\.conda\envs\manim\lib\site-packages\manim\scene\vector_spa │
│ ce_scene.py:986 in get_moving_mobject_movement                                                   │
│                                                                                                  │
│    983 │   │   │   │   m.target = m.copy()                                                       │
│    984 │   │   │   target_point = func(m.get_center())                                           │
│    985 │   │   │   m.target.move_to(target_point)                                                │
│ >  986 │   │   return self.get_piece_movement(self.moving_mobjects)                              │
│    987 │                                                                                         │
│    988 │   def get_vector_movement(self, func):                                                  │
│    989 │   │   """                                                                               │
│                                                                                                  │
│ C:\Users\a\Documents\github\.conda\envs\manim\lib\site-packages\manim\scene\vector_spa │
│ ce_scene.py:957 in get_piece_movement                                                            │
│                                                                                                  │
│    954 │   │   Animation                                                                         │
│    955 │   │   │   The animation of the movement.                                                │
│    956 │   │   """                                                                               │
│ >  957 │   │   start = VGroup(*pieces)                                                           │
│    958 │   │   target = VGroup(*(mob.target for mob in pieces))                                  │
│    959 │   │   if self.leave_ghost_vectors:                                                      │
│    960 │   │   │   self.add(start.copy().fade(0.7))                                              │
│                                                                                                  │
│ C:\Users\a\Documents\github\.conda\envs\manim\lib\site-packages\manim\mobject\types\ve │
│ ctorized_mobject.py:1779 in __init__                                                             │
│                                                                                                  │
│   1776 │                                                                                         │
│   1777 │   def __init__(self, *vmobjects, **kwargs):                                             │
│   1778 │   │   super().__init__(**kwargs)                                                        │
│ > 1779 │   │   self.add(*vmobjects)                                                              │
│   1780 │                                                                                         │
│   1781 │   def __repr__(self):                                                                   │
│   1782 │   │   return (                                                                          │
│                                                                                                  │
│ C:\Users\a\Documents\github\.conda\envs\manim\lib\site-packages\manim\mobject\types\ve │
│ ctorized_mobject.py:1844 in add                                                                  │
│                                                                                                  │
│   1841 │   │   │   │   │   )                                                                     │
│   1842 │   │   """                                                                               │
│   1843 │   │   if not all(isinstance(m, (VMobject, OpenGLVMobject)) for m in vmobjects):         │
│ > 1844 │   │   │   raise TypeError("All submobjects must be of type VMobject")                   │
│   1845 │   │   return super().add(*vmobjects)                                                    │
│   1846 │                                                                                         │
│   1847 │   def __add__(self, vmobject):                                                          │
└──────────────────────────────────────────────────────────────────────────────────────────────────┘
TypeError: All submobjects must be of type VMobject

System specifications

System Details

- OS- Windows 10
- RAM: 16GB
- Python version (`python/py/python3 --version`): 3.9.7
- Installed modules (provide output from `pip list`):
(too many installed modules to list, using manim 0.15.2)

Metadata

Metadata

Assignees

No one assigned

    Labels

    issue:bugSomething isn't working... For use in issues

    Type

    No type

    Projects

    Status

    🆕 New

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions