Problems happend when trying to transform a VGroup object to another VGroup object
- 主要語言
- Python
- 星號
- 93.9k
- 分支
- 7.7k
- 平均合併
- 2 天 13 小時
- 30 天內合併 PR
- 4
描述
### Describe the error
I have two VGroup objects, which consisting of other VGroups and Mobjects, when I trying to apply a ReplacementTransformation to these two VGroup objects, some errors happend
### Code and Error
**Code**:
```
case_1_scene = VGroup()
case_1_scene.add(
case_1_vised_gird,
new_line,
case_1_explaination,
case_num_txt,
left_plug,
right_plug,
show_no_plug_on_left_right
)
del visited_grid_id
del vgrp_grid_line_list
vgrp_grid_line_list = (creat_grid_line(5, 5, 1, color=BLUE_E))[1]
case_1_overall_grid = (creat_blocked_grid_by_id(4,4,1,1,2))[1]
case_1_overall_vised_gird = (creat_visited_grid(4,4,1,
*(tuple(range(1,10))),
color=GREEN_E,
fill_color=GREEN_E,
fill_opacity=0.6
))[1]
case_1_overall_effect = VGroup(
vgrp_grid_line_list,
case_1_overall_grid,
case_1_overall_vised_gird
)
self.play(ReplacementTransform(case_1_scene, case_1_overall_effect))
```
If I change the code in the last few lines to this:
```
self.play(ReplacementTransform(case_1_scene, vgrp_grid_line_list))
self.play(Write(case_1_overall_effect))
```
Then it will run properly, and their will be a similar effect, but I just confused about that error
**Error**:
```
Traceback (most recent call last):
File "C:\Users\ZYT20\AppData\Local\Programs\Python\Python38\Scripts\manimgl-script.py", line 33, in
sys.exit(load_entry_point('manimgl', 'console_scripts', 'manimgl')())
File "e:\manim\manim\manimlib\__main__.py", line 25, in main
scene.run()
File "e:\manim\manim\manimlib\scene\scene.py", line 76, in run
self.construct()
File "manim题解.py", line 431, in construct
self.play(ReplacementTransform(case_1_scene, case_1_overall_effect))
File "e:\manim\manim\manimlib\scene\scene.py", line 410, in wrapper
func(self, *args, **kwargs)
File "e:\manim\manim\manimlib\scene\scene.py", line 471, in play
self.progress_through_animations(animations)
File "e:\manim\manim\manimlib\scene\scene.py", line 450, in progress_through_animations
animation.interpolate(alpha)
File "e:\manim\manim\manimlib\animation\animation.py", line 114, in interpolate
self.interpolate_mobject(self.rate_func(alpha))
File "e:\manim\manim\manimlib\animation\animation.py", line 126, in interpolate_mobject
self.interpolate_submobject(*mobs, sub_alpha)
File "e:\manim\manim\manimlib\animation\transform.py", line 105, in interpolate_submobject
submob.interpolate(start, target_copy, alpha, self.path_func)
File "e:\manim\manim\manimlib\mobject\types\vectorized_mobject.py", line 733, in interpolate
super().interpolate(mobject1, mobject2, alpha, *args, **kwargs)
File "e:\manim\manim\manimlib\mobject\mobject.py", line 1289, in interpolate
self.data[key][:] = func(
ValueError: could not broadcast input array from shape (6,1) into shape (3,1)
```
### Environment
**OS System**: Windows 10
**manim version**:manimgl
**python version**:3.8.6
貢獻指南
這個儲存庫沒有索引到貢獻指南
研究方向
此錯誤發生在 manimlib/mobject/types/vectorized_mobject.py 第733行,interpolate 因形狀不匹配而失敗。先檢查 VGroup 物件的內部結構以及 ReplacementTransform 如何映射 submobjects。查看兩個 VGroup 的資料陣列形狀,以了解為何 (6,1) 無法廣播(broadcast)到 (3,1)。執行提供的程式碼來重現該錯誤,然後追蹤插值邏輯。
由索引模型根據 Issue 內容生成。
評估
- 領域
- computer-graphics
- Issue 類型
- 缺陷
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100