diff --git a/python/cucim/src/cucim/skimage/data/tests/test_data.py b/python/cucim/src/cucim/skimage/data/tests/test_data.py index eb92b2294..2a7d8f528 100644 --- a/python/cucim/src/cucim/skimage/data/tests/test_data.py +++ b/python/cucim/src/cucim/skimage/data/tests/test_data.py @@ -1,4 +1,5 @@ import cupy as cp +import pytest from numpy.testing import assert_almost_equal from cucim.skimage import data @@ -15,3 +16,8 @@ def test_binary_blobs(): length=32, volume_fraction=0.25, n_dim=3 ) assert not cp.all(blobs == other_realization) + + +def test_binary_blobs_futurewarning(): + with pytest.warns(FutureWarning): + data.binary_blobs(length=128, seed=5) diff --git a/python/cucim/src/cucim/skimage/morphology/tests/test_skeletonize.py b/python/cucim/src/cucim/skimage/morphology/tests/test_skeletonize.py index 2fbafafc1..42b9926dd 100644 --- a/python/cucim/src/cucim/skimage/morphology/tests/test_skeletonize.py +++ b/python/cucim/src/cucim/skimage/morphology/tests/test_skeletonize.py @@ -1,4 +1,5 @@ import cupy as cp +import numpy as np import pytest from cupy.testing import assert_array_equal from skimage import data @@ -93,7 +94,7 @@ def test_00_01_zeros_masked(self): result = medial_axis(cp.zeros((10, 10), bool), cp.zeros((10, 10), bool)) assert not cp.any(result) - def test_vertical_line(self): + def _test_vertical_line(self, **kwargs): """Test a thick vertical line, issue #3861""" img = cp.zeros((9, 9)) img[:, 2] = 1 @@ -103,9 +104,35 @@ def test_vertical_line(self): expected = cp.full(img.shape, False) expected[:, 3] = True - result = medial_axis(img) + result = medial_axis(img, **kwargs) assert_array_equal(result, expected) + def test_vertical_line(self): + """Test a thick vertical line, issue #3861""" + self._test_vertical_line() + + def test_rng_numpy(self): + # NumPy Generator allowed + self._test_vertical_line(rng=np.random.default_rng()) + + def test_rng_cupy(self): + # CuPy Generator not currently supported + with pytest.raises(ValueError): + self._test_vertical_line(rng=cp.random.default_rng()) + + def test_rng_int(self): + self._test_vertical_line(rng=15) + + def test_vertical_line_seed(self): + """seed was deprecated (now use rng)""" + with pytest.warns(FutureWarning): + self._test_vertical_line(seed=15) + + def test_vertical_line_random_state(self): + """random_state was deprecated (now use rng)""" + with pytest.warns(FutureWarning): + self._test_vertical_line(random_state=15) + def test_01_01_rectangle(self): """Test skeletonize on a rectangle""" image = cp.zeros((9, 15), bool) diff --git a/python/cucim/src/cucim/skimage/restoration/tests/test_restoration.py b/python/cucim/src/cucim/skimage/restoration/tests/test_restoration.py index 02ac6e60b..94a5c308f 100644 --- a/python/cucim/src/cucim/skimage/restoration/tests/test_restoration.py +++ b/python/cucim/src/cucim/skimage/restoration/tests/test_restoration.py @@ -143,6 +143,19 @@ def test_unsupervised_wiener_deprecated_user_param(): random_state=5, ) + with expected_warnings( + [ + "`seed` is a deprecated argument name", + ] + ): + restoration.unsupervised_wiener( + data, + otf, + reg=laplacian, + is_real=False, + seed=5, + ) + def test_image_shape(): """Test that shape of output image in deconvolution is same as input. diff --git a/python/cucim/src/cucim/skimage/util/tests/test_random_noise.py b/python/cucim/src/cucim/skimage/util/tests/test_random_noise.py index 6dcc0578c..43383113f 100644 --- a/python/cucim/src/cucim/skimage/util/tests/test_random_noise.py +++ b/python/cucim/src/cucim/skimage/util/tests/test_random_noise.py @@ -16,6 +16,14 @@ def test_set_seed(): assert_array_equal(test, random_noise(cam, rng=seed)) +def test_random_noise_futurewarning(): + seed = 42 + cam = cp.asarray(camerad) + with pytest.warns(FutureWarning): + test = random_noise(cam, seed=seed) + assert_array_equal(test, random_noise(cam, rng=seed)) + + def test_salt(): amount = 0.15 cam = img_as_float(camerad)