{{ message }}
Fix Line3D.draw AttributeError for list coordinates with NaN - #32306
Open
ShamikOfficial wants to merge 1 commit into
Open
Fix Line3D.draw AttributeError for list coordinates with NaN#32306ShamikOfficial wants to merge 1 commit into
ShamikOfficial wants to merge 1 commit 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 <cursoragent@cursor.com>
scottshambaugh
approved these changes
Sep 6, 2026
Contributor
There was a problem hiding this comment.
I think we can drop the comment, but this PR lgtm
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
Closes #32127.
Line3D.set_data_3dis documented to take array-like input, but it stored the values as given.drawthen doesself._verts3d[0].shapewhen applying the invalid-scale mask, so a plain Python list with a NaN raisesAttributeError. Finite lists still drew, which is why this only shows up once a coordinate goes non-finite.I fixed it in the setter by coercing each coordinate with
np.asarray. That keepsdrawunchanged and makes_verts3dconsistently arrays. The other option isnp.shape(...)indraw, which would preserve the original list/tuple type fromget_data_3d(). I preferred normalizing at the setter because the draw path already treats these as arrays, and reading the data back still compares equal undernp.testing.assert_array_equal(covered by the existing set/get test).Added a regression test for the reported case: lists containing NaN, then
canvas.draw().AI Disclosure
Used Cursor to find the mplot3d code paths, draft the small patch/test, and help open the PR. I chose coercion in
set_data_3dovernp.shapeindrawafter reading the discussion on the earlier closed attempt (#32128). The summary above is written in my own words.PR quality check