Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix scikit-image version skipping in the test suite #14

Merged
merged 2 commits into from
Apr 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def test_mask_none(self):
result2 = feature.canny(cp.zeros((20, 20)), 4, 0, 0)
self.assertTrue(cp.all(result1 == result2))

@cp.testing.with_requires("skimage>=1.18")
@cp.testing.with_requires("scikit-image>=0.18")
def test_use_quantiles(self):
image = img_as_float(cp.asarray(data.camera()[::100, ::100]))

Expand Down
32 changes: 16 additions & 16 deletions python/cucim/src/cucim/skimage/filters/tests/test_thresholding.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,20 +245,20 @@ def test_threshold_sauvola_iterable_window_size(self):
assert_array_equal(ref, out)


@cp.testing.with_requires("skimage>=1.18")
@cp.testing.with_requires("scikit-image>=0.18")
def test_otsu_camera_image():
camera = util.img_as_ubyte(camerad)
assert 101 < threshold_otsu(camera) < 103


@cp.testing.with_requires("skimage>=1.18")
@cp.testing.with_requires("scikit-image>=0.18")
def test_otsu_camera_image_histogram():
camera = util.img_as_ubyte(camerad)
hist = histogram(camera.ravel(), 256, source_range="image")
assert 101 < threshold_otsu(hist=hist) < 103


@cp.testing.with_requires("skimage>=1.18")
@cp.testing.with_requires("scikit-image>=0.18")
def test_otsu_camera_image_counts():
camera = util.img_as_ubyte(camerad)
counts, bin_centers = histogram(camera.ravel(), 256, source_range="image")
Expand Down Expand Up @@ -291,7 +291,7 @@ def test_otsu_one_color_image_3d():
assert threshold_otsu(img) == 1


@cp.testing.with_requires("skimage>=1.18")
@cp.testing.with_requires("scikit-image>=0.18")
def test_li_camera_image():
image = util.img_as_ubyte(camerad)
threshold = threshold_li(image)
Expand Down Expand Up @@ -381,20 +381,20 @@ def test_li_pathological_arrays():
assert cp.all(cp.isfinite(thresholds))


@cp.testing.with_requires("skimage>=1.18")
@cp.testing.with_requires("scikit-image>=0.18")
def test_yen_camera_image():
camera = util.img_as_ubyte(camerad)
assert 145 < threshold_yen(camera) < 147


@cp.testing.with_requires("skimage>=1.18")
@cp.testing.with_requires("scikit-image>=0.18")
def test_yen_camera_image_histogram():
camera = util.img_as_ubyte(camerad)
hist = histogram(camera.ravel(), 256, source_range="image")
assert 145 < threshold_yen(hist=hist) < 147


@cp.testing.with_requires("skimage>=1.18")
@cp.testing.with_requires("scikit-image>=0.18")
def test_yen_camera_image_counts():
camera = util.img_as_ubyte(camerad)
counts, bin_centers = histogram(camera.ravel(), 256, source_range='image')
Expand All @@ -417,7 +417,7 @@ def test_local_even_block_size_error():
threshold_local(img, block_size=4)


@cp.testing.with_requires("skimage>=1.18")
@cp.testing.with_requires("scikit-image>=0.18")
def test_isodata_camera_image():
camera = util.img_as_ubyte(camerad)

Expand All @@ -429,17 +429,17 @@ def test_isodata_camera_image():
assert_array_equal(threshold_isodata(camera, return_all=True), [102, 103])


@cp.testing.with_requires("skimage>=1.18")
@cp.testing.with_requires("scikit-image>=0.18")
def test_isodata_camera_image_histogram():
camera = util.img_as_ubyte(data.camera())
camera = util.img_as_ubyte(camerad)
hist = histogram(camera.ravel(), 256, source_range='image')
threshold = threshold_isodata(hist=hist)
assert threshold == 102


@cp.testing.with_requires("skimage>=1.18")
@cp.testing.with_requires("scikit-image>=0.18")
def test_isodata_camera_image_counts():
camera = util.img_as_ubyte(data.camera())
camera = util.img_as_ubyte(camerad)
counts, bin_centers = histogram(camera.ravel(), 256, source_range='image')
threshold = threshold_isodata(hist=counts)
assert threshold == 102
Expand Down Expand Up @@ -501,7 +501,7 @@ def test_isodata_moon_image_negative_float():
# fmt: on


