8000 smoke test for hatchcolors coercion · matplotlib/matplotlib@9d0ec23 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9d0ec23

Browse files
committed
smoke test for hatchcolors coercion
1 parent 7668535 commit 9d0ec23

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed

lib/matplotlib/tests/test_collections.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1453,3 +1453,36 @@ def test_collection_hatchcolor_fallback_logic():
14531453
col = PathCollection([path], hatch='//')
14541454
assert_array_equal(col.get_hatchcolor(),
14551455
mpl.colors.to_rgba_array(mpl.rcParams['patch.edgecolor']))
1456+
1457+
1458+
@pytest.mark.parametrize('backend', ['agg', 'pdf', 'svg', 'ps'])
1459+
def test_draw_path_collection_no_hatchcolor(backend):
1460+
from matplotlib.collections import PathCollection
1461+
path = mpath.Path.unit_rectangle()
1462+
1463+
plt.switch_backend(backend)
1464+
fig, ax = plt.subplots()
1465+
renderer = fig._get_renderer()
1466+
1467+
col = PathCollection([path], hatch='//')
1468+
ax.add_collection(col)
1469+
1470+
gc = renderer.new_gc()
1471+
transform = mtransforms.IdentityTransform()
1472+
paths = col.get_paths()
1473+
transforms = col.get_transforms()
1474+
offsets = col.get_offsets()
1475+
offset_trf = col.get_offset_transform()
1476+
facecolors = col.get_facecolor()
1477+
edgecolors = col.get_edgecolor()
1478+
linewidths = col.get_linewidth()
1479+
linestyles = col.get_linestyle()
1480+
antialiaseds = col.get_antialiased()
1481+
urls = col.get_urls()
1482+
offset_position = "screen"
1483+
1484+
renderer.draw_path_collection(
1485+
gc, transform, paths, transforms, offsets, offset_trf,
1486+
facecolors, edgecolors, linewidths, linestyles,
1487+
antialiaseds, urls, offset_position
1488+
)

src/_backend_agg_wrapper.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,11 +236,11 @@ PYBIND11_MODULE(_backend_agg, m, py::mod_gil_not_used())
236236
"gc"_a, "master_transform"_a, "paths"_a, "transforms"_a, "offsets"_a,
237237
"offset_trans"_a, "facecolors"_a, "edgecolors"_a, "linewidths"_a,
238238
"dashes"_a, "antialiaseds"_a, "ignored"_a, "offset_position"_a,
239-
"hatchcolors"_a = nullptr)
239+
"hatchcolors"_a = py::array_t<double>().reshape({0, 4}))
240240
.def("draw_quad_mesh", &PyRendererAgg_draw_quad_mesh,
241241
"gc"_a, "master_transform"_a, "mesh_width"_a, "mesh_height"_a,
242242
"coordinates"_a, "offsets"_a, "offset_trans"_a, "facecolors"_a,
243-
"antialiased"_a, "edgecolors"_a, "hatchcolors"_a = nullptr)
243+
"antialiased"_a, "edgecolors"_a, "hatchcolors"_a = py::array_t<double>().reshape({0, 4}))
244244
.def("draw_gouraud_triangles", &PyRendererAgg_draw_gouraud_triangles,
245245
"gc"_a, "points"_a, "colors"_a, "trans"_a = nullptr)
246246

0 commit comments

Comments
 (0)
0