Skip to content

Commit 219eda9

Browse files
committed
test(render): visual permutation grids for points, labels, polygons
Adds 2x2 visual tests mirroring the circle one, for the other elements whose render paths split by backend / as_points, so divergence or breakage across paths is visible: - points: (no color / continuous) x (matplotlib / datashader) - labels: (fill / as_points) x (matplotlib / datashader) - polygons: (geometry / as_points) x (matplotlib / datashader) Colorbars disabled and marker sizes bumped so panels stay non-degenerate; each panel is titled with its (mode x backend) combination. New baselines to be generated from CI.
1 parent 68cc388 commit 219eda9

3 files changed

Lines changed: 40 additions & 0 deletions

File tree

tests/pl/test_render_labels.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,19 @@ def _annotate_labels_with_outline_columns(sdata: SpatialData) -> SpatialData:
4040

4141

4242
class TestLabels(PlotTester, metaclass=PlotTesterMeta):
43+
def test_plot_labels_render_permutations(self, sdata_blobs: SpatialData):
44+
"""2x2 of (fill / as_points) x (matplotlib / datashader); fill is backend-invariant, as_points should match."""
45+
panels = [
46+
("fill · matplotlib", {"method": "matplotlib"}),
47+
("fill · datashader", {"method": "datashader"}),
48+
("as_points · matplotlib", {"as_points": True, "size": 150, "method": "matplotlib"}),
49+
("as_points · datashader", {"as_points": True, "size": 150, "method": "datashader"}),
50+
]
51+
_, axs = plt.subplots(2, 2, figsize=(8, 8))
52+
for ax, (title, kw) in zip(axs.ravel(), panels, strict=True):
53+
sdata_blobs.pl.render_labels("blobs_labels", color="channel_0_sum", colorbar=False, **kw).pl.show(ax=ax)
54+
ax.set_title(title, fontsize=8)
55+
4356
def test_plot_can_render_labels(self, sdata_blobs: SpatialData):
4457
sdata_blobs.pl.render_labels(element="blobs_labels").pl.show()
4558

tests/pl/test_render_points.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,19 @@
4848

4949

5050
class TestPoints(PlotTester, metaclass=PlotTesterMeta):
51+
def test_plot_points_render_permutations(self, sdata_blobs: SpatialData):
52+
"""2x2 of (no color / continuous color) x (matplotlib / datashader); columns should look alike."""
53+
panels = [
54+
("no color · matplotlib", {"method": "matplotlib"}),
55+
("no color · datashader", {"method": "datashader"}),
56+
("color · matplotlib", {"color": "instance_id", "method": "matplotlib", "colorbar": False}),
57+
("color · datashader", {"color": "instance_id", "method": "datashader", "colorbar": False}),
58+
]
59+
_, axs = plt.subplots(2, 2, figsize=(8, 8))
60+
for ax, (title, kw) in zip(axs.ravel(), panels, strict=True):
61+
sdata_blobs.pl.render_points("blobs_points", size=200, **kw).pl.show(ax=ax)
62+
ax.set_title(title, fontsize=8)
63+
5164
def test_plot_can_render_points(self, sdata_blobs: SpatialData):
5265
sdata_blobs.pl.render_points(element="blobs_points").pl.show()
5366

tests/pl/test_render_shapes.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,20 @@ def test_plot_circle_render_permutations(self, monkeypatch):
7171
sdata.pl.render_shapes("circ", **kw).pl.show(ax=ax)
7272
ax.set_title(title, fontsize=8)
7373

74+
def test_plot_polygon_render_permutations(self, sdata_blobs_shapes_annotated: SpatialData):
75+
"""2x2 of (geometry / as_points) x (matplotlib / datashader) for polygons; columns should look alike."""
76+
panels = [
77+
("geometry · matplotlib", {"method": "matplotlib"}),
78+
("geometry · datashader", {"method": "datashader"}),
79+
("as_points · matplotlib", {"as_points": True, "size": 150, "method": "matplotlib"}),
80+
("as_points · datashader", {"as_points": True, "size": 150, "method": "datashader"}),
81+
]
82+
annotated = sdata_blobs_shapes_annotated
83+
_, axs = plt.subplots(2, 2, figsize=(8, 8))
84+
for ax, (title, kw) in zip(axs.ravel(), panels, strict=True):
85+
annotated.pl.render_shapes("blobs_polygons", color="value", colorbar=False, **kw).pl.show(ax=ax)
86+
ax.set_title(title, fontsize=8)
87+
7488
def test_plot_can_render_circles(self, sdata_blobs: SpatialData):
7589
sdata_blobs.pl.render_shapes(element="blobs_circles").pl.show()
7690

0 commit comments

Comments
 (0)