Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Make VGroup and VDict printable

nilaybhatia89e8808e93ba
diff --git a/manim/mobject/mobject.py b/manim/mobject/mobject.py
index 3b6f6e6e5..0d7244a5a 100644
--- a/manim/mobject/mobject.py
+++ b/manim/mobject/mobject.py
@@ -62,9 +62,6 @@ class Mobject(Container):
self.generate_points()
self.init_colors()
- def __str__(self):
- return str(self.name)
-
def reset_points(self):
self.points = np.zeros((0, self.dim))
diff --git a/manim/mobject/types/vectorized_mobject.py b/manim/mobject/types/vectorized_mobject.py
index cbc63d9c8..4f3d6eef7 100644
--- a/manim/mobject/types/vectorized_mobject.py
+++ b/manim/mobject/types/vectorized_mobject.py
@@ -876,6 +876,14 @@ class VGroup(VMobject):
VMobject.__init__(self, **kwargs)
self.add(*vmobjects)
+ def __repr__(self):
+ return (
+ __class__.__name__
+ + "("
+ + ", ".join(str(mob) for mob in self.submobjects)
+ + ")"
+ )
+
def add(self, *vmobjects):
"""Checks if all passed elements are an instance of VMobject and then add them to submobjects
@@ -934,6 +942,9 @@ class VDict(VMobject):
self.submob_dict = {}
self.add(mapping_or_iterable)
+ def __repr__(self):
+ return __class__.__name__ + "(" + repr(self.submob_dict) + ")"
+
def add(self, mapping_or_iterable):
"""Adds the key-value pairs to the :class:`VDict` object.