spatialdata-plot
spatialdata-plot copied to clipboard
Fix transformed labels with outline
Outlines are rendered on an axis separate from the filled labels. The transformation was only applied to the filled labels, so that the outlines had an identity transform. This was not observable when outlines were off or the transform was an identity (as in the blobs data).
Closes #273
For comparison with the example in the linked issue:
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 84.27%. Comparing base (
ffd4a1f) to head (61ff47c).
Additional details and impacted files
@@ Coverage Diff @@
## main #275 +/- ##
=======================================
Coverage 84.27% 84.27%
=======================================
Files 8 8
Lines 1558 1558
=======================================
Hits 1313 1313
Misses 245 245
I looked into the 2 lines of missing coverage. These are the two lines that seemed to be wrongly indented. By indenting them, I moved them into an untested code block, so that they are not covered anymore.
The else-branch is commented as "Default: no alpha, contour = infill" and not covered by tests. I tried adding a test to improve coverage, but am not convinced that this is the correct result. I think the code is wrong, the labels should be filled and my test (below) should fail. That means before adding the test we need a plot file of the correct, expected result. Or the else-branch should be removed.
Test case for infill
def test_plot_can_render_contour_with_infill(self, sdata_blobs):
# Rendering with fill_alpha == outline_alpha takes a special code path
sdata_blobs.pl.render_labels(
"blobs_labels",
color="channel_0_sum",
fill_alpha=1.0,
outline=True,
outline_alpha=1.0,
).pl.show()
Hi @aeisenbarth, thanks for the PR. I will merge a couple of PRs first and then adjust this one if required.
@aeisenbarth can you rename that one function?