Skip to content
Open
Changes from all commits
Commits
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
16 changes: 13 additions & 3 deletions manim/mobject/types/vectorized_mobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -1592,6 +1592,16 @@ def construct(self):
if alpha == 1:
return self.points[-1]

# Non-finite points (e.g. a function returning NaN/inf) make every
# length NaN, so the comparisons below always fail and the loop falls
# through. Surface a clear error instead of an unreachable one.
if not np.all(np.isfinite(self.points)):
raise ValueError(
"Cannot compute point_from_proportion for a VMobject with "
"non-finite points; check that the underlying function does "
"not return NaN or infinite values."
)

curves_and_lengths = tuple(self.get_curve_functions_with_lengths())

target_length = alpha * sum(length for _, length in curves_and_lengths)
Expand All @@ -1607,9 +1617,9 @@ def construct(self):
return curve(residue)

current_length += length
raise Exception(
"Not sure how you reached here, please file a bug report at https://github.com/ManimCommunity/manim/issues/new/choose"
)
# Floating-point summation can leave current_length just short of
# target_length on the final curve; fall back to the last point.
return self.points[-1]

def proportion_from_point(
self,
Expand Down
Loading