mirror of
https://github.com/3b1b/manim.git
synced 2025-08-19 21:08:53 +00:00
Iterations and indexing into mobject should only look at submobjects, none of this sometimes self is included and sometimes it isn't business
This commit is contained in:
parent
2e3a112ff8
commit
d29cfd842f
1 changed files with 4 additions and 6 deletions
|
@ -104,7 +104,7 @@ class Mobject(object):
|
||||||
|
|
||||||
def set_data(self, data):
|
def set_data(self, data):
|
||||||
for key in data:
|
for key in data:
|
||||||
self.data[key] = data[key]
|
self.data[key] = data[key].copy()
|
||||||
|
|
||||||
def resize_points(self, new_length, resize_func=resize_array):
|
def resize_points(self, new_length, resize_func=resize_array):
|
||||||
if new_length != len(self.data["points"]):
|
if new_length != len(self.data["points"]):
|
||||||
|
@ -134,11 +134,10 @@ class Mobject(object):
|
||||||
|
|
||||||
# Family matters
|
# Family matters
|
||||||
def __getitem__(self, value):
|
def __getitem__(self, value):
|
||||||
self_list = self.split()
|
|
||||||
if isinstance(value, slice):
|
if isinstance(value, slice):
|
||||||
GroupClass = self.get_group_class()
|
GroupClass = self.get_group_class()
|
||||||
return GroupClass(*self_list.__getitem__(value))
|
return GroupClass(*self.split().__getitem__(value))
|
||||||
return self_list.__getitem__(value)
|
return self.split().__getitem__(value)
|
||||||
|
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
return iter(self.split())
|
return iter(self.split())
|
||||||
|
@ -147,8 +146,7 @@ class Mobject(object):
|
||||||
return len(self.split())
|
return len(self.split())
|
||||||
|
|
||||||
def split(self):
|
def split(self):
|
||||||
result = [self] if self.get_num_points() > 0 else []
|
return self.submobjects
|
||||||
return result + self.submobjects
|
|
||||||
|
|
||||||
def assemble_family(self):
|
def assemble_family(self):
|
||||||
sub_families = [sm.get_family() for sm in self.submobjects]
|
sub_families = [sm.get_family() for sm in self.submobjects]
|
||||||
|
|
Loading…
Add table
Reference in a new issue