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

remove unimplemented functions from See Also and fix version numbers in deprecation warnings #356

Merged
merged 2 commits into from
Jul 28, 2022
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
6 changes: 3 additions & 3 deletions python/cucim/src/cucim/skimage/_shared/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ def bar(arg0, arg1=0, arg2=1):

def test_deprecate_kwarg():

@deprecate_kwarg({'old_arg1': 'new_arg1'}, '0.19')
@deprecate_kwarg({'old_arg1': 'new_arg1'}, '22.02.00')
def foo(arg0, new_arg1=1, arg2=None):
"""Expected docstring"""
return arg0, new_arg1, arg2

@deprecate_kwarg({'old_arg1': 'new_arg1'},
deprecated_version='0.19',
deprecated_version='22.02.00',
warning_msg="Custom warning message")
def bar(arg0, new_arg1=1, arg2=None):
"""Expected docstring"""
Expand Down Expand Up @@ -116,7 +116,7 @@ def bar(arg0, new_arg1=1, arg2=None):
old_arg1 : DEPRECATED
Deprecated in favor of `new_arg1`.

.. deprecated:: 0.19
.. deprecated:: 22.02.00
"""

assert len(recorded) == 0
Expand Down
18 changes: 10 additions & 8 deletions python/cucim/src/cucim/skimage/_shared/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,11 @@ def __call__(self, func):
parameters = inspect.signature(func).parameters
arg_idx = list(parameters.keys()).index(self.arg_name)
warning_msg = (
f"{self.arg_name} argument is deprecated and will be removed "
f"in version {self.changed_version}. To avoid this warning, "
f"please do not use the {self.arg_name} argument. Please "
f"see {func.__name__} documentation for more details.")
f"{self.arg_name} argument is deprecated in upstream scikit-image "
f"and will be removed in cuCIM {self.changed_version}. To avoid "
f"this warning, please do not use the {self.arg_name} argument. "
f"Please see {func.__name__} documentation for more details."
)

if self.help_msg is not None:
warning_msg += f" {self.help_msg}"
Expand Down Expand Up @@ -206,7 +207,7 @@ def __init__(self, kwarg_mapping, deprecated_version, warning_msg=None,
self.warning_msg = ("`{old_arg}` is a deprecated argument name "
"for `{func_name}`. ")
if removed_version is not None:
self.warning_msg += (f'It will be removed in '
self.warning_msg += (f'It will be removed in cuCIM '
f'version {removed_version}.')
self.warning_msg += "Please use `{new_arg}` instead."
else:
Expand Down Expand Up @@ -248,10 +249,11 @@ class deprecate_multichannel_kwarg(deprecate_kwarg):

"""

def __init__(self, removed_version='1.0', multichannel_position=None):
def __init__(self, removed_version='2023.02.00',
multichannel_position=None):
super().__init__(
kwarg_mapping={'multichannel': 'channel_axis'},
deprecated_version='0.19',
deprecated_version='22.02.00',
warning_msg=None,
removed_version=removed_version)
self.position = multichannel_position
Expand Down Expand Up @@ -293,7 +295,7 @@ def fixed_func(*args, **kwargs):

if func.__doc__ is not None:
newdoc = docstring_add_deprecated(
func, {'multichannel': 'channel_axis'}, '0.19')
func, {'multichannel': 'channel_axis'}, '22.02.00')
fixed_func.__doc__ = newdoc
return fixed_func

Expand Down
2 changes: 1 addition & 1 deletion python/cucim/src/cucim/skimage/_vendored/signaltools.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ def choose_conv_method(in1, in2, mode="full", measure=False):
returns `direct` (e.g., to protect against floating point integer
precision).

.. versionadded:: 0.19
.. versionadded:: 22.02.00

Examples
--------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,11 +297,7 @@ def test_rescale_in_range_clip():
def test_rescale_out_range(dtype):
"""Check that output range is correct.

.. versionchanged:: 0.17
This function used to return dtype matching the input dtype. It now
matches the output.

.. versionchanged:: 0.19
.. versionchanged:: 22.02.00
float16 and float32 inputs now result in float32 output. Formerly they
would give float64 outputs.
"""
Expand Down
5 changes: 3 additions & 2 deletions python/cucim/src/cucim/skimage/filters/_median.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
from .._shared.utils import deprecate_kwarg


