Skip to content

Commit 08d9bbd

Browse files
committed
Trim #628 tests to essentials
1 parent 705d350 commit 08d9bbd

1 file changed

Lines changed: 8 additions & 31 deletions

File tree

‎tests/pl/test_render_images.py‎

Lines changed: 8 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -542,26 +542,22 @@ def _nan_image(n_channels: int, nan_indices: list[int]) -> SpatialData:
542542
return SpatialData(images={"img": img})
543543

544544

545-
def test_nan_in_single_channel_raises():
546-
sdata = _nan_image(n_channels=1, nan_indices=[0])
547-
with pytest.raises(ValueError, match=r"NaN.*channel\(s\) \[0\]"):
548-
sdata.pl.render_images("img").pl.show()
549-
550-
551545
def test_nan_in_multi_channel_raises():
546+
# Message must list the offending channel and include the fillna hint.
552547
sdata = _nan_image(n_channels=2, nan_indices=[0])
553-
with pytest.raises(ValueError, match=r"NaN.*channel\(s\) \[0\]"):
548+
with pytest.raises(ValueError, match=r"NaN.*channel\(s\) \[0\].*fillna"):
554549
sdata.pl.render_images("img").pl.show()
555550

556551

557-
def test_finite_multi_channel_unaffected():
558-
sdata = _nan_image(n_channels=2, nan_indices=[])
559-
fig, ax = plt.subplots()
560-
sdata.pl.render_images("img").pl.show(ax=ax)
561-
plt.close(fig)
552+
def test_nan_in_single_channel_raises():
553+
# 1ch previously substituted na_color silently; locks the new symmetric behavior.
554+
sdata = _nan_image(n_channels=1, nan_indices=[0])
555+
with pytest.raises(ValueError, match="NaN"):
556+
sdata.pl.render_images("img").pl.show()
562557

563558

564559
def test_integer_dtype_skips_nan_check():
560+
# Integer-dtype images can't contain NaN; the check must short-circuit on dtype.
565561
rng = np.random.default_rng(0)
566562
data = rng.integers(0, 255, (2, 8, 8), dtype=np.uint16)
567563
img = Image2DModel.parse(data, dims=("c", "y", "x"), c_coords=[0, 1])
@@ -571,25 +567,6 @@ def test_integer_dtype_skips_nan_check():
571567
plt.close(fig)
572568

573569

574-
def test_nan_only_in_unselected_channel_renders():
575-
sdata = _nan_image(n_channels=2, nan_indices=[1])
576-
fig, ax = plt.subplots()
577-
sdata.pl.render_images("img", channel=[0]).pl.show(ax=ax)
578-
plt.close(fig)
579-
580-
581-
def test_nan_error_lists_all_offending_channels():
582-
sdata = _nan_image(n_channels=3, nan_indices=[0, 2])
583-
with pytest.raises(ValueError, match=r"\[0, 2\]"):
584-
sdata.pl.render_images("img").pl.show()
585-
586-
587-
def test_nan_error_message_includes_fillna_hint():
588-
sdata = _nan_image(n_channels=1, nan_indices=[0])
589-
with pytest.raises(ValueError, match="fillna"):
590-
sdata.pl.render_images("img").pl.show()
591-
592-
593570
# Regression for #612: vmin/vmax kwargs are no longer accepted on any render
594571
# function. The check covers all four to prevent the asymmetry from re-emerging.
595572
@pytest.mark.parametrize("kwarg", ["vmin", "vmax"])

0 commit comments

Comments
 (0)