Skip to content

fix(vmobject): clear error for non-finite points in point_from_proportion#4847

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

fix(vmobject): clear error for non-finite points in point_from_proportion#4847
Chessing234 wants to merge 1 commit into
ManimCommunity:mainfrom
Chessing234:fix/4838-point-from-proportion-nan

Conversation

@Chessing234

Copy link
Copy Markdown

Problem

Animating along a curve whose function returns NaN/inf (e.g. MoveAlongPath on a ParametricFunction with a negative base raised to a fractional power) raises:

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

Non-finite points make every curve length NaN. Because NaN comparisons are always False, the loop in point_from_proportion never returns and falls through to the unreachable 'file a bug report' exception (#4838).

Fix

  • Detect non-finite points up front and raise a clear ValueError telling the user their function produced NaN/inf.
  • Replace the cryptic fallthrough exception with a fallback to the last point, which can legitimately be reached due to floating-point summation leaving current_length just short of target_length on the final curve.

Closes #4838.

…tion

Functions returning NaN/inf (e.g. a negative base to a fractional power)
made every curve length NaN, so the loop fell through to a misleading
'file a bug report' exception. Raise a clear ValueError for non-finite
points, and fall back to the last point on float-rounding fallthrough.
Fixes ManimCommunity#4838.
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