Skip to content

Commit 89e8808

Browse files
committed
Make VGroup and VDict printable
1 parent 037c9be commit 89e8808

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

manim/mobject/mobject.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,6 @@ def __init__(self, **kwargs):
6262
self.generate_points()
6363
self.init_colors()
6464

65-
def __str__(self):
66-
return str(self.name)
67-
6865
def reset_points(self):
6966
self.points = np.zeros((0, self.dim))
7067

manim/mobject/types/vectorized_mobject.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -876,6 +876,14 @@ def __init__(self, *vmobjects, **kwargs):
876876
VMobject.__init__(self, **kwargs)
877877
self.add(*vmobjects)
878878

879+
def __repr__(self):
880+
return (
881+
__class__.__name__
882+
+ "("
883+
+ ", ".join(str(mob) for mob in self.submobjects)
884+
+ ")"
885+
)
886+
879887
def add(self, *vmobjects):
880888
"""Checks if all passed elements are an instance of VMobject and then add them to submobjects
881889
@@ -934,6 +942,9 @@ def __init__(self, mapping_or_iterable={}, show_keys=False, **kwargs):
934942
self.submob_dict = {}
935943
self.add(mapping_or_iterable)
936944

945+
def __repr__(self):
946+
return __class__.__name__ + "(" + repr(self.submob_dict) + ")"
947+
937948
def add(self, mapping_or_iterable):
938949
"""Adds the key-value pairs to the :class:`VDict` object.
939950

0 commit comments

Comments
 (0)