-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix wrong value of MObject width/height with empty VGroup #4088
Open
gvauvert
wants to merge
5
commits into
ManimCommunity:main
Choose a base branch
from
gvauvert:fix-PR-4087
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+27
−24
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
33ac00b
Issue-4087 Add bug test
gvauvert e9443ae
Issue-4087 Fix bug
gvauvert 1e59773
Issue-4087 Fix comment and add type hint
gvauvert 7337501
Issue-4087 Fix comment
gvauvert 8b5d831
Issue-4087 Improve previous test instead of adding a new one
gvauvert File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
import numpy as np | ||
import pytest | ||
|
||
from manim import DL, UR, Circle, Mobject, Rectangle, Square, VGroup | ||
from manim import DL, DR, UL, UR, Circle, Mobject, Rectangle, Square, VGroup | ||
|
||
|
||
def test_mobject_add(): | ||
|
@@ -136,21 +136,19 @@ def test_mobject_dimensions_nested_mobjects(): | |
|
||
|
||
def test_mobject_dimensions_mobjects_with_no_points_are_at_origin(): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As the previous test was testing an unexpected behavior, it should have been linked to an issue. |
||
rect = Rectangle(width=2, height=3) | ||
rect.move_to([-4, -5, 0]) | ||
outer_group = VGroup(rect) | ||
|
||
# This is as one would expect | ||
assert outer_group.width == 2 | ||
assert outer_group.height == 3 | ||
|
||
# Adding a mobject with no points has a quirk of adding a "point" | ||
# to [0, 0, 0] (the origin). This changes the size of the outer | ||
# group because now the bottom left corner is at [-5, -6.5, 0] | ||
# but the upper right corner is [0, 0, 0] instead of [-3, -3.5, 0] | ||
outer_group.add(VGroup()) | ||
assert outer_group.width == 5 | ||
assert outer_group.height == 6.5 | ||
for direction in [DL, DR, UL, UR]: | ||
rect = Rectangle(width=2, height=3) | ||
rect.move_to(direction * 10) | ||
outer_group = VGroup(rect) | ||
|
||
# This is as one would expect | ||
assert outer_group.width == 2 | ||
assert outer_group.height == 3 | ||
|
||
# Adding a mobject with no points does not change its size | ||
outer_group.add(VGroup()) | ||
assert outer_group.width == 2 | ||
assert outer_group.height == 3 | ||
|
||
|
||
def test_mobject_dimensions_has_points_and_children(): | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As this function is meant to be used only internally, it should be private
or at least protected