-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Milestone
Description
Description of bug / unexpected behavior
In some conditions, the result of Mobject.length_over_dim(self, dim: int) -> float
is wrong.
Given:
a VGroup containing:
- an empty VGroup (no submobject)
- any MObject with some position, like Square
and with only positive [resp. negative] coordinates,
Then:
the result oflength_over_dim
is the max [resp. the min] coordinate of the square
Expected behavior
The result of length_over_dim
should be the size of the square.
How to reproduce the issue
Code for reproducing the problem
from manim import *
class LengthOverDimBug(Scene):
# create the simplest case that reproduce the issue
vgroup = VGroup()
sub_vgroup = VGroup()
square = Square(side_length=2.0)
vgroup.add(sub_vgroup)
vgroup.add(square)
# move the vgroup to have all values positive (resp. negative)
vgroup.shift(UP * 10) # makes the min wrong, and then the height
# vgroup.shift(UP * 10) # makes the max wrong, and then the height
vgroup.arrange_in_grid(rows=2, cols=1, flow_order="ur")
print(f"vgroup: {vgroup.__class__.__name__}")
print(f"vgroup.height={vgroup.height}")
print(f"vgroup.reduce_across_dimension(min, 1)={vgroup.reduce_across_dimension(min, 1)}")
print(f"vgroup.reduce_across_dimension(max, 1)={vgroup.reduce_across_dimension(max, 1)}")
for submobject in vgroup.submobjects:
print(f"submobject: {submobject.__class__.__name__}")
print(f"submobject.height={submobject.height}")
print(f"submobject.reduce_across_dimension(min, 1)={submobject.reduce_across_dimension(min, 1)}")
print(f"submobject.reduce_across_dimension(max, 1)={submobject.reduce_across_dimension(max, 1)}")
if __name__ == '__main__':
with tempconfig({'quality': 'low_quality', 'preview': True}):
scene = LengthOverDimBug()
scene.render()
Additional media files
USELESS
Logs
Terminal output
Manim Community v0.18.1
vgroup: VGroup
vgroup.height=11.0
vgroup.reduce_across_dimension(min, 1)=0
vgroup.reduce_across_dimension(max, 1)=11.0
submobject: VGroup
submobject.height=0
submobject.reduce_across_dimension(min, 1)=0
submobject.reduce_across_dimension(max, 1)=0
submobject: Square
submobject.height=2.0
submobject.reduce_across_dimension(min, 1)=9.0
submobject.reduce_across_dimension(max, 1)=11.0
System specifications
System Details
- OS (with version, e.g., Windows 10 v2004 or macOS 10.15 (Catalina)): Ubuntu 22.04.5 LTS
- RAM: 32GB
- Python version (
python/py/python3 --version
): 3.10.12 - Installed modules (provide output from
pip list
):
Package Version
----------------- -----------
click 8.1.7
cloup 3.0.5
decorator 5.1.1
distlib 0.3.9
filelock 3.16.1
glcontext 3.0.0
isosurfaces 0.1.2
manim 0.18.1
ManimPango 0.6.0
mapbox_earcut 1.0.2
markdown-it-py 3.0.0
mdurl 0.1.2
moderngl 5.12.0
moderngl-window 3.0.3
networkx 3.4.2
numpy 2.2.0
packaging 24.2
pbr 6.1.0
pillow 11.0.0
pip 24.3.1
pipdeptree 2.24.0
platformdirs 4.3.6
pycairo 1.27.0
pydub 0.25.1
pyglet 2.0.20
PyGLM 2.7.3
Pygments 2.18.0
rich 13.9.4
scipy 1.14.1
screeninfo 0.8.1
setuptools 59.6.0
skia-pathops 0.8.0.post2
srt 3.5.3
stevedore 5.4.0
svgelements 1.9.6
tqdm 4.67.1
typing_extensions 4.12.2
virtualenv 20.28.0
virtualenv-clone 0.5.7
virtualenvwrapper 6.1.1
watchdog 6.0.0
LaTeX details
UNUSED
Additional comments
Impacts:
arrange_in_grid
is not working well, because it useslength_over_dim
.
Cause:
length_over_dim
is based onself.reduce_across_dimension(max, dim)
andself.reduce_across_dimension(min, dim)
self.reduce_across_dimension
computes the min/max recursively- when an object has no
submobject
, it returns0
(center), what is the case for our emptyVGroup
- but for an empty VGroup, that is wrong, it should be
None
(as this MObject should not be taken into account), andNone
should be managed in bothreduce_across_dimension
andlength_over_dim
- I am going to propose a PR to solve this issue
Metadata
Metadata
Assignees
Labels
No labels