3
3
import numpy as np
4
4
import pytest
5
5
6
- from manim import DL , UR , Circle , Mobject , Rectangle , Square , VGroup
6
+ from manim import DL , DR , UL , UR , Circle , Mobject , Rectangle , Square , VGroup
7
7
8
8
9
9
def test_mobject_add ():
@@ -136,18 +136,19 @@ def test_mobject_dimensions_nested_mobjects():
136
136
137
137
138
138
def test_mobject_dimensions_mobjects_with_no_points_are_at_origin ():
139
- rect = Rectangle (width = 2 , height = 3 )
140
- rect .move_to ([- 4 , - 5 , 0 ])
141
- outer_group = VGroup (rect )
139
+ for direction in [DL , DR , UL , UR ]:
140
+ rect = Rectangle (width = 2 , height = 3 )
141
+ rect .move_to (direction * 10 )
142
+ outer_group = VGroup (rect )
142
143
143
- # This is as one would expect
144
- assert outer_group .width == 2
145
- assert outer_group .height == 3
144
+ # This is as one would expect
145
+ assert outer_group .width == 2
146
+ assert outer_group .height == 3
146
147
147
- # Adding a mobject with no points does not change its size
148
- outer_group .add (VGroup ())
149
- assert outer_group .width == 2
150
- assert outer_group .height == 3
148
+ # Adding a mobject with no points does not change its size
149
+ outer_group .add (VGroup ())
150
+ assert outer_group .width == 2
151
+ assert outer_group .height == 3
151
152
152
153
153
154
def test_mobject_dimensions_has_points_and_children ():
@@ -165,25 +166,3 @@ def test_mobject_dimensions_has_points_and_children():
165
166
assert inner_rect .width == 2
166
167
assert inner_rect .height == 1
167
168
assert inner_rect .depth == 0
168
-
169
-
170
- def test_mobject_width_height ():
171
- for flow_order in ["ur" , "dl" ]:
172
- for is_reversed in [False , True ]:
173
- # create a vgroup with some sub-elements
174
- vgroup = VGroup ()
175
- sub_vgroup = VGroup ()
176
- square = Square (side_length = 2.0 )
177
- sub_elements = [sub_vgroup , square ]
178
- if is_reversed :
179
- sub_elements .reverse ()
180
- vgroup .add (sub_elements )
181
- # arrange them to move sub-objects all above or below zero
182
- direction = UR if flow_order == "ur" else DL
183
- vgroup .shift (direction * 10 )
184
- vgroup .arrange_in_grid (rows = 2 , cols = 2 , flow_order = flow_order )
185
- # These measures should be 2.
186
- assert vgroup .length_over_dim (0 ) == pytest .approx (2.0 )
187
- assert vgroup .length_over_dim (1 ) == pytest .approx (2.0 )
188
- assert vgroup .height == pytest .approx (2.0 )
189
- assert vgroup .width == pytest .approx (2.0 )
0 commit comments