Skip to content

Commit 72ef587

Browse files
committed
Add test case
1 parent 739296f commit 72ef587

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed
75.4 KB
Loading

tests/pl/test_render_labels.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from spatialdata import SpatialData
1111
from spatialdata._core.query.relational_query import _get_unique_label_values_as_index
1212
from spatialdata.models import TableModel
13+
from spatialdata.transformations import Affine, Scale, Sequence, Translation, set_transformation
1314

1415
from tests.conftest import DPI, PlotTester, PlotTesterMeta
1516

@@ -111,6 +112,34 @@ def test_can_plot_with_one_element_color_table(self, sdata_blobs: SpatialData):
111112
def test_plot_label_categorical_color(self, sdata_blobs: SpatialData, label: str):
112113
self._make_tablemodel_with_categorical_labels(sdata_blobs, label)
113114

115+
def test_plot_can_render_transformed_labels_with_outline(self, sdata_blobs: SpatialData):
116+
# Blobs have by default an identity transform. Replace it by a rotated, scaled transform:
117+
angle = np.deg2rad(15)
118+
axes = ("y", "x")
119+
rotation = Affine(
120+
matrix=np.array(
121+
[
122+
[np.cos(angle), -np.sin(angle), 0],
123+
[np.sin(angle), np.cos(angle), 0],
124+
[0, 0, 1],
125+
]
126+
),
127+
input_axes=axes,
128+
output_axes=axes,
129+
)
130+
translation = Translation([10, 10], axes=axes)
131+
scale = Scale([0.65, 0.65], axes=axes)
132+
transform = Sequence([translation, rotation, scale])
133+
set_transformation(sdata_blobs["blobs_labels"], transform)
134+
135+
# Render without fill, but with outline.
136+
sdata_blobs.pl.render_labels(
137+
"blobs_labels",
138+
fill_alpha=0.0,
139+
outline=True,
140+
outline_alpha=1.0,
141+
).pl.show()
142+
114143
def _make_tablemodel_with_categorical_labels(self, sdata_blobs, label):
115144
n_obs = max(_get_unique_label_values_as_index(sdata_blobs[label]))
116145
adata = AnnData(

0 commit comments

Comments
 (0)