Skip to content

Commit 424ba82

Browse files
timtreisclaude
andcommitted
Make visual tests two-panel: baseline viridis vs transparent cmap
Each visual test now shows a side-by-side comparison with the standard viridis cmap on the left and the transparent cmap on the right, making the transparency effect clearly visible. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 3ca6a52 commit 424ba82

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

tests/pl/test_utils.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,21 @@ def test_plot_can_set_zero_in_cmap_to_transparent(self, sdata_blobs: SpatialData
7878
)
7979

8080
def _render_transparent_cmap_shapes(self, sdata_blobs: SpatialData, method: str):
81+
_, axs = plt.subplots(nrows=1, ncols=2, layout="tight")
8182
new_cmap = set_zero_in_cmap_to_transparent(cmap="viridis")
8283
sdata_blobs["table"].obs["region"] = pd.Categorical(["blobs_polygons"] * sdata_blobs["table"].n_obs)
8384
sdata_blobs["table"].uns["spatialdata_attrs"]["region"] = "blobs_polygons"
8485
sdata_blobs.shapes["blobs_polygons"]["value"] = [0.0, 2.0, 3.0, 4.0, 5.0]
86+
87+
# left: baseline with standard viridis
88+
sdata_blobs.pl.render_images("blobs_image").pl.render_shapes(
89+
"blobs_polygons", color="value", cmap="viridis", method=method
90+
).pl.show(ax=axs[0], colorbar=False)
91+
92+
# right: transparent cmap — shape with value=0 should reveal the image
8593
sdata_blobs.pl.render_images("blobs_image").pl.render_shapes(
8694
"blobs_polygons", color="value", cmap=new_cmap, method=method
87-
).pl.show(colorbar=False)
95+
).pl.show(ax=axs[1], colorbar=False)
8896

8997
def test_plot_transparent_cmap_shapes_matplotlib(self, sdata_blobs: SpatialData):
9098
self._render_transparent_cmap_shapes(sdata_blobs, method="matplotlib")

0 commit comments

Comments
 (0)