Skip to content

Commit

Permalink
[WIP] Setup image forming
Browse files Browse the repository at this point in the history
- todo: setup more test images
- todo: setup assertions
  • Loading branch information
gnodar01 committed Dec 10, 2024
1 parent fe4521d commit 0f25ee3
Showing 1 changed file with 36 additions and 7 deletions.
43 changes: 36 additions & 7 deletions tests/core/core/reader/test__reader.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,43 @@
import pytest
import numpy
import skimage.io as io
from cellprofiler_core.reader import fill_readers, filter_active_readers
from cellprofiler_core.constants.reader import ALL_READERS, AVAILABLE_READERS
from cellprofiler_core.image import MonochromeImage
from cellprofiler_core.utilities.pathname import pathname2url


def init_readers():
@pytest.fixture(scope="module")
def readers():
# init readers
fill_readers()
print(ALL_READERS)
print("---")
filter_active_readers([x for x in ALL_READERS.keys() if "Google Cloud Storage" not in x], by_module_name=False)
print(AVAILABLE_READERS)
# do not test GCS Reader
filter_active_readers(
[x for x in ALL_READERS.keys() if "Google Cloud Storage" not in x],
by_module_name=False)
# post-filtered readers
return AVAILABLE_READERS

def create_provider(img_data, path, rescale=True):
io.imsave(path, img_data)

provider = MonochromeImage(
path.stem, # name
pathname2url(str(path)), # url
0, # series
None, # index
None, # channel
rescale=rescale,
volume=False,
spacing=None,
z=None,
t=None
)
return provider

class TestReaders:
def test_readers(self):
init_readers()
def test_simple(self, readers, tmp_path):
img_data = numpy.array([0,0,0,0], dtype=numpy.dtype("uint8")).reshape(2,2)
provider = create_provider(img_data, tmp_path / "uint8_all_zero.tiff", rescale=True)
img = provider.provide_image(None) # img.pixel_data for array
print("Did the thing")

0 comments on commit 0f25ee3

Please sign in to comment.