Skip to content

Commit

Permalink
Merge pull request #588 from rapidsai/branch-23.08
Browse files Browse the repository at this point in the history
Forward-merge branch-23.08 to branch-23.10
  • Loading branch information
GPUtester authored Jul 26, 2023
2 parents a2c5990 + 9a20221 commit 9ba54cc
Show file tree
Hide file tree
Showing 8 changed files with 3 additions and 35 deletions.
9 changes: 3 additions & 6 deletions python/cucim/src/cucim/skimage/_shared/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,11 @@

have_fetch = True
try:
# scikit-image 0.19
# scikit-image >=0.19
from skimage.data._fetchers import _fetch
except ImportError:
# scikit-image 0.18
try:
from skimage.data import _fetch
except ImportError:
have_fetch = False
# skip this test if private API changed on scikit-image end
have_fetch = False


def fetch(data_filename):
Expand Down
1 change: 0 additions & 1 deletion python/cucim/src/cucim/skimage/feature/tests/test_canny.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ def test_mask_none(self):
result2 = feature.canny(cp.zeros((20, 20)), 4, 0, 0)
assert cp.all(result1 == result2)

@cp.testing.with_requires("scikit-image>=0.18")
@pytest.mark.parametrize('image_dtype', [cp.uint8, cp.int32, cp.float32,
cp.float64])
def test_use_quantiles(self, image_dtype):
Expand Down
14 changes: 0 additions & 14 deletions python/cucim/src/cucim/skimage/filters/tests/test_thresholding.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,20 +282,17 @@ def test_threshold_sauvola_iterable_window_size(self):
assert_array_equal(ref, out)


@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("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("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 @@ -341,7 +338,6 @@ def test_otsu_one_color_image_3d():
assert threshold_otsu(img) == 1


@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 @@ -431,20 +427,17 @@ def test_li_pathological_arrays():
assert cp.all(cp.isfinite(thresholds))


@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("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("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 @@ -467,7 +460,6 @@ def test_local_even_block_size_error():
threshold_local(img, block_size=4)


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

Expand All @@ -479,15 +471,13 @@ def test_isodata_camera_image():
assert_array_equal(threshold_isodata(camera, return_all=True), [102, 103])


@cp.testing.with_requires("scikit-image>=0.18")
def test_isodata_camera_image_histogram():
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("scikit-image>=0.18")
def test_isodata_camera_image_counts():
camera = util.img_as_ubyte(camerad)
counts, bin_centers = histogram(camera.ravel(), 256, source_range='image')
Expand Down Expand Up @@ -551,7 +541,6 @@ def test_isodata_moon_image_negative_float():
# fmt: on


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

Expand All @@ -563,7 +552,6 @@ def test_threshold_minimum():
assert_array_equal(threshold, 114)


@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')
Expand All @@ -578,7 +566,6 @@ def test_threshold_minimum_deprecated_max_iter_kwarg():
threshold_minimum(hist=hist, max_iter=5000)


@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 @@ -774,7 +761,6 @@ def test_multiotsu_more_classes_then_values():
threshold_multiotsu(img, classes=4)


# @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 @@ -24,7 +24,6 @@


@pytest.mark.parametrize('dtype', [cp.uint8, cp.float32, cp.float64])
@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 Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ def test_structural_similarity_multichannel_chelsea():
assert_equal(structural_similarity(Xc, Xc, channel_axis=-1), 1.0)


@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 @@ -209,7 +208,6 @@ def test_gaussian_structural_similarity_vs_IPOL():
@pytest.mark.parametrize(
'dtype', [np.uint8, np.int32, np.float16, np.float32, np.float64]
)
@cp.testing.with_requires("scikit-image>=0.18")
def test_mssim_vs_legacy(dtype):
# 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
@@ -1,7 +1,6 @@
import cupy as cp
import numpy as np
import pytest
import skimage
from skimage.data import camera, chelsea
# from cucim.skimage.restoration import denoise_wavelet
from skimage.restoration import denoise_wavelet
Expand All @@ -23,12 +22,6 @@

# TODO: replace with CuPy version once completed
def _denoise_wavelet(image, rescale_sigma=True, **kwargs):

if 'channel_axis' in kwargs and skimage.__version__ < '0.19.0':
# convert channel_axis to older multichannel kwarg for skimage 0.18.x
channel_axis = kwargs.pop('channel_axis')
kwargs['multichannel'] = False if channel_axis is None else True

return cp.asarray(
denoise_wavelet(
cp.asnumpy(image), rescale_sigma=rescale_sigma, **kwargs
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import cupy as cp
import numpy as np
import pytest
from cupy import testing
from cupyx.scipy import ndimage as ndi
from scipy import signal

Expand Down Expand Up @@ -136,7 +135,6 @@ def test_unsupervised_wiener_deprecated_user_param():
)


@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 Expand Up @@ -177,7 +175,6 @@ def test_richardson_lucy():

@pytest.mark.parametrize('dtype_image', [cp.float16, cp.float32, cp.float64])
@pytest.mark.parametrize('dtype_psf', [cp.float32, cp.float64])
@testing.with_requires("scikit-image>=0.18")
def test_richardson_lucy_filtered(dtype_image, dtype_psf):
if dtype_image == cp.float64:
atol = 1e-8
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ def test_clip_poisson():
assert (cam_poisson2.max() > 1.3) and (cam_poisson2.min() == -1.0)


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

0 comments on commit 9ba54cc

Please sign in to comment.