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
Mobject methods like add() assert that all the values passed are also instances of Mobject, before adding them as children (into Mobject.submobjects).
VGroup overrides add() to go even further, by asserting that the values are instances of the VMobject subclass, being more restrictive than the original assertion.
However, the VMobject class itself does NOT have that assertion, so you can actually add a Mobject to it which is not a VMobject.
Therefore, this is legal:
Circle().add(Mobject())
but this raises a TypeError:
VGroup().add(Mobject())
A direct consequence of this is that this is allowed:
creating a VGroup which contains a Mobject in its family, even though it's not a direct child / submobject.
Expected behavior
The VMobject itself should assert that only VMobjects can be added to it. Adding a Mobject to a VMobject such as Circle should be illegal and also throw a TypeError. By doing this, VGroup would automatically do the assertion as well, as it's a subclass of VMobject.
The text was updated successfully, but these errors were encountered:
Description of bug / unexpected behavior
Mobject
methods likeadd()
assert that all the values passed are also instances ofMobject
, before adding them as children (intoMobject.submobjects
).VGroup
overridesadd()
to go even further, by asserting that the values are instances of theVMobject
subclass, being more restrictive than the original assertion.However, the
VMobject
class itself does NOT have that assertion, so you can actually add aMobject
to it which is not aVMobject
.Therefore, this is legal:
but this raises a
TypeError
:A direct consequence of this is that this is allowed:
creating a
VGroup
which contains aMobject
in its family, even though it's not a direct child / submobject.Expected behavior
The
VMobject
itself should assert that onlyVMobject
s can be added to it. Adding aMobject
to aVMobject
such asCircle
should be illegal and also throw aTypeError
. By doing this,VGroup
would automatically do the assertion as well, as it's a subclass ofVMobject
.The text was updated successfully, but these errors were encountered: