Skip to content

Commit 4fabaad

Browse files
committed
Merge branch 'img-source' of https://github.com/BiocPy/SpatialExperiment into img-source
2 parents 35c76c9 + adecaa4 commit 4fabaad

2 files changed

Lines changed: 16 additions & 16 deletions

File tree

src/spatialexperiment/SpatialExperiment.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -921,7 +921,7 @@ def img_source(
921921
path=False,
922922
):
923923
"""Retrieve the source(s) for images stored in the SpatialExperiment object.
924-
924+
925925
Args:
926926
sample_id:
927927
- `sample_id=True`: Matches all samples.
@@ -932,9 +932,9 @@ def img_source(
932932
- `image_id=True`: Matches all images for the specified sample(s).
933933
- `image_id=None`: Matches the first image for the sample(s).
934934
- `image_id="<str>"`: Matches image(s) by its(their) id.
935-
935+
936936
path: If True, returns path as string. Defaults to False.
937-
937+
938938
Returns:
939939
The image source(s) for the matching criteria. Returns `None` if `img_data` is `None`.
940940
When a single image matches, returns its source as a `str`, `Path`, or `None`.

tests/test_img_source.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313
def test_loaded_spatial_image_img_source():
1414
image = Image.open("tests/images/sample_image2.png")
1515
spi_loaded = construct_spatial_image_class(image, is_url=False)
16-
16+
1717
assert isinstance(spi_loaded, LoadedSpatialImage)
1818
assert spi_loaded.img_source() is None
1919
assert spi_loaded.img_source(as_path=True) is None
20-
20+
2121
np_image = np.zeros((100, 100, 3), dtype=np.uint8)
2222
spi_loaded_np = construct_spatial_image_class(np_image)
23-
23+
2424
assert isinstance(spi_loaded_np, LoadedSpatialImage)
2525
assert spi_loaded_np.img_source() is None
2626
assert spi_loaded_np.img_source(as_path=True) is None
@@ -29,26 +29,26 @@ def test_loaded_spatial_image_img_source():
2929
def test_stored_spatial_image_img_source():
3030
image_path = "tests/images/sample_image1.jpg"
3131
spi_stored = construct_spatial_image_class(image_path, is_url=False)
32-
32+
3333
assert isinstance(spi_stored, StoredSpatialImage)
34-
34+
3535
source_path = spi_stored.img_source()
3636
assert isinstance(source_path, Path)
3737
assert image_path in str(source_path)
38-
38+
3939
source_str = spi_stored.img_source(as_path=True)
4040
assert isinstance(source_str, str)
4141
assert image_path in source_str
42-
42+
4343
assert str(source_path) == str(spi_stored.path)
4444

4545

4646
def test_remote_spatial_image_img_source():
4747
image_url = "https://example.com/test_image.jpg"
4848
spi_remote = construct_spatial_image_class(image_url, is_url=True)
49-
49+
5050
assert isinstance(spi_remote, RemoteSpatialImage)
51-
51+
5252
source = spi_remote.img_source()
5353
assert isinstance(source, str)
5454
assert source == image_url
@@ -57,17 +57,17 @@ def test_remote_spatial_image_img_source():
5757
def test_remote_spatial_image_img_source_with_mock(monkeypatch):
5858
image_url = "https://example.com/test_image.jpg"
5959
spi_remote = construct_spatial_image_class(image_url, is_url=True)
60-
60+
6161
assert isinstance(spi_remote, RemoteSpatialImage)
62-
62+
6363
# Mock the _download_image method to return a fixed path
6464
mock_path = Path("/tmp/image.jpg")
6565
monkeypatch.setattr(spi_remote, "_download_image", lambda: mock_path)
66-
66+
6767
# Test with as_path=True (returns the cached path)
6868
source_path = spi_remote.img_source(as_path=True)
6969
assert source_path == str(mock_path)
70-
70+
7171
# Test default behavior returns URL
7272
assert spi_remote.img_source() == image_url
7373

0 commit comments

Comments
 (0)