FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Backport PR #26767 on branch v3.8.x (Trim Gouraud triangles that contain NaN) by meeseeksmachine · Pull Request #26775 · matplotlib/matplotlib · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .h  (1) .py  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
19 changes: 19 additions & 0 deletions lib/matplotlib/tests/test_transforms.py
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
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,25 @@ def test_pcolormesh_pre_transform_limits():
assert_almost_equal(expected, ax.dataLim.get_points())


def test_pcolormesh_gouraud_nans():
np.random.seed(19680801)

values = np.linspace(0, 180, 3)
radii = np.linspace(100, 1000, 10)
z, y = np.meshgrid(values, radii)
x = np.radians(np.random.rand(*z.shape) * 100)

fig = plt.figure()
ax = fig.add_subplot(111, projection="polar")
# Setting the limit to cause clipping of the r values causes NaN to be
# introduced; these should not crash but be ignored as in other path
# operations.
ax.set_rlim(101, 1000)
ax.pcolormesh(x, y, z, shading="gouraud")

fig.canvas.draw()


def test_Affine2D_from_values():
points = np.array([[0, 0],
[10, 20],
Expand Down
3 changes: 3 additions & 0 deletions src/_backend_agg.h
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
Original file line number Diff line number Diff line change
Expand Up @@ -1193,6 +1193,9 @@ inline void RendererAgg::_draw_gouraud_triangle(PointArray &points,
tpoints[i][j] = points(i, j);
}
trans.transform(&tpoints[i][0], &tpoints[i][1]);
if(std::isnan(tpoints[i][0]) || std::isnan(tpoints[i][1])) {
return;
}
}

span_alloc_t span_alloc;
Expand Down

Back | FazBrowse Home | New Git URL