Skip to content

Commit b646004

Browse files
timtreisclaude
andcommitted
Add tests verifying transfunc is applied for continuous shapes and labels
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 10c131e commit b646004

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

tests/pl/test_render_labels.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,3 +454,17 @@ def test_groups_warns_when_no_groups_match_labels(sdata_blobs: SpatialData, capl
454454
sdata_blobs.pl.render_labels(
455455
labels_name, color="cat", groups=["nonexistent"], table_name="label_table", na_color=None
456456
).pl.show()
457+
458+
459+
def test_transfunc_is_applied_for_continuous_labels(sdata_blobs: SpatialData):
460+
called = []
461+
462+
def track(x):
463+
called.append(True)
464+
return x
465+
466+
fig, ax = plt.subplots()
467+
sdata_blobs.pl.render_labels("blobs_labels", color="channel_0_sum", transfunc=track).pl.show(ax=ax)
468+
plt.close(fig)
469+
470+
assert called, "transfunc was not called for continuous labels data"

tests/pl/test_render_shapes.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1310,3 +1310,17 @@ def test_datashader_na_color_nan_overlay(sdata_blobs: SpatialData, na_color: str
13101310
f"Expected {expected_images} image(s), got {len(ax.get_images())} for na_color={na_color!r}"
13111311
)
13121312
plt.close(fig)
1313+
1314+
1315+
def test_transfunc_is_applied_for_continuous_shapes(sdata_blobs_shapes_annotated: SpatialData):
1316+
called = []
1317+
1318+
def track(x):
1319+
called.append(True)
1320+
return x
1321+
1322+
fig, ax = plt.subplots()
1323+
sdata_blobs_shapes_annotated.pl.render_shapes("blobs_polygons", color="value", transfunc=track).pl.show(ax=ax)
1324+
plt.close(fig)
1325+
1326+
assert called, "transfunc was not called for continuous shapes data"

0 commit comments

Comments
 (0)