Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
93147e3
sub_alphas is derived directly from to_update so they're guaranteed t…
Oll-iver Jan 24, 2026
b8eb909
self.shapes is initialised as a direct copy of the mobject, guarantee…
Oll-iver Jan 24, 2026
9883fcf
linspace in this case guarantees both arrays are of equal size (self.…
Oll-iver Jan 24, 2026
0620eea
Any transformation already requires that each datapoint in the first …
Oll-iver Jan 24, 2026
5bc2273
Replaced arange with linspace, eliminates risk of floating point erro…
Oll-iver Jan 24, 2026
68c9b93
all_arc_configs is either defined specifically by length of point_pai…
Oll-iver Jan 25, 2026
3b85664
There should always be an equal amount of start and end anchors; radi…
Oll-iver Jan 25, 2026
d6824a2
boundary_times always contains has an even length so both 'slices' in…
Oll-iver Jan 25, 2026
2d8bbb6
colors_in_gradient is defined to be the same length as p_list_complet…
Oll-iver Jan 25, 2026
0da9899
In most cases here, the tuples are either defined to be of same lengt…
Oll-iver Jan 25, 2026
42c0791
Reverting _add_x_axis_labels() zip() function back
Oll-iver Jan 25, 2026
c7ce2f3
Reverted strict zip usage
Oll-iver Jan 25, 2026
f18121b
color_gradient is defined to be same length as p_list_complete & with…
Oll-iver Jan 25, 2026
d6ffe12
align_data and lock_matching_data have no validation to ensure tuples…
Oll-iver Jan 25, 2026
8b8ab0a
All tuples in zip() functions here are either clearly the same size o…
Oll-iver Jan 25, 2026
8ef8c84
The tuples in the zip() function will clearly be of equal length, the…
Oll-iver Jan 25, 2026
945b1a8
In the ingest_submobjects function arrays is a one to one mapping of …
Oll-iver Jan 25, 2026
be26595
Every usage of zip() consists of tuples that are either manipulated t…
Oll-iver Jan 25, 2026
3fa6d54
the zip() function in bezier_remap will always consist of equal lengt…
Oll-iver Jan 25, 2026
6b8c482
The zip() function color_gradient() will always consist of equal leng…
Oll-iver Jan 25, 2026
7e33f5d
The tuples in the zip() function in adjacent_n_tuples will always be …
Oll-iver Jan 25, 2026
0afc7e4
The find_intersection() contains a zip() function that has been set t…
Oll-iver Jan 25, 2026
9f6ef7a
Changed zip() function to have strict=True in __init__() as custom_la…
Oll-iver Jan 25, 2026
827d124
Several instances of zip() set to strict=True. In add_coordinates we …
Oll-iver Jan 25, 2026
78d4773
zip() function bool changed to strict=True in all these test cases. M…
Oll-iver Jan 25, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion manim/animation/composition.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def interpolate(self, alpha: float) -> None:
sub_alphas[(sub_alphas > 1) | with_zero_run_time] = 1

for anim_to_update, sub_alpha in zip(
to_update["anim"], sub_alphas, strict=False
to_update["anim"], sub_alphas, strict=True
):
anim_to_update.interpolate(sub_alpha)

Expand Down
2 changes: 1 addition & 1 deletion manim/animation/creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ def __init__(

def interpolate_mobject(self, alpha: float) -> None:
alpha = self.rate_func(alpha)
for original_shape, shape in zip(self.shapes, self.mobject, strict=False):
for original_shape, shape in zip(self.shapes, self.mobject, strict=True):
shape.restore()
fill_opacity = original_shape.get_fill_opacity()
stroke_opacity = original_shape.get_stroke_opacity()
Expand Down
2 changes: 1 addition & 1 deletion manim/animation/indication.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ def __init__(
for stroke_width, time_width in zip(
np.linspace(0, max_stroke_width, self.n_segments),
np.linspace(max_time_width, 0, self.n_segments),
strict=False,
strict=True,
)
),
)
Expand Down
8 changes: 4 additions & 4 deletions manim/animation/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,8 @@ def get_all_families_zipped(self) -> Iterable[tuple]: # more precise typing?
self.target_copy,
]
if config.renderer == RendererType.OPENGL:
return zip(*(mob.get_family() for mob in mobs), strict=False)
return zip(*(mob.family_members_with_points() for mob in mobs), strict=False)
return zip(*(mob.get_family() for mob in mobs), strict=True)
return zip(*(mob.family_members_with_points() for mob in mobs), strict=True)

