Fix Line3D.draw AttributeError for list coordinates with NaN - #32306
Fix Line3D.draw AttributeError for list coordinates with NaN#32306ShamikOfficial wants to merge 3 commits into
Conversation
set_data_3d documents array-like input but stored values verbatim, while draw assumes .shape. Coerce with np.asarray so invalid-scale masking works. Co-authored-by: Cursor <[email protected]>
|
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. |
iccir
left a comment
There was a problem hiding this comment.
Everything looks good except for the comment!
|
Thanks @scottshambaugh. Dropped the comment. |
Co-authored-by: Cursor <[email protected]>
Keep set_data_3d storing inputs as given so get_data_3d behavior is unchanged, and make draw tolerate lists/tuples when masking invalid scale values. Co-authored-by: Cursor <[email protected]>
|
Updated per feedback on #32127: switched from coercing in This keeps |
PR summary
Closes #32127.
Line3D.set_data_3dis documented to take array-like input and stores the values as given.drawthen usedself._verts3d[0].shapewhen applying the invalid-scale mask, so a plain Python list with a NaN raisedAttributeError. Finite lists still drew, which is why this only shows up once a coordinate goes non-finite.This PR changes that access to
np.shape(self._verts3d[0])so lists and tuples work.set_data_3dis left alone, soget_data_3d()still returns whatever was passed in.Added a regression test for the reported case: lists containing NaN, then
canvas.draw(), and an assert thatget_data_3d()still returns the original lists.AI Disclosure
Used Cursor to find the mplot3d code paths, draft the small patch/test, and help open the PR. Updated the approach to
np.shapeindrawbased on review feedback on the issue. The summary above is written in my own words.PR quality check