Skip to content

Commit 832ddad

Browse files
committed
[test] add unit test for _plot_contour_grid function
1 parent a5e274f commit 832ddad

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tests/unit_tests/plotting/test_h5sc.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
rng = np.random.default_rng()
1010

1111
from scportrait.plotting.h5sc import (
12+
_plot_contour_grid,
1213
_plot_image_grid,
1314
_reshape_image_array,
1415
cell_grid,
@@ -70,6 +71,28 @@ def test_plot_image_grid(input_shape, nrows, ncols, col_labels, col_labels_rotat
7071
break
7172

7273

74+
# ---------- _plot_contour_grid ----------
75+
76+
77+
def test_plot_contour_grid_requires_image_grid():
78+
fig, ax = plt.subplots(1, 1)
79+
masks = rng.random((2, 10, 10)) > 0.5
80+
with pytest.raises(RuntimeError):
81+
_plot_contour_grid(ax, masks)
82+
83+
84+
def test_plot_contour_grid_draws_on_existing_grid():
85+
images = rng.random((4, 10, 10))
86+
masks = np.zeros((4, 10, 10), dtype=float)
87+
masks[:, 2:8, 2:8] = 1.0
88+
fig, ax = plt.subplots(1, 1)
89+
_plot_image_grid(ax, images, nrows=2, ncols=2)
90+
_plot_contour_grid(ax, masks)
91+
# Verify contours were added to each inset axis
92+
for ax_sub in ax.child_axes:
93+
assert len(ax_sub.lines) > 0
94+
95+
7396
# ---------- cell_grid_single_channel ----------
7497

7598

0 commit comments

Comments
 (0)