@cp.testing.with_requires("skimage>=1.18")
@cp.testing.with_requires("scikit-image>=0.18")
def test_threshold_minimum():
camera = util.img_as_ubyte(camerad)

Expand All @@ -513,15 +513,15 @@ def test_threshold_minimum():
assert_array_equal(threshold, 114)


@cp.testing.with_requires("skimage>=1.18")
@cp.testing.with_requires("scikit-image>=0.18")
def test_threshold_minimum_histogram():
camera = util.img_as_ubyte(camerad)
hist = histogram(camera.ravel(), 256, source_range='image')
threshold = threshold_minimum(hist=hist)
assert_array_equal(threshold, 85)


@cp.testing.with_requires("skimage>=1.18")
@cp.testing.with_requires("scikit-image>=0.18")
def test_threshold_minimum_counts():
camera = util.img_as_ubyte(camerad)
counts, bin_centers = histogram(camera.ravel(), 256, source_range='image')
Expand Down Expand Up @@ -695,7 +695,7 @@ def test_multiotsu_more_classes_then_values():
threshold_multiotsu(img, classes=4)


# @testing.with_requires("skimage>=0.18")
# @testing.with_requires("scikit-image>=0.18")
# @pytest.mark.parametrize(
# "thresholding, lower, upper",
# [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@


@pytest.mark.parametrize('dtype', [cp.uint8, cp.float32, cp.float64])
@cp.testing.with_requires("skimage>=1.18")
@cp.testing.with_requires("scikit-image>=0.18")
def test_PSNR_vs_IPOL(dtype):
"""Tests vs. imdiff result from the following IPOL article and code:
https://www.ipol.im/pub/art/2011/g_lmii/.
Expand All @@ -41,11 +41,10 @@ def test_PSNR_vs_IPOL(dtype):
https://github.com/scikit-image/scikit-image/pull/4913#issuecomment-700653165
"""
p_IPOL = 22.409353363576034
p = peak_signal_noise_ratio(cam.astype(dtype), cam_noisy.astype(dtype))
if np.dtype.kind(dtype) == 'f':
assert p.dtype == dtype
else:
assert p.dtype == cp.float64
p = peak_signal_noise_ratio(cam.astype(dtype), cam_noisy.astype(dtype),
data_range=255)
# internally, mean_square_error always sets dtype=cp.float64 for accuracy
assert p.dtype == cp.float64
assert_almost_equal(p, p_IPOL, decimal=4)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def test_structural_similarity_multichannel_chelsea():
assert_equal(structural_similarity(Xc, Xc, multichannel=True), 1.0)


@cp.testing.with_requires("skimage>=1.18")
@cp.testing.with_requires("scikit-image>=0.18")
def test_gaussian_structural_similarity_vs_IPOL():
"""Tests vs. imdiff result from the following IPOL article and code:
https://www.ipol.im/pub/art/2011/g_lmii/.
Expand All @@ -200,7 +200,7 @@ def test_gaussian_structural_similarity_vs_IPOL():
assert_almost_equal(mssim, mssim_IPOL, decimal=3)


@cp.testing.with_requires("skimage>=1.18")
@cp.testing.with_requires("scikit-image>=0.18")
def test_mssim_vs_legacy():
# check that ssim with default options matches skimage 0.11 result
mssim_skimage_0pt17 = 0.3674518327910367
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def test_unsupervised_wiener(dtype):
# cp.testing.assert_allclose(cp.real(deconvolved), np.load(path), rtol=1e-3)


@cp.testing.with_requires("skimage>=1.18")
@cp.testing.with_requires("scikit-image>=0.18")
def test_image_shape():
"""Test that shape of output image in deconvolution is same as input.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def test_clip_poisson():
assert (cam_poisson2.max() > 1.3) and (cam_poisson2.min() == -1.0)


@cp.testing.with_requires("skimage>=1.18")
@cp.testing.with_requires("scikit-image>=0.18")
def test_clip_gaussian():
seed = 42
data = camerad # 512x512 grayscale uint8
Expand Down