File size: 2,544 Bytes
12d2e9e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
"""
Copyright 2021, Dana-Farber Cancer Institute and Weill Cornell Medicine
License: GNU GPL 2.0
"""
import anndata
import numpy as np
# define fixtures here, and use them throughout the other tests in core_tests/
import pytest
from pathml.core import SlideData, SlideDataset, VectraSlide, types
@pytest.fixture
def example_slide_data():
labs = {
"test_string_label": "testlabel",
"test_array_label": np.array([2, 3, 4]),
"test_int_label": 3,
"test_float_label": 3.0,
"test_bool_label": True,
}
wsi = SlideData(
"tests/testdata/small_HE.svs", name="test", labels=labs, backend="openslide"
)
return wsi
@pytest.fixture
def example_slide_data_with_tiles(tile):
labs = {
"test_string_label": "testlabel",
"test_array_label": np.array([2, 3, 4]),
"test_int_label": 3,
"test_float_label": 3.0,
"test_bool_label": True,
}
adata = anndata.AnnData()
wsi = SlideData(
"tests/testdata/small_HE.svs",
name="test",
labels=labs,
backend="openslide",
tiles=[tile],
counts=adata,
)
return wsi
@pytest.fixture()
def slide_dataset(example_slide_data_with_tiles):
n = 4
labs = {
"test_string_label": "testlabel",
"test_array_label": np.array([2, 3, 4]),
"test_int_label": 3,
"test_float_label": 3.0,
"test_bool_label": True,
}
slide_list = [
SlideData(
"tests/testdata/small_HE.svs",
name=f"slide{i}",
labels=labs,
backend="openslide",
)
for i in range(n)
]
slide_dataset = SlideDataset(slide_list)
return slide_dataset
@pytest.fixture()
def slide_dataset_with_tiles(tile, example_slide_data_with_tiles):
n = 4
labs = {
"test_string_label": "testlabel",
"test_array_label": np.array([2, 3, 4]),
"test_int_label": 3,
"test_float_label": 3.0,
"test_bool_label": True,
}
slide_list = [
SlideData(
"tests/testdata/small_HE.svs",
name=f"slide{i}",
labels=labs,
backend="openslide",
tiles=[tile],
)
for i in range(n)
]
slide_dataset = SlideDataset(slide_list)
return slide_dataset
@pytest.fixture
def vectra_slide():
temp_path = "tests/testdata/small_vectra.qptiff"
vectra_slide = VectraSlide(temp_path, backend="bioformats", slide_type=types.Vectra)
return vectra_slide
|