-
Notifications
You must be signed in to change notification settings - Fork 383
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- todo: setup more test images - todo: setup assertions
- Loading branch information
Showing
1 changed file
with
36 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |