mirror of
https://github.com/3b1b/manim.git
synced 2025-07-29 04:53:34 +08:00
After running 2to3
This commit is contained in:
@ -333,7 +333,7 @@ class IntroduceStolenNecklaceProblem(ThreeDScene):
|
||||
self.play(
|
||||
FadeOut(necklace.chain),
|
||||
*it.chain(*[
|
||||
map(Animation, group)
|
||||
list(map(Animation, group))
|
||||
for group in strand_groups
|
||||
])
|
||||
)
|
||||
@ -401,12 +401,12 @@ class IntroduceStolenNecklaceProblem(ThreeDScene):
|
||||
|
||||
def get_jewels_organized_by_type(self, jewels):
|
||||
return [
|
||||
VGroup(*filter(lambda m : m.get_color() == color, jewels))
|
||||
VGroup(*[m for m in jewels if m.get_color() == color])
|
||||
for color in map(Color, self.jewel_colors)
|
||||
]
|
||||
|
||||
def shuffle_jewels(self, jewels, run_time = 2, path_arc = np.pi/2, **kwargs):
|
||||
shuffled_indices = range(len(jewels))
|
||||
shuffled_indices = list(range(len(jewels)))
|
||||
random.shuffle(shuffled_indices)
|
||||
target_group = VGroup(*[
|
||||
jewel.copy().move_to(jewels[shuffled_indices[i]])
|
||||
@ -426,15 +426,15 @@ class IntroduceStolenNecklaceProblem(ThreeDScene):
|
||||
if jewel in jewel_type:
|
||||
return i
|
||||
raise Exception("Not in any jewel_types")
|
||||
type_numbers = map(jewel_to_type_number, jewels)
|
||||
type_numbers = list(map(jewel_to_type_number, jewels))
|
||||
|
||||
n_types = len(jewel_types)
|
||||
for slice_indices in it.combinations(range(1, len(jewels)), n_types):
|
||||
for slice_indices in it.combinations(list(range(1, len(jewels))), n_types):
|
||||
slice_indices = [0] + list(slice_indices) + [len(jewels)]
|
||||
if self.forced_binary_choices is not None:
|
||||
all_binary_choices = [self.forced_binary_choices]
|
||||
else:
|
||||
all_binary_choices = it.product(*[range(2)]*(n_types+1))
|
||||
all_binary_choices = it.product(*[list(range(2))]*(n_types+1))
|
||||
for binary_choices in all_binary_choices:
|
||||
subsets = [
|
||||
type_numbers[i1:i2]
|
||||
@ -813,7 +813,7 @@ class WalkEquatorPostTransform(GraphScene):
|
||||
self.play(ShowCreation(v_line))
|
||||
self.wait()
|
||||
self.play(FadeOut(v_line))
|
||||
self.play(*map(FadeOut, [tilted_eq, dots]))
|
||||
self.play(*list(map(FadeOut, [tilted_eq, dots])))
|
||||
|
||||
def draw_transverse_curve(self):
|
||||
transverse_curve = self.get_transverse_curve(self.great_arc_images)
|
||||
@ -1151,16 +1151,16 @@ class GeneralizeBorsukUlam(Scene):
|
||||
self.wait()
|
||||
|
||||
def get_condition(self):
|
||||
squares = map(TexMobject, [
|
||||
squares = list(map(TexMobject, [
|
||||
"x_%d^2"%d
|
||||
for d in range(1, 1+self.n_dims)
|
||||
])
|
||||
]))
|
||||
for square, color in zip(squares, self.colors):
|
||||
square[0].set_color(color)
|
||||
square[-1].set_color(color)
|
||||
plusses = [TexMobject("+") for x in range(self.n_dims-1)]
|
||||
plusses += [TexMobject("=1")]
|
||||
condition = VGroup(*it.chain(*zip(squares, plusses)))
|
||||
condition = VGroup(*it.chain(*list(zip(squares, plusses))))
|
||||
condition.arrange_submobjects(RIGHT)
|
||||
|
||||
return condition
|
||||
@ -1354,7 +1354,7 @@ class MakeTwoJewelCaseContinuous(IntroduceStolenNecklaceProblem):
|
||||
jewels.submobjects.sort(
|
||||
lambda m1, m2 : cmp(m1.get_center()[0], m2.get_center()[0])
|
||||
)
|
||||
remaining_indices = range(len(jewels))
|
||||
remaining_indices = list(range(len(jewels)))
|
||||
remaining_indices.remove(example_index)
|
||||
|
||||
example_segment = self.color_necklace_by_indices(example_index)
|
||||
@ -1365,10 +1365,7 @@ class MakeTwoJewelCaseContinuous(IntroduceStolenNecklaceProblem):
|
||||
lambda m1, m2 : cmp(m1.get_center()[0], m2.get_center()[0])
|
||||
)
|
||||
segment_types = VGroup(*[
|
||||
VGroup(*filter(
|
||||
lambda m : m.get_color() == Color(color),
|
||||
segments
|
||||
))
|
||||
VGroup(*[m for m in segments if m.get_color() == Color(color)])
|
||||
for color in self.jewel_colors
|
||||
])
|
||||
|
||||
@ -1437,7 +1434,7 @@ class MakeTwoJewelCaseContinuous(IntroduceStolenNecklaceProblem):
|
||||
for i in slice_indices[1:-1]
|
||||
])
|
||||
cut_points = [
|
||||
map(chain.point_from_proportion, pair)
|
||||
list(map(chain.point_from_proportion, pair))
|
||||
for pair in cut_proportions
|
||||
]
|
||||
v_lines = VGroup(*[DashedLine(UP, DOWN) for x in range(2)])
|
||||
@ -1529,9 +1526,9 @@ class MakeTwoJewelCaseContinuous(IntroduceStolenNecklaceProblem):
|
||||
))
|
||||
self.play(Blink(morty))
|
||||
self.wait()
|
||||
self.play(*map(FadeOut, [
|
||||
self.play(*list(map(FadeOut, [
|
||||
morty, morty.bubble, morty.bubble.content
|
||||
]))
|
||||
])))
|
||||
|
||||
def shift_divide_off_tick_marks(self):
|
||||
groups = self.groups
|
||||
@ -1618,13 +1615,13 @@ class MakeTwoJewelCaseContinuous(IntroduceStolenNecklaceProblem):
|
||||
self.wait()
|
||||
self.play(
|
||||
emerald_segments.restore,
|
||||
*map(FadeOut, [brace, label])
|
||||
*list(map(FadeOut, [brace, label]))
|
||||
)
|
||||
|
||||
self.wait()
|
||||
self.play(ShowCreation(arrow2))
|
||||
self.wait()
|
||||
self.play(*map(FadeOut, [words, arrow1, arrow2]))
|
||||
self.play(*list(map(FadeOut, [words, arrow1, arrow2])))
|
||||
|
||||
for line in v_lines:
|
||||
self.play(line.shift, segment_width*LEFT/2)
|
||||
@ -1704,7 +1701,7 @@ class ChoicesInNecklaceCutting(ReconfigurableScene):
|
||||
] + [final_num_pair]
|
||||
|
||||
point_pairs = [
|
||||
map(self.interval.number_to_point, num_pair)
|
||||
list(map(self.interval.number_to_point, num_pair))
|
||||
for num_pair in num_pairs
|
||||
]
|
||||
|
||||
@ -1763,9 +1760,9 @@ class ChoicesInNecklaceCutting(ReconfigurableScene):
|
||||
self.wait()
|
||||
self.transition_to_alt_config(denoms = [3, 3, 3])
|
||||
self.wait()
|
||||
self.play(*map(FadeOut, list(braces) + [
|
||||
self.play(*list(map(FadeOut, list(braces) + [
|
||||
brace.concrete_label for brace in braces
|
||||
]))
|
||||
])))
|
||||
|
||||
self.choice_one_words = words
|
||||
|
||||
@ -1781,7 +1778,7 @@ class ChoicesInNecklaceCutting(ReconfigurableScene):
|
||||
)
|
||||
|
||||
self.play(Write(words))
|
||||
self.play(*map(FadeIn, [boxes, labels]))
|
||||
self.play(*list(map(FadeIn, [boxes, labels])))
|
||||
for binary_choices in it.product(*[[0, 1]]*3):
|
||||
self.play(*[
|
||||
ApplyMethod(group.move_to, group.target_points[choice])
|
||||
@ -2061,7 +2058,7 @@ class NecklaceDivisionSphereAssociation(ChoicesInNecklaceCutting):
|
||||
)
|
||||
|
||||
self.play(*it.chain(
|
||||
map(GrowFromCenter, braces),
|
||||
list(map(GrowFromCenter, braces)),
|
||||
[Write(brace.label) for brace in braces]
|
||||
))
|
||||
self.wait()
|
||||
@ -2070,14 +2067,14 @@ class NecklaceDivisionSphereAssociation(ChoicesInNecklaceCutting):
|
||||
|
||||
def add_boxes_and_labels(self):
|
||||
boxes, labels = self.get_boxes_and_labels()
|
||||
self.play(*map(FadeIn, [boxes, labels]))
|
||||
self.play(*list(map(FadeIn, [boxes, labels])))
|
||||
self.wait()
|
||||
|
||||
def show_binary_choice_association(self):
|
||||
groups = self.get_groups()
|
||||
self.swapping_anims = []
|
||||
final_choices = [1, 0, 1]
|
||||
quads = zip(self.braces, self.denoms, groups, final_choices)
|
||||
quads = list(zip(self.braces, self.denoms, groups, final_choices))
|
||||
for brace, denom, group, final_choice in quads:
|
||||
char = brace.label.args[0][1]
|
||||
choices = [
|
||||
@ -2186,12 +2183,12 @@ class TotalLengthOfEachJewelEquals(NecklaceDivisionSphereAssociation, ThreeDScen
|
||||
|
||||
def get_fair_division_indices(self, colors):
|
||||
colors = np.array(list(colors))
|
||||
color_types = map(Color, set([c.get_hex_l() for c in colors]))
|
||||
color_types = list(map(Color, set([c.get_hex_l() for c in colors])))
|
||||
type_to_count = dict([
|
||||
(color, sum(colors == color))
|
||||
for color in color_types
|
||||
])
|
||||
for i1, i2 in it.combinations(range(1, len(colors)-1), 2):
|
||||
for i1, i2 in it.combinations(list(range(1, len(colors)-1)), 2):
|
||||
bools = [
|
||||
sum(colors[i1:i2] == color) == type_to_count[color]/2
|
||||
for color in color_types
|
||||
@ -2202,10 +2199,10 @@ class TotalLengthOfEachJewelEquals(NecklaceDivisionSphereAssociation, ThreeDScen
|
||||
|
||||
def demonstrate_fair_division(self):
|
||||
segments, tick_marks = self.necklace
|
||||
color_types = map(Color, set([
|
||||
color_types = list(map(Color, set([
|
||||
segment.get_color().get_hex_l()
|
||||
for segment in segments
|
||||
]))
|
||||
])))
|
||||
top_segments = VGroup(*it.chain(
|
||||
self.groups[0][0],
|
||||
self.groups[2][0],
|
||||
@ -2213,10 +2210,7 @@ class TotalLengthOfEachJewelEquals(NecklaceDivisionSphereAssociation, ThreeDScen
|
||||
bottom_segments = self.groups[1][0]
|
||||
for color in color_types:
|
||||
monochrome_groups = [
|
||||
VGroup(*filter(
|
||||
lambda segment: segment.get_color() == color,
|
||||
segment_group
|
||||
))
|
||||
VGroup(*[segment for segment in segment_group if segment.get_color() == color])
|
||||
for segment_group in (top_segments, bottom_segments)
|
||||
]
|
||||
labels = VGroup()
|
||||
@ -2484,7 +2478,7 @@ class FourDBorsukUlam(GeneralizeBorsukUlam, PiCreatureScene):
|
||||
Write(brace_text)
|
||||
)
|
||||
self.wait()
|
||||
self.play(*map(FadeOut, [brace, brace_text]))
|
||||
self.play(*list(map(FadeOut, [brace, brace_text])))
|
||||
self.wait()
|
||||
self.play(
|
||||
FadeIn(lhs),
|
||||
|
Reference in New Issue
Block a user