You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 of length_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
frommanimimport*classLengthOverDimBug(Scene):
# create the simplest case that reproduce the issuevgroup=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 heightvgroup.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)}")
forsubmobjectinvgroup.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__':
withtempconfig({'quality': 'low_quality', 'preview': True}):
scene=LengthOverDimBug()
scene.render()
arrange_in_grid is not working well, because it uses length_over_dim.
Cause:
length_over_dim is based on self.reduce_across_dimension(max, dim) and self.reduce_across_dimension(min, dim)
self.reduce_across_dimension computes the min/max recursively
when an object has no submobject, it returns 0 (center), what is the case for our empty VGroup
but for an empty VGroup, that is wrong, it should be None (as this MObject should not be taken into account), and None should be managed in both reduce_across_dimension and length_over_dim
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:
and with only positive [resp. negative] coordinates,
Then:
the result of
length_over_dim
is the max [resp. the min] coordinate of the squareExpected behavior
The result of
length_over_dim
should be the size of the square.How to reproduce the issue
Code for reproducing the problem
Additional media files
USELESS
Logs
Terminal output
System specifications
System Details
python/py/python3 --version
): 3.10.12pip list
):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 recursivelysubmobject
, it returns0
(center), what is the case for our emptyVGroup
None
(as this MObject should not be taken into account), andNone
should be managed in bothreduce_across_dimension
andlength_over_dim
The text was updated successfully, but these errors were encountered: