| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Initialize padded vertex storage with NaN instead of empty so unused entries cannot overflow during projection before invalid masking. Co-authored-by: Cursor <cursoragent@cursor.com>
| Back | FazBrowse Home | New Git URL |
PR summary
When Poly3DCollection gets polygons with different vertex counts, _get_vector packs them into a rectangular array with np.empty(). Unused padding is marked in _invalid_vertices, but do_3d_projection still projects the whole array first. Uninitialized padding can hold huge float values and trigger nondeterministic RuntimeWarning: overflow encountered in dot.
This change initializes that padded storage with np.nan instead. NaN values do not overflow in the projection math, and do_3d_projection already ignores invalid floating point results. A regression test builds a square plus triangle collection, checks that padding is NaN, and draws under np.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.empty padding path, draft the regression test, and prepare the PR text. I reviewed the code path in Poly3DCollection._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