Skip to content

Commit e0eb924

Browse files
authored
Merge pull request #26775 from meeseeksmachine/auto-backport-of-pr-26767-on-v3.8.x
2 parents 0267cc1 + 6ce6fe0 commit e0eb924

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

lib/matplotlib/tests/test_transforms.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,25 @@ def test_pcolormesh_pre_transform_limits():
142142
assert_almost_equal(expected, ax.dataLim.get_points())
143143

144144

145+
def test_pcolormesh_gouraud_nans():
146+
np.random.seed(19680801)
147+
148+
values = np.linspace(0, 180, 3)
149+
radii = np.linspace(100, 1000, 10)
150+
z, y = np.meshgrid(values, radii)
151+
x = np.radians(np.random.rand(*z.shape) * 100)
152+
153+
fig = plt.figure()
154+
ax = fig.add_subplot(111, projection="polar")
155+
# Setting the limit to cause clipping of the r values causes NaN to be
156+
# introduced; these should not crash but be ignored as in other path
157+
# operations.
158+
ax.set_rlim(101, 1000)
159+
ax.pcolormesh(x, y, z, shading="gouraud")
160+
161+
fig.canvas.draw()
162+
163+
145164
def test_Affine2D_from_values():
146165
points = np.array([[0, 0],
147166
[10, 20],

src/_backend_agg.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,6 +1193,9 @@ inline void RendererAgg::_draw_gouraud_triangle(PointArray &points,
11931193
tpoints[i][j] = points(i, j);
11941194
}
11951195
trans.transform(&tpoints[i][0], &tpoints[i][1]);
1196+
if(std::isnan(tpoints[i][0]) || std::isnan(tpoints[i][1])) {
1197+
return;
1198+
}
11961199
}
11971200

11981201
span_alloc_t span_alloc;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy