Skip to content

Commit

Permalink
tests for seqfish
Browse files Browse the repository at this point in the history
  • Loading branch information
LucaMarconato committed Dec 12, 2024
1 parent ee87ea2 commit 28b0eb3
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
27 changes: 27 additions & 0 deletions tests/test_seqfish.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import math
from pathlib import Path

import pytest

from spatialdata_io.readers.seqfish import seqfish
from tests._utils import skip_if_below_python_version


# See https://github.com/scverse/spatialdata-io/blob/main/.github/workflows/prepare_test_data.yaml for instructions on
# how to download and place the data on disk
@skip_if_below_python_version()
@pytest.mark.parametrize("dataset,expected", [("instrument 2 official", "{'y': (0, 108), 'x': (0, 108)}")])
@pytest.mark.parametrize("rois", [[1], None])
@pytest.mark.parametrize("cells_as_circles", [False, True])
def test_example_data(dataset: str, expected: str, rois: list[int] | None, cells_as_circles: bool) -> None:
f = Path("./data") / dataset
assert f.is_dir()
sdata = seqfish(f, cells_as_circles=cells_as_circles, rois=rois)
from spatialdata import get_extent

extent = get_extent(sdata, exact=False)
extent = {ax: (math.floor(extent[ax][0]), math.ceil(extent[ax][1])) for ax in extent}
if cells_as_circles:
# manual correction required to take into account for the circle radii
expected = "{'y': (-2, 109), 'x': (-2, 109)}"
assert str(extent) == expected
8 changes: 2 additions & 6 deletions tests/test_xenium.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,8 @@ def test_roundtrip_with_data_limits() -> None:
assert np.array_equal(cell_id_str, f0(*f1(cell_id_str)))


# The datasets should be downloaded from
# https://www.10xgenomics.com/support/software/xenium-onboard-analysis/latest/resources/xenium-example-data#test-data
# and placed in the "data" directory; if you run the tests locally you may need to create a symlink in "tests/data"
# pointing to "data".
# The GitHub workflow "prepare_test_data.yaml" takes care of downloading the datasets and uploading an artifact for the
# tests to use
# See https://github.com/scverse/spatialdata-io/blob/main/.github/workflows/prepare_test_data.yaml for instructions on
# how to download and place the data on disk
@skip_if_below_python_version()
@pytest.mark.parametrize(
"dataset,expected",
Expand Down

0 comments on commit 28b0eb3

Please sign in to comment.