@deprecate_kwarg(kwarg_mapping={'selem': 'footprint'}, removed_version="1.0",
deprecated_version="0.19")
@deprecate_kwarg(kwarg_mapping={'selem': 'footprint'},
removed_version="23.02.00",
deprecated_version="22.02.00")
def median(image, footprint=None, out=None, mode='nearest', cval=0.0,
behavior='ndimage'):
"""Return local median of an image.
Expand Down
4 changes: 2 additions & 2 deletions python/cucim/src/cucim/skimage/filters/thresholding.py
Original file line number Diff line number Diff line change
Expand Up @@ -735,8 +735,8 @@ def threshold_li(image, *, tolerance=None, initial_guess=None,
return threshold


@deprecate_kwarg({'max_iter': 'max_num_iter'}, removed_version="1.0",
deprecated_version="0.19")
@deprecate_kwarg({'max_iter': 'max_num_iter'}, removed_version="23.02.00",
deprecated_version="22.02.00")
def threshold_minimum(image=None, nbins=256, max_num_iter=10000, *, hist=None):
"""Return threshold value based on minimum method.

Expand Down
4 changes: 2 additions & 2 deletions python/cucim/src/cucim/skimage/measure/_label.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ def _get_structure(ndim, connectivity):

# TODO: currently uses int32 for the labels. should add int64 option as well
@deprecate_kwarg({'input': 'label_image'},
deprecated_version='0.19',
removed_version='1.0')
deprecated_version='22.02.00',
removed_version='23.02.00')
def label(label_image, background=None, return_num=False, connectivity=None):
r"""Label connected regions of an integer array.

Expand Down
6 changes: 3 additions & 3 deletions python/cucim/src/cucim/skimage/morphology/_skeletonize.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
0, 0, 0, 0, 0, 0, 0, 0, 0], dtype=bool)


@deprecate_kwarg({'max_iter': 'max_num_iter'}, removed_version="1.0",
deprecated_version="0.19")
@deprecate_kwarg({'max_iter': 'max_num_iter'}, removed_version="23.02.00",
deprecated_version="22.02.00")
def thin(image, max_num_iter=None):
"""
Perform morphological thinning of a binary image.
Expand All @@ -62,7 +62,7 @@ def thin(image, max_num_iter=None):

See Also
--------
skeletonize, medial_axis
medial_axis

Notes
-----
Expand Down
20 changes: 12 additions & 8 deletions python/cucim/src/cucim/skimage/morphology/binary.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ def _iterate_binary_func(binary_func, image, footprint, out):
# default with the same dimension as the input image and size 3 along each
# axis.
@default_footprint
@deprecate_kwarg(kwarg_mapping={'selem': 'footprint'}, removed_version="1.0",
deprecated_version="0.19")
@deprecate_kwarg(kwarg_mapping={'selem': 'footprint'},
removed_version="23.02.00",
deprecated_version="22.02.00")
def binary_erosion(image, footprint=None, out=None):
"""Return fast binary morphological erosion of an image.

Expand Down Expand Up @@ -94,8 +95,9 @@ def binary_erosion(image, footprint=None, out=None):


@default_footprint
@deprecate_kwarg(kwarg_mapping={'selem': 'footprint'}, removed_version="1.0",
deprecated_version="0.19")
@deprecate_kwarg(kwarg_mapping={'selem': 'footprint'},
removed_version="23.02.00",
deprecated_version="22.02.00")
def binary_dilation(image, footprint=None, out=None):
"""Return fast binary morphological dilation of an image.

Expand Down Expand Up @@ -149,8 +151,9 @@ def binary_dilation(image, footprint=None, out=None):


@default_footprint
@deprecate_kwarg(kwarg_mapping={'selem': 'footprint'}, removed_version="1.0",
deprecated_version="0.19")
@deprecate_kwarg(kwarg_mapping={'selem': 'footprint'},
removed_version="23.02.00",
deprecated_version="22.02.00")
def binary_opening(image, footprint=None, out=None):
"""Return fast binary morphological opening of an image.

Expand Down Expand Up @@ -199,8 +202,9 @@ def binary_opening(image, footprint=None, out=None):


@default_footprint
@deprecate_kwarg(kwarg_mapping={'selem': 'footprint'}, removed_version="1.0",
deprecated_version="0.19")
@deprecate_kwarg(kwarg_mapping={'selem': 'footprint'},
removed_version="23.02.00",
deprecated_version="22.02.00")
def binary_closing(image, footprint=None, out=None):
"""Return fast binary morphological closing of an image.

