Skip to content

Fix VMobject.point_from_proportion crash on non-finite points#4854

Open
Chessing234 wants to merge 1 commit into
ManimCommunity:mainfrom
Chessing234:fix/point-from-proportion-nonfinite
Open

Fix VMobject.point_from_proportion crash on non-finite points#4854
Chessing234 wants to merge 1 commit into
ManimCommunity:mainfrom
Chessing234:fix/point-from-proportion-nonfinite

Conversation

@Chessing234

Copy link
Copy Markdown

Overview

Fixes #4838.

VMobject.point_from_proportion iterates over the curve pieces, accumulating arc lengths until it reaches alpha * total_length. When the mobject contains non-finite points (e.g. a ParametricFunction whose callable returns NaN), every length is NaN, target_length is NaN, and every current_length + length >= target_length comparison is False. The loop therefore completes without returning and hits the internal:

Exception: Not sure how you reached here, please file a bug report ...

which is confusing and points users at the tracker for their own data issue.

Fix

  • Raise a clear ValueError when target_length is non-finite, naming the real cause (NaN/inf points).
  • For the remaining reachable case (floating-point summation leaving target_length marginally past the accumulated lengths at alpha ≈ 1), return the path endpoint instead of raising.

Test

Added test_vmobject_point_from_proportion_non_finite_points, which reproduces the crash (a corner set to NaN) and asserts the descriptive ValueError.

Made with Cursor

Non-finite points (e.g. a parametric function returning NaN) make every
curve length NaN, so the length-accumulation loop never triggers and hits
the internal 'Not sure how you reached here' exception (ManimCommunity#4838). Raise a
clear ValueError for non-finite points, and fall back to the path endpoint
for the alpha~=1 floating-point edge case.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"Exception: Not sure how you reached here" when ParametricFunction takes invalid values

1 participant