|
9 | 9 | rng = np.random.default_rng() |
10 | 10 |
|
11 | 11 | from scportrait.plotting.h5sc import ( |
| 12 | + _plot_contour_grid, |
12 | 13 | _plot_image_grid, |
13 | 14 | _reshape_image_array, |
14 | 15 | cell_grid, |
@@ -70,6 +71,28 @@ def test_plot_image_grid(input_shape, nrows, ncols, col_labels, col_labels_rotat |
70 | 71 | break |
71 | 72 |
|
72 | 73 |
|
| 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 | + |
73 | 96 | # ---------- cell_grid_single_channel ---------- |
74 | 97 |
|
75 | 98 |
|
|
0 commit comments