Skip to content

Commit c367e62

Browse files
Merge pull request #283 from scverse/bugfix/issue245-linearring
Xenium Reader now filters out invalid polygons
2 parents 6be7296 + 091c5f3 commit c367e62

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

src/spatialdata_io/readers/xenium.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44
import logging
55
import os
66
import re
7-
import tempfile
87
import warnings
9-
import zipfile
108
from pathlib import Path
119
from types import MappingProxyType
1210
from typing import TYPE_CHECKING, Any
@@ -418,9 +416,6 @@ def _get_polygons(
418416
n_jobs: int,
419417
idx: ArrayLike | None = None,
420418
) -> GeoDataFrame:
421-
def _poly(arr: ArrayLike) -> Polygon:
422-
return Polygon(arr[:-1])
423-
424419
# seems to be faster than pd.read_parquet
425420
df = pq.read_table(path / file).to_pandas()
426421

@@ -429,8 +424,9 @@ def _poly(arr: ArrayLike) -> Polygon:
429424
# convert the index to str since we will compare it with an AnnData object, where the index is a str
430425
index.index = index.index.astype(str)
431426
index = _decode_cell_id_column(index)
427+
432428
out = Parallel(n_jobs=n_jobs)(
433-
delayed(_poly)(i.to_numpy())
429+
delayed(Polygon)(i.to_numpy())
434430
for _, i in group_by[[XeniumKeys.BOUNDARIES_VERTEX_X, XeniumKeys.BOUNDARIES_VERTEX_Y]]
435431
)
436432
geo_df = GeoDataFrame({"geometry": out})

0 commit comments

Comments
 (0)