From 6d0c55d2ba543dbb5263931e1c6963465f14a333 Mon Sep 17 00:00:00 2001 From: BillyLikesHacking <86190295+BillyLikesHacking@users.noreply.github.com> Date: Fri, 22 Oct 2021 20:00:27 +0800 Subject: [PATCH 01/16] Update mobject.py --- manimlib/mobject/mobject.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/manimlib/mobject/mobject.py b/manimlib/mobject/mobject.py index 79b489de..126ebdec 100644 --- a/manimlib/mobject/mobject.py +++ b/manimlib/mobject/mobject.py @@ -82,6 +82,15 @@ class Mobject(object): def __str__(self): return self.__class__.__name__ + def __add__(self, other : 'Mobject'): + assert(isinstance(other, Mobject)) + return Group(self, other) + + def __mul__(self, other : 'int'): + if isinstance(self, VMobject): + return VGroup(*[mob.copy() for mob in range(other)]) + return Group(*[mob.copy() for mob in range(other)]) + def init_data(self): self.data = { "points": np.zeros((0, 3)), From 487f582302e1555782d5dd1af4626f52fffdd332 Mon Sep 17 00:00:00 2001 From: BillyLikesHacking <86190295+BillyLikesHacking@users.noreply.github.com> Date: Fri, 22 Oct 2021 20:02:05 +0800 Subject: [PATCH 02/16] Update mobject.py --- manimlib/mobject/mobject.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/manimlib/mobject/mobject.py b/manimlib/mobject/mobject.py index 126ebdec..8ca79c69 100644 --- a/manimlib/mobject/mobject.py +++ b/manimlib/mobject/mobject.py @@ -1596,6 +1596,15 @@ class Group(Mobject): raise Exception("All submobjects must be of type Mobject") Mobject.__init__(self, **kwargs) self.add(*mobjects) + def __add__(self, other : 'Mobject' or 'Group'): + assert(isinstance(other, Mobject)) + if other in self: + return Group(*self, other.copy()) + if isinstance(other, (Group, VGroup)): + if all([isinstance(i, VMobject) for i in Group(*self, *other)]): + return VGroup(*self, *other) + return Group(*self, *other) + return Group(*self, other) class Point(Mobject): From 030fb52018854c3b137560cf70cf325ce41d5fab Mon Sep 17 00:00:00 2001 From: BillyLikesHacking <86190295+BillyLikesHacking@users.noreply.github.com> Date: Fri, 22 Oct 2021 20:03:05 +0800 Subject: [PATCH 03/16] Update vectorized_mobject.py --- manimlib/mobject/types/vectorized_mobject.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/manimlib/mobject/types/vectorized_mobject.py b/manimlib/mobject/types/vectorized_mobject.py index 98f8458d..1bf29d73 100644 --- a/manimlib/mobject/types/vectorized_mobject.py +++ b/manimlib/mobject/types/vectorized_mobject.py @@ -75,6 +75,10 @@ class VMobject(Mobject): self.triangulation = np.zeros(0, dtype='i4') super().__init__(**kwargs) self.refresh_unit_normal() + + def __add__(self, other : 'VMobject') -> VGroup: + assert(isinstance(other, VMobject)) + return VGroup(self, other) def get_group_class(self): return VGroup From c94ebaa260c117875ab324dec97afd2568f0834f Mon Sep 17 00:00:00 2001 From: BillyLikesHacking <86190295+BillyLikesHacking@users.noreply.github.com> Date: Fri, 22 Oct 2021 20:03:58 +0800 Subject: [PATCH 04/16] Update vectorized_mobject.py --- manimlib/mobject/types/vectorized_mobject.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/manimlib/mobject/types/vectorized_mobject.py b/manimlib/mobject/types/vectorized_mobject.py index 1bf29d73..1037cc25 100644 --- a/manimlib/mobject/types/vectorized_mobject.py +++ b/manimlib/mobject/types/vectorized_mobject.py @@ -993,6 +993,16 @@ class VGroup(VMobject): raise Exception("All submobjects must be of type VMobject") super().__init__(**kwargs) self.add(*vmobjects) + + def __add__(self:'VGroup', other : 'VMobject' or 'VGroup'): + assert(isinstance(other, VMobject)) + if isinstance(other, VGroup): + return VGroup(*self, *other) + if isinstance(other, Mobject): + return Group(*self) + other + if other in self: + return self.add(other.copy()) + return self.add(other) class VectorizedPoint(Point, VMobject): From b1ed16e81afc33720353f3442c1e68275d1da2b7 Mon Sep 17 00:00:00 2001 From: BillyLikesHacking <86190295+BillyLikesHacking@users.noreply.github.com> Date: Fri, 22 Oct 2021 20:46:47 +0800 Subject: [PATCH 05/16] Update mobject.py --- manimlib/mobject/mobject.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/manimlib/mobject/mobject.py b/manimlib/mobject/mobject.py index 8ca79c69..dafba973 100644 --- a/manimlib/mobject/mobject.py +++ b/manimlib/mobject/mobject.py @@ -87,8 +87,9 @@ class Mobject(object): return Group(self, other) def __mul__(self, other : 'int'): + from manimlib.mobject.types.vectorized_mobject import VMobject, VGroup if isinstance(self, VMobject): - return VGroup(*[mob.copy() for mob in range(other)]) + return VGroup(*[self.copy() for i in range(other)]) return Group(*[mob.copy() for mob in range(other)]) def init_data(self): From c60e97ebf9775883b5b5ca261e9723e848a65190 Mon Sep 17 00:00:00 2001 From: BillyLikesHacking <86190295+BillyLikesHacking@users.noreply.github.com> Date: Fri, 22 Oct 2021 20:58:19 +0800 Subject: [PATCH 06/16] Update vectorized_mobject.py --- manimlib/mobject/types/vectorized_mobject.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manimlib/mobject/types/vectorized_mobject.py b/manimlib/mobject/types/vectorized_mobject.py index 1037cc25..257c6de1 100644 --- a/manimlib/mobject/types/vectorized_mobject.py +++ b/manimlib/mobject/types/vectorized_mobject.py @@ -76,7 +76,7 @@ class VMobject(Mobject): super().__init__(**kwargs) self.refresh_unit_normal() - def __add__(self, other : 'VMobject') -> VGroup: + def __add__(self, other : 'VMobject') -> 'VGroup': assert(isinstance(other, VMobject)) return VGroup(self, other) From 4eabaecfc818190477aff07c49485e77ba49da86 Mon Sep 17 00:00:00 2001 From: Bill Xi <86190295+BillyLikesHacking@users.noreply.github.com> Date: Sun, 31 Oct 2021 18:34:23 +0800 Subject: [PATCH 07/16] Update mobject.py --- manimlib/mobject/mobject.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/manimlib/mobject/mobject.py b/manimlib/mobject/mobject.py index dafba973..8532b42f 100644 --- a/manimlib/mobject/mobject.py +++ b/manimlib/mobject/mobject.py @@ -83,14 +83,10 @@ class Mobject(object): return self.__class__.__name__ def __add__(self, other : 'Mobject'): - assert(isinstance(other, Mobject)) return Group(self, other) def __mul__(self, other : 'int'): - from manimlib.mobject.types.vectorized_mobject import VMobject, VGroup - if isinstance(self, VMobject): - return VGroup(*[self.copy() for i in range(other)]) - return Group(*[mob.copy() for mob in range(other)]) + return self.replicate(other) def init_data(self): self.data = { From f9a6fa7036e6e6ef78a9f7eaa9174fa9d44bbcc7 Mon Sep 17 00:00:00 2001 From: Bill Xi <86190295+BillyLikesHacking@users.noreply.github.com> Date: Sun, 31 Oct 2021 18:35:28 +0800 Subject: [PATCH 08/16] Update mobject.py --- manimlib/mobject/mobject.py | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/manimlib/mobject/mobject.py b/manimlib/mobject/mobject.py index 8532b42f..c7cc16b7 100644 --- a/manimlib/mobject/mobject.py +++ b/manimlib/mobject/mobject.py @@ -1594,14 +1594,7 @@ class Group(Mobject): Mobject.__init__(self, **kwargs) self.add(*mobjects) def __add__(self, other : 'Mobject' or 'Group'): - assert(isinstance(other, Mobject)) - if other in self: - return Group(*self, other.copy()) - if isinstance(other, (Group, VGroup)): - if all([isinstance(i, VMobject) for i in Group(*self, *other)]): - return VGroup(*self, *other) - return Group(*self, *other) - return Group(*self, other) + return self.add(other) class Point(Mobject): From 82540edae90bd7a7bd5b9bfdb839e2009f334a91 Mon Sep 17 00:00:00 2001 From: Bill Xi <86190295+BillyLikesHacking@users.noreply.github.com> Date: Sun, 31 Oct 2021 18:37:12 +0800 Subject: [PATCH 09/16] Update mobject.py --- manimlib/mobject/mobject.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manimlib/mobject/mobject.py b/manimlib/mobject/mobject.py index c7cc16b7..b706d9ad 100644 --- a/manimlib/mobject/mobject.py +++ b/manimlib/mobject/mobject.py @@ -83,7 +83,7 @@ class Mobject(object): return self.__class__.__name__ def __add__(self, other : 'Mobject'): - return Group(self, other) + return self.get_group_class(self, other) def __mul__(self, other : 'int'): return self.replicate(other) From b285ca7c22537bf3034ed26e58dbcd92ad6c675b Mon Sep 17 00:00:00 2001 From: Bill Xi <86190295+BillyLikesHacking@users.noreply.github.com> Date: Sun, 31 Oct 2021 18:38:23 +0800 Subject: [PATCH 10/16] Update vectorized_mobject.py --- manimlib/mobject/types/vectorized_mobject.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/manimlib/mobject/types/vectorized_mobject.py b/manimlib/mobject/types/vectorized_mobject.py index 257c6de1..02604a7f 100644 --- a/manimlib/mobject/types/vectorized_mobject.py +++ b/manimlib/mobject/types/vectorized_mobject.py @@ -995,13 +995,6 @@ class VGroup(VMobject): self.add(*vmobjects) def __add__(self:'VGroup', other : 'VMobject' or 'VGroup'): - assert(isinstance(other, VMobject)) - if isinstance(other, VGroup): - return VGroup(*self, *other) - if isinstance(other, Mobject): - return Group(*self) + other - if other in self: - return self.add(other.copy()) return self.add(other) From 5d942d5ac0202caac54e657c8f24b1e838f34114 Mon Sep 17 00:00:00 2001 From: Bill Xi <86190295+BillyLikesHacking@users.noreply.github.com> Date: Sun, 31 Oct 2021 18:42:14 +0800 Subject: [PATCH 11/16] Update vectorized_mobject.py --- manimlib/mobject/types/vectorized_mobject.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/manimlib/mobject/types/vectorized_mobject.py b/manimlib/mobject/types/vectorized_mobject.py index 02604a7f..d4cf19ca 100644 --- a/manimlib/mobject/types/vectorized_mobject.py +++ b/manimlib/mobject/types/vectorized_mobject.py @@ -75,10 +75,6 @@ class VMobject(Mobject): self.triangulation = np.zeros(0, dtype='i4') super().__init__(**kwargs) self.refresh_unit_normal() - - def __add__(self, other : 'VMobject') -> 'VGroup': - assert(isinstance(other, VMobject)) - return VGroup(self, other) def get_group_class(self): return VGroup From b531c82bc4a98e25a5bbe60188730e1b3a8ffe5f Mon Sep 17 00:00:00 2001 From: Bill Xi <86190295+BillyLikesHacking@users.noreply.github.com> Date: Sun, 31 Oct 2021 20:01:16 +0800 Subject: [PATCH 12/16] Update mobject.py --- manimlib/mobject/mobject.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/manimlib/mobject/mobject.py b/manimlib/mobject/mobject.py index b706d9ad..5dd8dff0 100644 --- a/manimlib/mobject/mobject.py +++ b/manimlib/mobject/mobject.py @@ -82,10 +82,12 @@ class Mobject(object): def __str__(self): return self.__class__.__name__ - def __add__(self, other : 'Mobject'): + def __add__(self, other : 'Mobject') -> 'Mobject': + assert(isinstance(other, Mobject)) return self.get_group_class(self, other) - def __mul__(self, other : 'int'): + def __mul__(self, other : 'int') -> 'Mobject': + assert(isinstance(other, int)) return self.replicate(other) def init_data(self): From 01f4ef3e5d59b9afe30654a0ccef6a2a6bf10098 Mon Sep 17 00:00:00 2001 From: Bill Xi <86190295+BillyLikesHacking@users.noreply.github.com> Date: Sun, 31 Oct 2021 20:02:30 +0800 Subject: [PATCH 13/16] Create mobject.py --- manimlib/mobject/mobject.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/manimlib/mobject/mobject.py b/manimlib/mobject/mobject.py index 5dd8dff0..16a4fc5c 100644 --- a/manimlib/mobject/mobject.py +++ b/manimlib/mobject/mobject.py @@ -1595,7 +1595,9 @@ class Group(Mobject): raise Exception("All submobjects must be of type Mobject") Mobject.__init__(self, **kwargs) self.add(*mobjects) + def __add__(self, other : 'Mobject' or 'Group'): + assert(isinstance(other(Mobject)) return self.add(other) From 6766e459f21ae408090d83957ae02940e54ac7a6 Mon Sep 17 00:00:00 2001 From: Bill Xi <86190295+BillyLikesHacking@users.noreply.github.com> Date: Sun, 31 Oct 2021 20:03:04 +0800 Subject: [PATCH 14/16] Update vectorized_mobject.py --- manimlib/mobject/types/vectorized_mobject.py | 1 + 1 file changed, 1 insertion(+) diff --git a/manimlib/mobject/types/vectorized_mobject.py b/manimlib/mobject/types/vectorized_mobject.py index d4cf19ca..0e930084 100644 --- a/manimlib/mobject/types/vectorized_mobject.py +++ b/manimlib/mobject/types/vectorized_mobject.py @@ -991,6 +991,7 @@ class VGroup(VMobject): self.add(*vmobjects) def __add__(self:'VGroup', other : 'VMobject' or 'VGroup'): + assert(isinstance(other, VMobject)) return self.add(other) From 77159eea2eccdb9cd69f20f1e2f33345adfdf69c Mon Sep 17 00:00:00 2001 From: Bill Xi <86190295+BillyLikesHacking@users.noreply.github.com> Date: Mon, 1 Nov 2021 10:19:06 +0800 Subject: [PATCH 15/16] Update mobject.py --- manimlib/mobject/mobject.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manimlib/mobject/mobject.py b/manimlib/mobject/mobject.py index 16a4fc5c..8ef3625b 100644 --- a/manimlib/mobject/mobject.py +++ b/manimlib/mobject/mobject.py @@ -1597,7 +1597,7 @@ class Group(Mobject): self.add(*mobjects) def __add__(self, other : 'Mobject' or 'Group'): - assert(isinstance(other(Mobject)) + assert(isinstance(other, Mobject)) return self.add(other) From f0b5181694b40e23f38e83a7707511aa032244fd Mon Sep 17 00:00:00 2001 From: Grant Sanderson Date: Mon, 1 Nov 2021 13:16:50 -0700 Subject: [PATCH 16/16] Update manimlib/mobject/mobject.py Small bug fix to Mobject.__add__ --- manimlib/mobject/mobject.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manimlib/mobject/mobject.py b/manimlib/mobject/mobject.py index 8ef3625b..3e4d5f61 100644 --- a/manimlib/mobject/mobject.py +++ b/manimlib/mobject/mobject.py @@ -84,7 +84,7 @@ class Mobject(object): def __add__(self, other : 'Mobject') -> 'Mobject': assert(isinstance(other, Mobject)) - return self.get_group_class(self, other) + return self.get_group_class()(self, other) def __mul__(self, other : 'int') -> 'Mobject': assert(isinstance(other, int))