def interpolate_submobject(
self,
Expand Down Expand Up @@ -741,7 +741,7 @@ def __init__(
def create_target(self) -> Group:
target = self.group.copy()
cycled_targets = [target[-1], *target[:-1]]
for m1, m2 in zip(cycled_targets, self.group, strict=False):
for m1, m2 in zip(cycled_targets, self.group, strict=True):
m1.move_to(m2)
return target

Expand Down Expand Up @@ -929,5 +929,5 @@ def ghost_to(self, source, target):
"""Replaces the source submobjects by the target submobjects and sets
the opacity to 0.
"""
for sm0, sm1 in zip(source.get_family(), target.get_family(), strict=False):
for sm0, sm1 in zip(source.get_family(), target.get_family(), strict=True):
super().ghost_to(sm0, sm1)
5 changes: 2 additions & 3 deletions manim/camera/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -756,9 +756,8 @@ def set_cairo_context_color(
points = vmobject.get_gradient_start_and_end_points()
points = self.transform_points_pre_display(vmobject, points)
pat = cairo.LinearGradient(*it.chain(*(point[:2] for point in points)))
step = 1.0 / (len(rgbas) - 1)
offsets = np.arange(0, 1 + step, step)
for rgba, offset in zip(rgbas, offsets, strict=False):
offsets = np.linspace(0, 1, len(rgbas))
for rgba, offset in zip(rgbas, offsets, strict=True):
pat.add_color_stop_rgba(offset, *rgba[2::-1], rgba[3])
ctx.set_source(pat)
return self
Expand Down
2 changes: 1 addition & 1 deletion manim/mobject/geometry/arc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1231,7 +1231,7 @@ def __init__(

arcs = [
ArcBetweenPoints(*pair, **conf)
for (pair, conf) in zip(point_pairs, all_arc_configs, strict=False)
for (pair, conf) in zip(point_pairs, all_arc_configs, strict=True)
]

super().__init__(**kwargs)
Expand Down
6 changes: 3 additions & 3 deletions manim/mobject/geometry/polygram.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def get_vertex_groups(self) -> list[Point3D_Array]:
# times, then .get_vertex_groups() splits it into N vertex groups.
group = []
for start, end in zip(
self.get_start_anchors(), self.get_end_anchors(), strict=False
self.get_start_anchors(), self.get_end_anchors(), strict=True
):
group.append(start)

Expand Down Expand Up @@ -240,7 +240,7 @@ def construct(self):
radius_list = radius * ceil(len(vertex_group) / len(radius))

for current_radius, (v1, v2, v3) in zip(
radius_list, adjacent_n_tuples(vertex_group, 3), strict=False
radius_list, adjacent_n_tuples(vertex_group, 3), strict=True
):
vect1 = v2 - v1
vect2 = v3 - v2
Expand Down Expand Up @@ -552,7 +552,7 @@ def __init__(
)

vertices: list[npt.NDArray] = []
for pair in zip(outer_vertices, inner_vertices, strict=False):
for pair in zip(outer_vertices, inner_vertices, strict=True):
vertices.extend(pair)

super().__init__(*vertices, **kwargs)
Expand Down
6 changes: 3 additions & 3 deletions manim/mobject/graphing/coordinate_systems.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ def add_coordinates(
zip(
tick_range,
axis.scaling.get_custom_labels(tick_range),
strict=False,
strict=True,
)
)
)
Expand Down Expand Up @@ -1300,7 +1300,7 @@ def construct(self):

colors = color_gradient(color, len(x_range_array))

for x, color in zip(x_range_array, colors, strict=False):
for x, color in zip(x_range_array, colors, strict=True):
if input_sample_type == "left":
sample_input = x
elif input_sample_type == "right":
Expand Down Expand Up @@ -2362,7 +2362,7 @@ def construct(self):

vertices = [
self.coords_to_point(x, y, z)
for x, y, z in zip(x_values, y_values, z_values, strict=False)
for x, y, z in zip(x_values, y_values, z_values, strict=True)
]
graph.set_points_as_corners(vertices)
line_graph["line_graph"] = graph
Expand Down
2 changes: 1 addition & 1 deletion manim/mobject/graphing/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def generate_points(self) -> Self:
else:
boundary_times = [self.t_min, self.t_max]

for t1, t2 in zip(boundary_times[0::2], boundary_times[1::2], strict=False):
for t1, t2 in zip(boundary_times[0::2], boundary_times[1::2], strict=True):
t_range = np.array(
[
*self.scaling.function(np.arange(t1, t2, self.t_step)),
Expand Down
2 changes: 1 addition & 1 deletion manim/mobject/graphing/number_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ def __init__(
zip(
tick_range,
custom_labels,
strict=False,
strict=True,
)
),
)
Expand Down
4 changes: 2 additions & 2 deletions manim/mobject/graphing/probability.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def get_division_along_dimension(

last_point = self.get_edge_center(-vect)
parts = VGroup()
for factor, color in zip(p_list_complete, colors_in_gradient, strict=False):
for factor, color in zip(p_list_complete, colors_in_gradient, strict=True):
part = SampleSpace()
part.set_fill(color, 1)
part.replace(self, stretch=True)
Expand Down Expand Up @@ -368,7 +368,7 @@ def _add_x_axis_labels(self) -> None:
labels = VGroup()

for i, (value, bar_name) in enumerate(
zip(val_range, self.bar_names, strict=False)
zip(val_range, self.bar_names, strict=True)
):
# to accommodate negative bars, the label may need to be
# below or above the x_axis depending on the value of the bar
Expand Down
12 changes: 6 additions & 6 deletions manim/mobject/mobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -2016,7 +2016,7 @@ def set_submobject_colors_by_gradient(self, *colors: Iterable[ParsableManimColor
mobs = self.family_members_with_points()
new_colors = color_gradient(colors, len(mobs))

for mob, color in zip(mobs, new_colors, strict=False):
for mob, color in zip(mobs, new_colors, strict=True):
mob.set_color(color, family=False)
return self

Expand Down Expand Up @@ -2309,7 +2309,7 @@ def get_pieces(self, n_pieces: float) -> Group:
return Group(
*(
template.copy().pointwise_become_partial(self, a1, a2)
for a1, a2 in zip(alphas[:-1], alphas[1:], strict=False)
for a1, a2 in zip(alphas[:-1], alphas[1:], strict=True)
)
)

Expand Down Expand Up @@ -2502,7 +2502,7 @@ def construct(self):
x = VGroup(s1, s2, s3, s4).set_x(0).arrange(buff=1.0)
self.add(x)
"""
for m1, m2 in zip(self.submobjects, self.submobjects[1:], strict=False):
for m1, m2 in zip(self.submobjects[:-1], self.submobjects[1:], strict=True):
m2.next_to(m1, direction, buff, **kwargs)
if center:
self.center()
Expand Down Expand Up @@ -2887,7 +2887,7 @@ def align_data(self, mobject: Mobject, skip_point_alignment: bool = False) -> No
if not skip_point_alignment:
self.align_points(mobject)
# Recurse
for m1, m2 in zip(self.submobjects, mobject.submobjects, strict=False):
for m1, m2 in zip(self.submobjects, mobject.submobjects, strict=True):
m1.align_data(m2)

def get_point_mobject(self, center=None):
Expand Down Expand Up @@ -2957,7 +2957,7 @@ def add_n_more_submobjects(self, n: int) -> Self | None:
repeat_indices = (np.arange(target) * curr) // target
split_factors = [sum(repeat_indices == i) for i in range(curr)]
new_submobs = []
for submob, sf in zip(self.submobjects, split_factors, strict=False):
for submob, sf in zip(self.submobjects, split_factors, strict=True):
new_submobs.append(submob)
new_submobs.extend(submob.copy().fade(1) for _ in range(1, sf))
self.submobjects = new_submobs
Expand Down Expand Up @@ -3169,7 +3169,7 @@ def construct(self):
mobject.move_to(self.get_center())

self.align_data(mobject, skip_point_alignment=True)
for sm1, sm2 in zip(self.get_family(), mobject.get_family(), strict=False):
for sm1, sm2 in zip(self.get_family(), mobject.get_family(), strict=True):
sm1.points = np.array(sm2.points)
sm1.interpolate_color(sm1, sm2, 1)
return self
Expand Down
14 changes: 7 additions & 7 deletions manim/mobject/opengl/opengl_mobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -1055,7 +1055,7 @@ def construct(self):
x = OpenGLVGroup(s1, s2, s3, s4).set_x(0).arrange(buff=1.0)
self.add(x)
"""
for m1, m2 in zip(self.submobjects, self.submobjects[1:], strict=False):
for m1, m2 in zip(self.submobjects[:-1], self.submobjects[1:], strict=True):
m2.next_to(m1, direction, **kwargs)
if center:
self.center()
Expand Down Expand Up @@ -2190,7 +2190,7 @@ def set_rgba_array(
# Color and opacity
if color is not None and opacity is not None:
rgbas: FloatRGBA_Array = np.array(
[[*rgb, o] for rgb, o in zip(*make_even(rgbs, opacities), strict=False)]
[[*rgb, o] for rgb, o in zip(*make_even(rgbs, opacities), strict=True)]
)
for mob in self.get_family(recurse):
mob.data[name] = rgbas.copy()
Expand Down Expand Up @@ -2266,7 +2266,7 @@ def set_submobject_colors_by_gradient(self, *colors: ParsableManimColor) -> Self
mobs = self.submobjects
new_colors = color_gradient(colors, len(mobs))

for mob, color in zip(mobs, new_colors, strict=False):
for mob, color in zip(mobs, new_colors, strict=True):
mob.set_color(color)
return self

Expand Down Expand Up @@ -2481,7 +2481,7 @@ def get_pieces(self, n_pieces: int) -> OpenGLMobject:
return OpenGLGroup(
*(
template.copy().pointwise_become_partial(self, a1, a2)
for a1, a2 in zip(alphas[:-1], alphas[1:], strict=False)
for a1, a2 in zip(alphas[:-1], alphas[1:], strict=True)
)
)

Expand Down Expand Up @@ -2612,7 +2612,7 @@ def align_family(self, mobject: OpenGLMobject) -> Self:
mob1.add_n_more_submobjects(max(0, n2 - n1))
mob2.add_n_more_submobjects(max(0, n1 - n2))
# Recurse
for sm1, sm2 in zip(mob1.submobjects, mob2.submobjects, strict=False):
for sm1, sm2 in zip(mob1.submobjects, mob2.submobjects, strict=True):
sm1.align_family(sm2)
return self

Expand All @@ -2638,7 +2638,7 @@ def add_n_more_submobjects(self, n: int) -> Self:
repeat_indices = (np.arange(target) * curr) // target
split_factors = [(repeat_indices == i).sum() for i in range(curr)]
new_submobs = []
for submob, sf in zip(self.submobjects, split_factors, strict=False):
for submob, sf in zip(self.submobjects, split_factors, strict=True):
new_submobs.append(submob)
for _ in range(1, sf):
new_submob = submob.copy()
Expand Down Expand Up @@ -2780,7 +2780,7 @@ def construct(self):
mobject.move_to(self.get_center())

self.align_family(mobject)
for sm1, sm2 in zip(self.get_family(), mobject.get_family(), strict=False):
for sm1, sm2 in zip(self.get_family(), mobject.get_family(), strict=True):
sm1.set_data(sm2.data)
sm1.set_uniforms(sm2.uniforms)
self.refresh_bounding_box(recurse_down=True)
Expand Down
8 changes: 4 additions & 4 deletions manim/mobject/opengl/opengl_vectorized_mobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ def match_style(self, vmobject, recurse=True):
return self
elif len(submobs2) == 0:
submobs2 = [vmobject]
for sm1, sm2 in zip(*make_even(submobs1, submobs2), strict=False):
for sm1, sm2 in zip(*make_even(submobs1, submobs2), strict=True):
sm1.match_style(sm2)
return self

Expand Down Expand Up @@ -580,7 +580,7 @@ def subdivide_sharp_curves(self, angle_threshold=30 * DEGREES, recurse=True):
new_points.extend(
[
partial_bezier_points(tup, a1, a2)
for a1, a2 in zip(alphas, alphas[1:], strict=False)
for a1, a2 in zip(alphas[:-1], alphas[1:], strict=True)
],
)
else:
Expand Down Expand Up @@ -769,7 +769,7 @@ def get_subpaths_from_points(self, points):
split_indices = [0, *split_indices, len(points)]
return [
points[i1:i2]
for i1, i2 in zip(split_indices, split_indices[1:], strict=False)
for i1, i2 in zip(split_indices[:-1], split_indices[1:], strict=True)
if (i2 - i1) >= nppc
]

Expand Down Expand Up @@ -1093,7 +1093,7 @@ def get_anchors(self) -> Iterable[np.ndarray]:

s = self.get_start_anchors()
e = self.get_end_anchors()
return list(it.chain.from_iterable(zip(s, e, strict=False)))
return list(it.chain.from_iterable(zip(s, e, strict=True)))

def get_points_without_null_curves(self, atol=1e-9):
nppc = self.n_points_per_curve
Expand Down
2 changes: 1 addition & 1 deletion manim/mobject/three_d/polyhedra.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def get_edges(self, faces_list: list[list[int]]) -> list[tuple[int, int]]:
"""Creates list of cyclic pairwise tuples."""
edges: list[tuple[int, int]] = []
for face in faces_list:
edges += zip(face, face[1:] + face[:1], strict=False)
edges += zip(face, face[1:] + face[:1], strict=True)
return edges

def create_faces(
Expand Down
2 changes: 1 addition & 1 deletion manim/mobject/types/point_cloud_mobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def get_all_rgbas(self) -> npt.NDArray:
def ingest_submobjects(self) -> Self:
attrs = self.get_array_attrs()
arrays = list(map(self.get_merged_array, attrs))
for attr, array in zip(attrs, arrays, strict=False):
for attr, array in zip(attrs, arrays, strict=True):
setattr(self, attr, array)
self.submobjects = []
return self
Expand Down
8 changes: 4 additions & 4 deletions manim/mobject/types/vectorized_mobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def generate_rgbas_array(
rgbas: FloatRGBA_Array = np.array(
[
c.to_rgba_with_alpha(o)
for c, o in zip(*make_even(colors, opacities), strict=False)
for c, o in zip(*make_even(colors, opacities), strict=True)
],
)

Expand Down Expand Up @@ -461,7 +461,7 @@ def match_style(self, vmobject: VMobject, family: bool = True) -> Self:
return self
elif len(submobs2) == 0:
submobs2 = [vmobject]
for sm1, sm2 in zip(*make_even(submobs1, submobs2), strict=False):
for sm1, sm2 in zip(*make_even(submobs1, submobs2), strict=True):
sm1.match_style(sm2)
return self

Expand Down Expand Up @@ -1337,7 +1337,7 @@ def _gen_subpaths_from_points(
split_indices = [0] + list(filtered) + [len(points)]
return (
points[i1:i2]
for i1, i2 in zip(split_indices, split_indices[1:], strict=False)
for i1, i2 in zip(split_indices[:-1], split_indices[1:], strict=True)
if (i2 - i1) >= nppcc
)

Expand Down Expand Up @@ -1691,7 +1691,7 @@ def get_anchors(self) -> list[Point3D]:

s = self.get_start_anchors()
e = self.get_end_anchors()
return list(it.chain.from_iterable(zip(s, e, strict=False)))
return list(it.chain.from_iterable(zip(s, e, strict=True)))

def get_points_defining_boundary(self) -> Point3D_Array:
# Probably returns all anchors, but this is weird regarding the name of the method.
Expand Down
2 changes: 1 addition & 1 deletion manim/utils/bezier.py
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,7 @@ def bezier_remap(

new_tuples = np.empty((new_number_of_curves, nppc, dim))
index = 0
for curve, sf in zip(bezier_tuples, split_factors, strict=False):
for curve, sf in zip(bezier_tuples, split_factors, strict=True):
new_tuples[index : index + sf] = subdivide_bezier(curve, sf).reshape(
sf, nppc, dim
)
Expand Down
2 changes: 1 addition & 1 deletion manim/utils/color/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1418,7 +1418,7 @@ def color_gradient(
floors[-1] = num_colors - 2
return [
rgb_to_color((rgbs[i] * (1 - alpha)) + (rgbs[i + 1] * alpha))
for i, alpha in zip(floors, alphas_mod1, strict=False)
for i, alpha in zip(floors, alphas_mod1, strict=True)
]


Expand Down
2 changes: 1 addition & 1 deletion manim/utils/iterables.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def adjacent_n_tuples(objects: Sequence[T], n: int) -> zip[tuple[T, ...]]:
>>> list(adjacent_n_tuples([1, 2, 3, 4], 3))
[(1, 2, 3), (2, 3, 4), (3, 4, 1), (4, 1, 2)]
"""
return zip(*([*objects[k:], *objects[:k]] for k in range(n)), strict=False)
return zip(*([*objects[k:], *objects[:k]] for k in range(n)), strict=True)


def adjacent_pairs(objects: Sequence[T]) -> zip[tuple[T, ...]]:
Expand Down
Loading