Skip to content

Commit 0aa26cd

Browse files
committed
added test
1 parent 6716f75 commit 0aa26cd

16 files changed

+23
-0
lines changed
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
14.1 KB
Loading
7.44 KB
Loading
-467 Bytes
Loading
Loading
-671 Bytes
Loading
21.4 KB
Loading

tests/pl/test_render_shapes.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
import scanpy as sc
33
import spatialdata_plot # noqa: F401
44
from spatialdata import SpatialData
5+
from spatialdata.models import ShapesModel
6+
from shapely.geometry import Polygon, MultiPolygon
7+
import geopandas as gpd
58

69
from tests.conftest import PlotTester, PlotTesterMeta
710

@@ -24,3 +27,23 @@ def test_plot_can_render_circles(self, sdata_blobs: SpatialData):
2427

2528
def test_plot_can_render_polygons(self, sdata_blobs: SpatialData):
2629
sdata_blobs.pl.render_shapes(element="blobs_polygons").pl.show()
30+
31+
def test_plot_can_render_multipolygons(self):
32+
33+
def _make_multi():
34+
hole = MultiPolygon([(
35+
((0.0, 0.0), (0.0, 1.0), (1.0, 1.0), (1.0, 0.0)),
36+
[((0.2,0.2), (0.2,0.8), (0.8,0.8), (0.8,0.2))]
37+
)])
38+
overlap = MultiPolygon([
39+
Polygon([(2.0, 0.0), (2.0, 0.8), (2.8, 0.8), (2.8, 0.0)]),
40+
Polygon([(2.2, 0.2), (2.2, 1.0), (3.0, 1.0), (3.0, 0.2)])
41+
])
42+
poly = Polygon([(4.0, 0.0), (4.0, 1.0), (5.0, 1.0), (5.0, 0.0)])
43+
polygon_series = gpd.GeoSeries([hole, overlap, poly])
44+
cell_polygon_table = gpd.GeoDataFrame(geometry=polygon_series)
45+
sd_polygons = ShapesModel.parse(cell_polygon_table)
46+
return sd_polygons
47+
48+
sdata = SpatialData(shapes={"p": _make_multi()})
49+
sdata.pl.render_shapes(outline=True, fill_alpha=0.3).pl.show()

0 commit comments

Comments
 (0)