Expand Down
4 changes: 2 additions & 2 deletions python/cucim/src/cucim/skimage/morphology/footprints.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ def _decompose_size(size, kernel_size=3):


@deprecate_kwarg({'height': 'ncols', 'width': 'nrows'},
deprecated_version='0.18.0',
removed_version='0.20.0')
deprecated_version='21.06.00',
removed_version='22.02.00')
def rectangle(nrows, ncols, dtype=cp.uint8, *, decomposition=None):
"""Generates a flat, rectangular-shaped footprint.

Expand Down
24 changes: 12 additions & 12 deletions python/cucim/src/cucim/skimage/morphology/gray.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ def func_out(image, footprint, out=None, *args, **kwargs):


@default_footprint
@deprecate_kwarg(kwarg_mapping={'selem': 'footprint'}, removed_version="1.0",
deprecated_version="0.19")
@deprecate_kwarg(kwarg_mapping={'selem': 'footprint'},
removed_version="23.02.00", deprecated_version="22.02.00")
def erosion(image, footprint=None, out=None, shift_x=False, shift_y=False):
"""Return grayscale morphological erosion of an image.

Expand Down Expand Up @@ -236,8 +236,8 @@ def erosion(image, footprint=None, out=None, shift_x=False, shift_y=False):


@default_footprint
@deprecate_kwarg(kwarg_mapping={'selem': 'footprint'}, removed_version="1.0",
deprecated_version="0.19")
@deprecate_kwarg(kwarg_mapping={'selem': 'footprint'},
removed_version="23.02.00", deprecated_version="22.02.00")
def dilation(image, footprint=None, out=None, shift_x=False, shift_y=False):
"""Return grayscale morphological dilation of an image.

Expand Down Expand Up @@ -324,8 +324,8 @@ def dilation(image, footprint=None, out=None, shift_x=False, shift_y=False):
return out


@deprecate_kwarg(kwarg_mapping={'selem': 'footprint'}, removed_version="1.0",
deprecated_version="0.19")
@deprecate_kwarg(kwarg_mapping={'selem': 'footprint'},
removed_version="23.02.00", deprecated_version="22.02.00")
@default_footprint
@pad_for_eccentric_footprints
def opening(image, footprint=None, out=None):
Expand Down Expand Up @@ -390,8 +390,8 @@ def opening(image, footprint=None, out=None):
return out


@deprecate_kwarg(kwarg_mapping={'selem': 'footprint'}, removed_version="1.0",
deprecated_version="0.19")
@deprecate_kwarg(kwarg_mapping={'selem': 'footprint'},
removed_version="23.02.00", deprecated_version="22.02.00")
@default_footprint
@pad_for_eccentric_footprints
def closing(image, footprint=None, out=None):
Expand Down Expand Up @@ -474,8 +474,8 @@ def _white_tophat_seqence(image, footprints, out):


@default_footprint
@deprecate_kwarg(kwarg_mapping={'selem': 'footprint'}, removed_version="1.0",
deprecated_version="0.19")
@deprecate_kwarg(kwarg_mapping={'selem': 'footprint'},
removed_version="23.02.00", deprecated_version="22.02.00")
def white_tophat(image, footprint=None, out=None):
"""Return white top hat of an image.

Expand Down Expand Up @@ -565,8 +565,8 @@ def white_tophat(image, footprint=None, out=None):


@default_footprint
@deprecate_kwarg(kwarg_mapping={'selem': 'footprint'}, removed_version="1.0",
deprecated_version="0.19")
@deprecate_kwarg(kwarg_mapping={'selem': 'footprint'},
removed_version="23.02.00", deprecated_version="22.02.00")
def black_tophat(image, footprint=None, out=None):
"""Return black top hat of an image.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
from .._shared.utils import deprecate_kwarg


@deprecate_kwarg(kwarg_mapping={'selem': 'footprint'}, removed_version="1.0",
deprecated_version="0.19")
@deprecate_kwarg(kwarg_mapping={'selem': 'footprint'},
removed_version="23.02.00", deprecated_version="22.02.00")
def reconstruction(seed, mask, method='dilation', footprint=None, offset=None):
"""Perform a morphological reconstruction of an image.

