Skip to content

Commit afb835b

Browse files
minor fixes
1 parent 9d2e173 commit afb835b

File tree

4 files changed

+16
-4
lines changed

4 files changed

+16
-4
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55
- Can provide `qv_threshold` argument to the Xenium reader to filter low quality transcripts @callum-jpg (#210)
66

77
### Changed
8-
- Storing patches embeddings as an `AnnData` object instead of images (#212)
8+
- Storing patches embeddings as an `AnnData` object instead of images (#212) (see [updated tuto](https://gustaveroussy.github.io/sopa/tutorials/he/))
99

1010
### Fixed
1111
- Right sorting scales for WSI reader with openslide backend @stergioc (#209)
1212
- When a polygon cannot be simplified (for the Xenium Explorer), convert it to a circle (#206)
1313
- `sopa explorer write`: use correct default argument for `table_key` in the CLI (#211)
14+
- Fix Baysor usage on Windows (#185)
15+
- Fix tight patches returning a different number of patches (#214)
1416

1517
## [2.0.1] - 2025-02-10
1618

sopa/_constants.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,4 @@ class SopaFiles:
6868

6969
VALID_DIMENSIONS = ("c", "y", "x")
7070
LOW_AVERAGE_COUNT = 0.01
71-
EPS = 1e-5
7271
ATTRS_KEY = "spatialdata_attrs"

sopa/patches/_patches.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from spatialdata.transformations import get_transformation
1212
from xarray import DataArray, DataTree
1313

14-
from .._constants import EPS, SopaKeys
14+
from .._constants import SopaKeys
1515
from ..utils import add_spatial_element, to_intrinsic
1616

1717
log = logging.getLogger(__name__)
@@ -44,7 +44,7 @@ def update(self, patch_width):
4444

4545
def tight_width(self):
4646
width = (self.delta + (self._count - 1) * self.patch_overlap) / self._count
47-
return ceil(width) if self.int_coords else width + EPS
47+
return ceil(width) if self.int_coords else width + 1e-4 # add an epsilon to avoid floating point errors (#214)
4848

4949
def __getitem__(self, i):
5050
start_delta = i * (self.patch_width - self.patch_overlap)

tests/test_patches.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
import numpy as np
12
import pandas as pd
23
import pytest
34
from spatialdata import SpatialData
45

56
import sopa
67
from sopa._constants import SopaFiles, SopaKeys
8+
from sopa.patches._patches import Patches1D
79

810

911
@pytest.fixture
@@ -32,6 +34,15 @@ def test_patchify_inside_tissue_roi(sdata: SpatialData):
3234
del sdata.shapes[SopaKeys.ROI]
3335

3436

37+
def test_pathify_transcripts():
38+
# reproduce issue #214
39+
40+
xmax = np.float32(11475.797)
41+
xmin = np.float32(2.671875)
42+
43+
Patches1D(xmin=xmin, xmax=xmax, patch_width=300.0, patch_overlap=30.0, tight=True, int_coords=False)
44+
45+
3546
def test_patchify_baysor(sdata: SpatialData):
3647
with pytest.raises(AssertionError):
3748
sopa.utils.get_transcripts_patches_dirs(sdata)

0 commit comments

Comments
 (0)