Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

submobject_family -> get_family

Grant Sanderson51e6b66c9521
diff --git a/active_projects/eola2/cramer.py b/active_projects/eola2/cramer.py
index b5e12ed5f..b5b18e367 100644
--- a/active_projects/eola2/cramer.py
+++ b/active_projects/eola2/cramer.py
@@ -1302,7 +1302,7 @@ class SolvingASystemWithOrthonormalMatrix(LinearTransformationScene):
equation.movers = VGroup(
moving_var, moving_output_vect_label, moving_column_mob
)
- for element in moving_column_mob.target.submobject_family():
+ for element in moving_column_mob.target.get_family():
if not isinstance(element, TexMobject):
continue
tex_string = element.get_tex_string()
diff --git a/camera/multi_camera.py b/camera/multi_camera.py
index e61496dad..65780934d 100644
--- a/camera/multi_camera.py
+++ b/camera/multi_camera.py
@@ -47,7 +47,7 @@ class MultiCamera(MovingCamera):
to_add = list(mobjects)
if not self.allow_cameras_to_capture_their_own_display:
to_add = list_difference_update(
- to_add, imfc.submobject_family()
+ to_add, imfc.get_family()
)
imfc.camera.capture_mobjects(to_add, **kwargs)
MovingCamera.capture_mobjects(self, mobjects, **kwargs)
diff --git a/for_3b1b_videos/pi_creature_scene.py b/for_3b1b_videos/pi_creature_scene.py
index da846f744..1bdc5a6b8 100644
--- a/for_3b1b_videos/pi_creature_scene.py
+++ b/for_3b1b_videos/pi_creature_scene.py
@@ -171,13 +171,13 @@ class PiCreatureScene(Scene):
for pi_creature in self.get_pi_creatures():
if pi_creature not in self.get_mobjects():
continue
- if pi_creature in first_anim.mobject.submobject_family():
+ if pi_creature in first_anim.mobject.get_family():
continue
- anims_with_pi_creature = [anim for anim in animations if pi_creature in anim.mobject.submobject_family()]
+ anims_with_pi_creature = [anim for anim in animations if pi_creature in anim.mobject.get_family()]
for anim in anims_with_pi_creature:
if isinstance(anim, Transform):
- index = anim.mobject.submobject_family().index(pi_creature)
- target_family = anim.target_mobject.submobject_family()
+ index = anim.mobject.get_family().index(pi_creature)
+ target_family = anim.target_mobject.get_family()
target = target_family[index]
if isinstance(target, PiCreature):
target.look_at(point_of_interest)
diff --git a/mobject/mobject.py b/mobject/mobject.py
index 42392d4b0..c5eca9a85 100644
--- a/mobject/mobject.py
+++ b/mobject/mobject.py
@@ -126,7 +126,7 @@ class Mobject(Container):
copy_mobject.submobjects = [
submob.copy() for submob in self.submobjects
]
- family = self.submobject_family()
+ family = self.get_family()
for attr, value in list(self.__dict__.items()):
if isinstance(value, Mobject) and value in family and value is not self:
setattr(copy_mobject, attr, value.copy())
@@ -628,7 +628,7 @@ class Mobject(Container):
return self
def fade_to(self, color, alpha):
- for mob in self.submobject_family():
+ for mob in self.get_family():
mob.fade_to_no_recurse(self, color, alpha)
return self
@@ -637,7 +637,7 @@ class Mobject(Container):
return self
def fade(self, darkness=0.5):
- for submob in self.submobject_family():
+ for submob in self.get_family():
submob.fade_no_recurse(darkness)
return self
@@ -660,7 +660,7 @@ class Mobject(Container):
if not hasattr(self, "saved_state") or self.save_state is None:
raise Exception("Trying to restore without having saved")
self.align_data(self.saved_state)
- for sm1, sm2 in zip(self.submobject_family(), self.saved_state.submobject_family()):
+ for sm1, sm2 in zip(self.get_family(), self.saved_state.get_family()):
sm1.interpolate(sm1, sm2, 1)
return self
@@ -806,14 +806,14 @@ class Mobject(Container):
result = [self] if len(self.points) > 0 else []
return result + self.submobjects
- def submobject_family(self):
+ def get_family(self):
sub_families = list(map(Mobject.submobject_family, self.submobjects))
all_mobjects = [self] + list(it.chain(*sub_families))
#all_mobjects = list(it.chain(*sub_families)) + [self]
return remove_list_redundancies(all_mobjects)
def family_members_with_points(self):
- return [m for m in self.submobject_family() if m.get_num_points() > 0]
+ return [m for m in self.get_family() if m.get_num_points() > 0]
def arrange_submobjects(self, direction=RIGHT, center=True, **kwargs):
for m1, m2 in zip(self.submobjects, self.submobjects[1:]):
@@ -853,11 +853,11 @@ class Mobject(Container):
submob.shuffle_submobjects(recursive=True)
random.shuffle(self.submobjects)
- def print_submobject_family(self, n_tabs=0):
+ def print_get_family(self, n_tabs=0):
"""For debugging purposes"""
print("\t" * n_tabs, self, id(self))
for submob in self.submobjects:
- submob.print_submobject_family(n_tabs + 1)
+ submob.print_get_family(n_tabs + 1)
# Alignment
def align_data(self, mobject):
diff --git a/mobject/types/vectorized_mobject.py b/mobject/types/vectorized_mobject.py
index 2cf195283..39df19d8a 100644
--- a/mobject/types/vectorized_mobject.py
+++ b/mobject/types/vectorized_mobject.py
@@ -252,7 +252,7 @@ class VMobject(Mobject):
def set_sheen_direction(self, direction, family=True):
direction = np.array(direction)
if family:
- for submob in self.submobject_family():
+ for submob in self.get_family():
submob.sheen_direction = direction
else:
self.sheen_direction = direction
diff --git a/old_projects/WindingNumber_G.py b/old_projects/WindingNumber_G.py
index 769b55dd5..36e5cc24d 100644
--- a/old_projects/WindingNumber_G.py
+++ b/old_projects/WindingNumber_G.py
@@ -790,7 +790,7 @@ class InputOutputScene(Scene):
label.to_edge(UP, buff = MED_SMALL_BUFF)
plane.add(label)
plane.label = label
- for submob in plane.submobject_family():
+ for submob in plane.get_family():
if isinstance(submob, TexMobject) and hasattr(submob, "background_rectangle"):
submob.remove(submob.background_rectangle)
@@ -1135,7 +1135,7 @@ class TwoDScreenInOurThreeDWorld(AltTeacherStudentsScene, ThreeDScene):
everything = VGroup(laptop, *self.mobjects)
everything.generate_target()
- # for mob in everything.target.submobject_family():
+ # for mob in everything.target.get_family():
# if isinstance(mob, PiCreature):
# mob.change_mode("confused")
everything.target.rotate(TAU/12, LEFT)
diff --git a/old_projects/efvgt.py b/old_projects/efvgt.py
index 44bf02977..8923c564d 100644
--- a/old_projects/efvgt.py
+++ b/old_projects/efvgt.py
@@ -768,7 +768,7 @@ class GroupOfCubeSymmetries(ThreeDScene):
randy = Randolph(mode = "pondering")
# randy.pupils.shift(0.01*OUT)
# randy.add(randy.pupils.copy().shift(0.02*IN))
- # for submob in randy.submobject_family():
+ # for submob in randy.get_family():
# submob.part_of_three_d_mobject = True
randy.scale(0.5)
face = cube[1]
diff --git a/old_projects/eola/chapter1.py b/old_projects/eola/chapter1.py
index 821768ef2..35202fdc3 100644
--- a/old_projects/eola/chapter1.py
+++ b/old_projects/eola/chapter1.py
@@ -537,7 +537,7 @@ class CoordinateSystemWalkthrough(VectorScene):
y_tick_marks = x_tick_marks.copy().rotate(np.pi/2)
tick_marks = VMobject(x_tick_marks, y_tick_marks)
tick_marks.set_color(WHITE)
- plane_lines = [m for m in plane.submobject_family() if isinstance(m, Line)]
+ plane_lines = [m for m in plane.get_family() if isinstance(m, Line)]
origin_words = TextMobject("Origin")
origin_words.shift(2*UP+2*LEFT)
dot = Dot(radius = 0.1).set_color(RED)
diff --git a/old_projects/eola/chapter4.py b/old_projects/eola/chapter4.py
index dde908b3f..453fe4c59 100644
--- a/old_projects/eola/chapter4.py
+++ b/old_projects/eola/chapter4.py
@@ -339,7 +339,7 @@ class IntroduceIdeaOfComposition(RotationThenShear):
def show_overall_effect(self, matrix):
everything = self.get_mobjects()
everything = list_difference_update(
- everything, matrix.submobject_family()
+ everything, matrix.get_family()
)
self.play(*list(map(FadeOut, everything)) + [Animation(matrix)])
new_matrix = matrix.copy()
diff --git a/old_projects/eola/chapter9.py b/old_projects/eola/chapter9.py
index e6d06b6d8..7b9a04753 100644
--- a/old_projects/eola/chapter9.py
+++ b/old_projects/eola/chapter9.py
@@ -843,7 +843,7 @@ class TranslateFromJenny(JenniferScene):
)
self.wait()
everything = self.get_mobjects()
- for submob in self.jenny_plane.submobject_family():
+ for submob in self.jenny_plane.get_family():
everything.remove(submob)
self.play(
Transform(self.jenny_plane, self.plane),
diff --git a/old_projects/hanoi.py b/old_projects/hanoi.py
index ae4640437..c7feeaeea 100644
--- a/old_projects/hanoi.py
+++ b/old_projects/hanoi.py
@@ -2847,7 +2847,7 @@ class SierpinskiGraphScene(Scene):
circles.set_stroke(width = self.graph_stroke_width)
self.nodes = VGroup()
- for circle in circles.submobject_family():
+ for circle in circles.get_family():
if not isinstance(circle, Circle):
continue
node = VGroup()
diff --git a/old_projects/wallis.py b/old_projects/wallis.py
index ffdd88b21..a87c0612d 100644
--- a/old_projects/wallis.py
+++ b/old_projects/wallis.py
@@ -1394,7 +1394,7 @@ class Lemma1(DistanceProductScene):
self.distance_lines,
self.numeric_distance_labels,
self.distance_product_column,
- ).submobject_family())
+ ).get_family())
self.play(
ApplyMethod(
observer_angle_tracker.set_value, observer_angle + 0.05 * TAU,
diff --git a/once_useful_constructs/fractals.py b/once_useful_constructs/fractals.py
index 51310d41c..a4e33851c 100644
--- a/once_useful_constructs/fractals.py
+++ b/once_useful_constructs/fractals.py
@@ -166,7 +166,7 @@ class PentagonalPiCreatureFractal(PentagonalFractal):
SelfSimilarFractal.init_colors(self)
internal_pis = [
pi
- for pi in self.submobject_family()
+ for pi in self.get_family()
if isinstance(pi, PiCreature)
]
colors = color_gradient(self.colors, len(internal_pis))
@@ -202,7 +202,7 @@ class PiCreatureFractal(VMobject):
VMobject.init_colors(self)
internal_pis = [
pi
- for pi in self.submobject_family()
+ for pi in self.get_family()
if isinstance(pi, PiCreature)
]
random.seed(self.random_seed)
diff --git a/scene/scene.py b/scene/scene.py
index 3210a6ead..cbeee2f2a 100644
--- a/scene/scene.py
+++ b/scene/scene.py
@@ -206,7 +206,7 @@ class Scene(Container):
# Return only those which are not in the family
# of another mobject from the scene
mobjects = self.get_mobjects()
- families = [m.submobject_family() for m in mobjects]
+ families = [m.get_family() for m in mobjects]
def is_top_level(mobject):
num_families = sum([
@@ -296,7 +296,7 @@ class Scene(Container):
for mob in list_to_examine:
if mob in set_to_remove:
continue
- intersect = set_to_remove.intersection(mob.submobject_family())
+ intersect = set_to_remove.intersection(mob.get_family())
if intersect:
add_safe_mobjects_from_list(mob.submobjects, intersect)
else: