Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 57f7fdf

Browse filesBrowse files
Merge pull request #29175 from vicliu2001/v3.9.x
addressing issue #29156, converted ps to array before slicing
2 parents 1d7e71e + 3982428 commit 57f7fdf
Copy full SHA for 57f7fdf

File tree

2 files changed

+13
-1
lines changed
Filter options

2 files changed

+13
-1
lines changed

‎lib/mpl_toolkits/mplot3d/art3d.py

Copy file name to clipboardExpand all lines: lib/mpl_toolkits/mplot3d/art3d.py
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1218,6 +1218,7 @@ def _generate_normals(polygons):
12181218
v2 = np.empty((len(polygons), 3))
12191219
for poly_i, ps in enumerate(polygons):
12201220
n = len(ps)
1221+
ps = np.asarray(ps)
12211222
i1, i2, i3 = 0, n//3, 2*n//3
12221223
v1[poly_i, :] = ps[i1, :] - ps[i2, :]
12231224
v2[poly_i, :] = ps[i2, :] - ps[i3, :]

‎lib/mpl_toolkits/mplot3d/tests/test_art3d.py

Copy file name to clipboardExpand all lines: lib/mpl_toolkits/mplot3d/tests/test_art3d.py
+12-1Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import matplotlib.pyplot as plt
44

55
from matplotlib.backend_bases import MouseEvent
6-
from mpl_toolkits.mplot3d.art3d import Line3DCollection
6+
from mpl_toolkits.mplot3d.art3d import Line3DCollection, Poly3DCollection
77

88

99
def test_scatter_3d_projection_conservation():
@@ -54,3 +54,14 @@ def test_zordered_error():
5454
ax.add_collection(Line3DCollection(lc))
5555
ax.scatter(*pc, visible=False)
5656
plt.draw()
57+
58+
59+
def test_generate_normals():
60+
# Smoke test for https://github.com/matplotlib/matplotlib/issues/29156
61+
vertices = ((0, 0, 0), (0, 5, 0), (5, 5, 0), (5, 0, 0))
62+
shape = Poly3DCollection([vertices], edgecolors='r', shade=True)
63+
64+
fig = plt.figure()
65+
ax = fig.add_subplot(projection='3d')
66+
ax.add_collection3d(shape)
67+
plt.draw()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.