Fix Poly3DCollection ragged padding overflow warnings - #32310
Open
ShamikOfficial wants to merge 1 commit into
Open
Fix Poly3DCollection ragged padding overflow warnings#32310ShamikOfficial wants to merge 1 commit into
ShamikOfficial wants to merge 1 commit into
Conversation
Initialize padded vertex storage with NaN instead of empty so unused entries cannot overflow during projection before invalid masking. Co-authored-by: Cursor <[email protected]>
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.
PR summary
When
Poly3DCollectiongets polygons with different vertex counts,_get_vectorpacks them into a rectangular array withnp.empty(). Unused padding is marked in_invalid_vertices, butdo_3d_projectionstill projects the whole array first. Uninitialized padding can hold huge float values and trigger nondeterministicRuntimeWarning: overflow encountered in dot.This change initializes that padded storage with
np.naninstead. NaN values do not overflow in the projection math, anddo_3d_projectionalready ignores invalid floating point results. A regression test builds a square plus triangle collection, checks that padding is NaN, and draws undernp.errstate(over="raise").Closes #32272
Note: #32279 proposed the same fix earlier and was closed because of the automated-contribution account policy, not because the change itself was wrong.
AI Disclosure
I used Cursor to help locate the
np.emptypadding path, draft the regression test, and prepare the PR text. I reviewed the code path inPoly3DCollection._get_vector/do_3d_projection, confirmed why #32279 was closed, and verified the overflow reproduction plus the NaN-padding behavior locally before opening this PR.PR quality check