Skip to content

Commit

Permalink
add tests for deprecated argument names
Browse files Browse the repository at this point in the history
  • Loading branch information
grlee77 committed Nov 2, 2023
1 parent 3703914 commit 11403ec
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 2 deletions.
6 changes: 6 additions & 0 deletions python/cucim/src/cucim/skimage/data/tests/test_data.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import cupy as cp
import pytest
from numpy.testing import assert_almost_equal

from cucim.skimage import data
Expand All @@ -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)
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 11403ec

Please sign in to comment.