Skip to content

Commit a71f9eb

Browse files
committed
Fix up label and vector result placement in bfs replacement semantics section.
1 parent 153d848 commit a71f9eb

2 files changed

Lines changed: 27 additions & 11 deletions

File tree

Chapter3/Scene0.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,15 @@ def construct(self):
6060

6161
# Chapter summary slide
6262
with self.voiceover(
63-
"""This chapter covers vector-matrix multiply, masking to control
64-
which outputs are written, complement masks for inverting selection,
65-
and replacement semantics for managing state between iterations."""
63+
"""This chapter covers matrix-vector and vector-matrix
64+
multiply, masking to control which outputs are written,
65+
complement masks for inverting selection, and replacement
66+
semantics for managing state between iterations."""
6667
):
6768
chapter_title = Text("Chapter 3: BFS Implementation", font_size=40).to_edge(UP)
6869

6970
outline = VGroup(
71+
Text("Matrix-vector multiply (vxm)", font_size=28),
7072
Text("Vector-matrix multiply (vxm)", font_size=28),
7173
Text("Masking to control output", font_size=28),
7274
Text("Complement masks", font_size=28),

Chapter3/Scene4.py

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,24 +47,38 @@ def construct(self):
4747
existing_cells = self.create_vector([1, 2, 3, "", "", ""], colors=[
4848
BLUE, BLUE, BLUE, DARK_GRAY, DARK_GRAY, DARK_GRAY
4949
])
50-
existing_row = VGroup(existing_label, existing_cells).arrange(RIGHT, buff=0.5)
51-
existing_row.shift(UP * 1.5)
5250

5351
# Mask
5452
mask_label = Text("mask:", font_size=24)
5553
mask_cells = self.create_vector(["F", "F", "F", "T", "T", "T"], colors=[
5654
RED, RED, RED, GREEN, GREEN, GREEN
5755
])
58-
mask_row = VGroup(mask_label, mask_cells).arrange(RIGHT, buff=0.5)
59-
mask_row.next_to(existing_row, DOWN, buff=0.4)
6056

6157
# Computed result (what would be written)
6258
result_label = Text("computed:", font_size=24)
6359
result_cells = self.create_vector(["", "", "", 5, 6, 7], colors=[
6460
DARK_GRAY, DARK_GRAY, DARK_GRAY, YELLOW, YELLOW, YELLOW
6561
])
66-
result_row = VGroup(result_label, result_cells).arrange(RIGHT, buff=0.5)
67-
result_row.next_to(mask_row, DOWN, buff=0.4)
62+
63+
# Align all labels to the left edge
64+
labels = VGroup(existing_label, mask_label, result_label)
65+
labels.arrange(DOWN, buff=0.75, aligned_edge=LEFT)
66+
67+
# Position cells to start at same X coordinate (right of widest label)
68+
existing_cells.next_to(existing_label, RIGHT, buff=0.5)
69+
mask_cells.move_to(existing_cells.get_center())
70+
mask_cells.set_y(mask_label.get_center()[1])
71+
result_cells.move_to(existing_cells.get_center())
72+
result_cells.set_y(result_label.get_center()[1])
73+
74+
# Create row groups for animation/fadeout
75+
existing_row = VGroup(existing_label, existing_cells)
76+
mask_row = VGroup(mask_label, mask_cells)
77+
result_row = VGroup(result_label, result_cells)
78+
79+
# Group everything and center vertically on screen
80+
all_vectors = VGroup(existing_row, mask_row, result_row)
81+
all_vectors.move_to(ORIGIN)
6882

6983
self.play(Write(existing_row))
7084
self.wait(0.5)
@@ -76,8 +90,8 @@ def construct(self):
7690
# Show the two outcomes side by side
7791
self.play(FadeOut(subtitle))
7892

79-
merge_title = Text("Default (Merge)", font_size=28, color=ORANGE).shift(LEFT * 3 + DOWN * 0.5)
80-
replace_title = Text("replace=True", font_size=28, color=PURPLE).shift(RIGHT * 3 + DOWN * 0.5)
93+
merge_title = Text("Default (Merge)", font_size=28, color=ORANGE).shift(LEFT * 3 + DOWN * 2)
94+
replace_title = Text("replace=True", font_size=28, color=PURPLE).shift(RIGHT * 3 + DOWN * 2)
8195

8296
with self.voiceover(
8397
"""Here's where the two behaviors differ. With default merge behavior,

0 commit comments

Comments
 (0)