Expand Down
4 changes: 2 additions & 2 deletions python/cucim/src/cucim/skimage/morphology/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def remove_small_objects(ar, min_size=64, connectivity=1, in_place=False,
labelling if `ar` is bool.
in_place : bool, optional (default: False)
If ``True``, remove the objects in the input array itself.
Otherwise, make a copy. Deprecated since version 0.19. Please
Otherwise, make a copy. Deprecated since version 22.02.00. Please
use `out` instead.
out : ndarray
Array of the same shape as `ar`, into which the output is
Expand Down Expand Up @@ -172,7 +172,7 @@ def remove_small_holes(ar, area_threshold=64, connectivity=1, in_place=False,
The connectivity defining the neighborhood of a pixel.
in_place : bool, optional (default: False)
If `True`, remove the connected components in the input array
itself. Otherwise, make a copy. Deprecated since version 0.19.
itself. Otherwise, make a copy. Deprecated since version 22.02.00.
Please use `out` instead.
out : ndarray
Array of the same shape as `ar` and bool dtype, into which the
Expand Down
5 changes: 3 additions & 2 deletions python/cucim/src/cucim/skimage/restoration/_denoise.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,9 @@ def _denoise_tv_chambolle_nd(image, weight=0.1, eps=2.0e-4, max_num_iter=200):
return out


@utils.deprecate_kwarg({'n_iter_max': 'max_num_iter'}, removed_version="1.0",
deprecated_version="0.19.2")
@utils.deprecate_kwarg({'n_iter_max': 'max_num_iter'},
removed_version="23.02.00",
deprecated_version="22.06.00")
@utils.deprecate_multichannel_kwarg(multichannel_position=4)
def denoise_tv_chambolle(image, weight=0.1, eps=2.0e-4, max_num_iter=200,
multichannel=False, *, channel_axis=None):
Expand Down
4 changes: 2 additions & 2 deletions python/cucim/src/cucim/skimage/restoration/deconvolution.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,8 +383,8 @@ def unsupervised_wiener(image, psf, reg=None, user_params=None, is_real=True,
return (x_postmean, {'noise': gn_chain, 'prior': gx_chain})


@deprecate_kwarg({'iterations': 'num_iter'}, removed_version="1.0",
deprecated_version="0.19")
@deprecate_kwarg({'iterations': 'num_iter'}, removed_version="23.02.00",
deprecated_version="22.02.00")
def richardson_lucy(image, psf, num_iter=50, clip=True, filter_epsilon=None):
"""Richardson-Lucy deconvolution.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
# 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':
if 'channel_axis' in kwargs and skimage.__version__ < '22.02.00':
# 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
Expand Down Expand Up @@ -62,7 +62,7 @@ def test_invariant_denoise_color(dtype):

def test_invariant_denoise_color_deprecated():

# can remove \A\Z here if only testing with scikit-image 0.19
# can remove \A\Z here if only testing with cuCIM 22.02.00
with expected_warnings([r"`multichannel` is a deprecated argument|\A\Z"]):
denoised_img_color = _invariant_denoise(
noisy_img_color, _denoise_wavelet,
Expand Down
10 changes: 6 additions & 4 deletions python/cucim/src/cucim/skimage/segmentation/morphsnakes.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,9 @@ def inverse_gaussian_gradient(image, alpha=100.0, sigma=5.0):
return 1.0 / cp.sqrt(1.0 + alpha * gradnorm)


@deprecate_kwarg({'iterations': 'num_iter'}, removed_version="1.0",
deprecated_version="0.19")
@deprecate_kwarg({'iterations': 'num_iter'},
removed_version="23.02.00",
deprecated_version="22.02.00")
def morphological_chan_vese(image, num_iter, init_level_set='checkerboard',
smoothing=1, lambda1=1, lambda2=1,
iter_callback=lambda x: None):
Expand Down Expand Up @@ -326,8 +327,9 @@ def morphological_chan_vese(image, num_iter, init_level_set='checkerboard',
return u


@deprecate_kwarg({'iterations': 'num_iter'}, removed_version="1.0",
deprecated_version="0.19")
@deprecate_kwarg({'iterations': 'num_iter'},
removed_version="23.02.00",
deprecated_version="22.02.00")
def morphological_geodesic_active_contour(gimage, num_iter,
init_level_set='disk', smoothing=1,
threshold='auto', balloon=0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,12 +343,6 @@ def random_walker(data, labels, beta=130, mode='cg_j', tol=1.e-3, copy=True,
probability that label `label_nb` reaches the pixel `(i, j)`
first.

See Also
--------
skimage.morphology.watershed : watershed segmentation
A segmentation algorithm based on mathematical morphology
and "flooding" of regions from markers.

Notes
-----
Multichannel inputs are scaled with all channel data combined. Ensure all
Expand Down
Loading