mirror of
https://github.com/3b1b/manim.git
synced 2025-08-05 16:49:03 +00:00
fixed bug for reduce_across_dim for mobs with empty submobs
This commit is contained in:
parent
fb9ce5f518
commit
90504e24e7
1 changed files with 5 additions and 4 deletions
|
@ -623,13 +623,17 @@ class Mobject(Container):
|
||||||
values = []
|
values = []
|
||||||
values += [
|
values += [
|
||||||
mob.reduce_across_dimension(points_func, reduce_func, dim)
|
mob.reduce_across_dimension(points_func, reduce_func, dim)
|
||||||
for mob in self.submobjects
|
for mob in self.nonempty_submobjects()
|
||||||
]
|
]
|
||||||
try:
|
try:
|
||||||
return reduce_func(values)
|
return reduce_func(values)
|
||||||
except:
|
except:
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
def nonempty_submobjects(self):
|
||||||
|
return [submob for submob in self.submobjects
|
||||||
|
if len(submob.submobjects) != 0 or len(submob.points) != 0]
|
||||||
|
|
||||||
def get_merged_array(self, array_attr):
|
def get_merged_array(self, array_attr):
|
||||||
result = None
|
result = None
|
||||||
for mob in self.family_members_with_points():
|
for mob in self.family_members_with_points():
|
||||||
|
@ -745,10 +749,7 @@ class Mobject(Container):
|
||||||
def submobject_family(self):
|
def submobject_family(self):
|
||||||
sub_families = map(Mobject.submobject_family, self.submobjects)
|
sub_families = map(Mobject.submobject_family, self.submobjects)
|
||||||
all_mobjects = [self] + list(it.chain(*sub_families))
|
all_mobjects = [self] + list(it.chain(*sub_families))
|
||||||
<<<<<<< HEAD
|
|
||||||
#all_mobjects = list(it.chain(*sub_families)) + [self]
|
#all_mobjects = list(it.chain(*sub_families)) + [self]
|
||||||
=======
|
|
||||||
>>>>>>> master
|
|
||||||
return remove_list_redundancies(all_mobjects)
|
return remove_list_redundancies(all_mobjects)
|
||||||
|
|
||||||
def family_members_with_points(self):
|
def family_members_with_points(self):
|
||||||
|
|
Loading…
Add table
Reference in a new issue