fix: initialize ragged Poly3DCollection padding with NaN - #32279
fix: initialize ragged Poly3DCollection padding with NaN#32279dajiaohuang wants to merge 1 commit into
Conversation
Replace np.empty() with np.full(..., np.nan) when creating padded storage for ragged polygons. Previously uninitialized padding could contain arbitrary values that caused overflow in projection. Fixes matplotlib#32272
|
Thank you for opening your first PR into Matplotlib! If you have not heard from us in a week or so, please leave a new comment below and that should bring it to our attention. Most of our reviewers are volunteers and sometimes things fall through the cracks. We also ask that you please finish addressing any review comments on this PR and wait for it to be merged (or closed) before opening a new one, as it can be a valuable learning experience to go through the review process. You can also join us on discourse chat for real-time discussion. For details on testing, writing docs, and our review process, please see the developer guide. We strive to be a welcoming and open project. Please follow our Code of Conduct. |
|
This account is opening a lot of PRs in a short space of time so I assume they are automated. Closing the PR and blocking the account for a week per our policy |
Problem
When
Poly3DCollectionreceives polygons with different numbers of vertices, it creates a padded rectangular array usingnp.empty(). Unused entries are marked as invalid via_invalid_vertices, butdo_3d_projection()projects the complete backing array before applying that mask. Uninitialized padding values can contain values nearfloat64max, causingRuntimeWarning: overflow encountered in dot.Fix
Replace
np.empty()withnp.full(..., np.nan)when creating padded storage for ragged polygons. NaN values propagate safely through matrix operations and are later masked out by_invalid_vertices.Fixes #32272