Fix VMobject.point_from_proportion crash on non-finite points#4854
Open
Chessing234 wants to merge 1 commit into
Open
Fix VMobject.point_from_proportion crash on non-finite points#4854Chessing234 wants to merge 1 commit into
Chessing234 wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Fixes #4838.
VMobject.point_from_proportioniterates over the curve pieces, accumulating arc lengths until it reachesalpha * total_length. When the mobject contains non-finite points (e.g. aParametricFunctionwhose callable returnsNaN), every length isNaN,target_lengthisNaN, and everycurrent_length + length >= target_lengthcomparison isFalse. The loop therefore completes without returning and hits the internal:which is confusing and points users at the tracker for their own data issue.
Fix
ValueErrorwhentarget_lengthis non-finite, naming the real cause (NaN/inf points).target_lengthmarginally past the accumulated lengths atalpha ≈ 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 toNaN) and asserts the descriptiveValueError.Made with Cursor