ManimCommunity / ManimCommunity/manim
LinearTransformationScene in v0.17.3: Circumscribe() causes problems
- Dominant language
- Python
- Stars
- 40.9k
- Forks
- 3.1k
- Avg merge
- 3d 12h
- Merged PRs (30d)
- 25
Description
## Description of bug / unexpected behavior
in the `LinearTransformationScene` using `self.play(Circumscribe())` around a `MathTex()` object leaves non-VMobjetcs behind on the scene which prevent any matrix operation.
See also [https://discord.com/channels/581738731934056449/1147643803956682802/1147643803956682802](https://discord.com/channels/581738731934056449/1147643803956682802/1147643803956682802)
## Expected behavior
An animation like `Circumscribe()` should clean up after itself...
## How to reproduce the issue
The code below reproduces the problem, aborting with
```
TypeError: All submobjects must be of type VMobject
```
Remove the comment before `#self.moving_mobjects = []` and the code will execute correctly.
Code for reproducing the problem
```py
class LinearTransformationSceneExample_02(LinearTransformationScene):
def __init__(self):
LinearTransformationScene.__init__(
self,
show_coordinates=True,
leave_ghost_vectors=True,
background_plane_kwargs={"x_range":[-4,4,0.5],"y_range":[-2.25,2.25,0.5],"x_length":14.22,"y_length":8},
foreground_plane_kwargs={"x_range":[-8,8,0.5],"y_range":[-4.5,4.5,0.5],"x_length":2*14.22,"y_length":2*8}
)
def construct(self):
matrix = [[1 / 2, 0], [0, -1 / 2]]
matrix_tex = MathTex(r"\hat{S}_z = \begin{bmatrix} \frac{1}{2}\hbar & 0 \\ "
r"0 & -\frac{1}{2}\hbar \end{bmatrix}").to_edge(UL).add_background_rectangle()
matrix_tex2 = MathTex(r"\theta = 2").to_edge(UR).add_background_rectangle()
self.add_foreground_mobject(matrix_tex, matrix_tex2)
self.add_transformable_mobject(Vector(self.background_plane.c2p(0.809, -0.5878), color=BLUE))
self.play(Circumscribe(matrix_tex))
#self.moving_mobjects = []
self.apply_matrix(matrix)
self.wait()
```
## System specifications
- happens on Windows 10 and Manimator
Contributor guide
Research direction
Start with the provided LinearTransformationSceneExample_02 reproduction and run it on the stated setup to observe the TypeError after Circumscribe(matrix_tex) and apply_matrix(matrix). Trace how Circumscribe leaves objects in the scene; done means the reproduction runs without manually clearing moving_mobjects and matrix operations still work.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- computer-graphics
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100