Skip to content
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
2 changes: 2 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ repos:
^python/cucim/src/cucim/skimage/restoration/tests/test_restoration[.]py$|
^python/cucim/src/cucim/skimage/restoration/uft[.]py$|
^python/cucim/src/cucim/skimage/segmentation/__init__[.]py$|
^python/cucim/src/cucim/skimage/segmentation/__init__[.]pyi$|
^python/cucim/src/cucim/skimage/segmentation/_chan_vese[.]py$|
^python/cucim/src/cucim/skimage/segmentation/_clear_border[.]py$|
^python/cucim/src/cucim/skimage/segmentation/_join[.]py$|
Expand Down Expand Up @@ -509,6 +510,7 @@ repos:
python/cucim/src/cucim/skimage/restoration/tests/test_restoration[.]py$|
python/cucim/src/cucim/skimage/restoration/uft[.]py$|
python/cucim/src/cucim/skimage/segmentation/__init__[.]py$|
python/cucim/src/cucim/skimage/segmentation/__init__[.]pyi$|
python/cucim/src/cucim/skimage/segmentation/_chan_vese[.]py$|
python/cucim/src/cucim/skimage/segmentation/_clear_border[.]py$|
python/cucim/src/cucim/skimage/segmentation/_join[.]py$|
Expand Down
2 changes: 1 addition & 1 deletion conda/environments/all_cuda-129_arch-aarch64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ dependencies:
- python>=3.11,<3.14
- pywavelets>=1.6
- recommonmark
- scikit-image>=0.19.0,<0.26.0
- scikit-image>=0.23.2,<0.27.0
- scipy>=1.11.2
- sphinx>=8.0.0,<8.2.0
- sysroot_linux-aarch64==2.28
Expand Down
2 changes: 1 addition & 1 deletion conda/environments/all_cuda-129_arch-x86_64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ dependencies:
- python>=3.11,<3.14
- pywavelets>=1.6
- recommonmark
- scikit-image>=0.19.0,<0.26.0
- scikit-image>=0.23.2,<0.27.0
- scipy>=1.11.2
- sphinx>=8.0.0,<8.2.0
- sysroot_linux-64==2.28
Expand Down
2 changes: 1 addition & 1 deletion conda/environments/all_cuda-131_arch-aarch64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ dependencies:
- python>=3.11,<3.14
- pywavelets>=1.6
- recommonmark
- scikit-image>=0.19.0,<0.26.0
- scikit-image>=0.23.2,<0.27.0
- scipy>=1.11.2
- sphinx>=8.0.0,<8.2.0
- sysroot_linux-aarch64==2.28
Expand Down
2 changes: 1 addition & 1 deletion conda/environments/all_cuda-131_arch-x86_64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ dependencies:
- python>=3.11,<3.14
- pywavelets>=1.6
- recommonmark
- scikit-image>=0.19.0,<0.26.0
- scikit-image>=0.23.2,<0.27.0
- scipy>=1.11.2
- sphinx>=8.0.0,<8.2.0
- sysroot_linux-64==2.28
Expand Down
2 changes: 1 addition & 1 deletion dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ dependencies:
- click
- lazy-loader>=0.4
- numpy>=1.23.4,<3.0
- scikit-image>=0.19.0,<0.26.0
- scikit-image>=0.23.2,<0.27.0
- scipy>=1.11.2
- output_types: conda
packages:
Expand Down
2 changes: 1 addition & 1 deletion python/cucim/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ dependencies = [
"lazy-loader>=0.4",
"numpy>=1.23.4,<3.0",
"nvidia-nvimgcodec-cu13>=0.7.0,<0.8.0",
"scikit-image>=0.19.0,<0.26.0",
"scikit-image>=0.23.2,<0.27.0",
"scipy>=1.11.2",
] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`.
classifiers = [
Expand Down
3 changes: 2 additions & 1 deletion python/cucim/src/cucim/skimage/_shared/compat.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# SPDX-FileCopyrightText: 2009-2022 the scikit-image team
# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. All rights reserved.
# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause

"""Compatibility helpers for dependencies."""
Expand Down Expand Up @@ -28,6 +28,7 @@
# check CuPy instead of SciPy
CUPY_LT_14 = parse(cp.__version__) < parse("14.0.0a1")


# Starting in SciPy v1.12, 'scipy.sparse.linalg.cg' keyword argument `tol` is
# deprecated in favor of `rtol`. The corresponding change in cupyx.scipy.sparse
# was made in v14.0
Expand Down
4 changes: 2 additions & 2 deletions python/cucim/src/cucim/skimage/_shared/coord.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# SPDX-FileCopyrightText: 2009-2022 the scikit-image team
# SPDX-FileCopyrightText: Copyright (c) 2021-2025, NVIDIA CORPORATION. All rights reserved.
# SPDX-FileCopyrightText: Copyright (c) 2021-2026, NVIDIA CORPORATION. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause

import cupy as cp
Expand All @@ -22,7 +22,7 @@ def _ensure_spacing(coord, spacing, p_norm, max_out):
A finite large p may cause a ValueError if overflow can occur.
``inf`` corresponds to the Chebyshev distance and 2 to the
Euclidean distance.
max_out: int
max_out : int
If not None, at most the first ``max_out`` candidates are
returned.

Expand Down
63 changes: 57 additions & 6 deletions python/cucim/src/cucim/skimage/_shared/tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SPDX-FileCopyrightText: 2009-2022 the scikit-image team
# SPDX-FileCopyrightText: Copyright (c) 2021-2025, NVIDIA CORPORATION. All rights reserved.
# SPDX-FileCopyrightText: Copyright (c) 2021-2026, NVIDIA CORPORATION. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause

import re
import sys
import warnings

Expand All @@ -12,11 +12,14 @@
from cucim.skimage._shared import testing
from cucim.skimage._shared.utils import (
DEPRECATED,
FailedEstimation,
FailedEstimationAccessError,
_supported_float_type,
_validate_interpolation_order,
change_default_value,
channel_as_last_axis,
check_nD,
deprecate_func,
deprecate_parameter,
)

Expand All @@ -34,7 +37,9 @@


def test_change_default_value():
@change_default_value("arg1", new_value=-1, changed_version="0.12")
@change_default_value(
"arg1", new_value=-1, changed_version="0.12", stacklevel=2
)
def foo(arg0, arg1=0, arg2=1):
"""Expected docstring"""
return arg0, arg1, arg2
Expand All @@ -44,6 +49,7 @@ def foo(arg0, arg1=0, arg2=1):
new_value=-1,
changed_version="0.12",
warning_msg="Custom warning message",
stacklevel=2,
)
def bar(arg0, arg1=0, arg2=1):
"""Expected docstring"""
Expand Down Expand Up @@ -202,6 +208,29 @@ def test_decorated_channel_axis_shape(channel_axis):
assert size == x.shape[channel_axis]


@deprecate_func(
deprecated_version="x", removed_version="y", hint="You are on your own."
)
def _deprecated_func():
"""Dummy function used in `test_deprecate_func`.

The decorated function must be outside the test function, otherwise it
seems that the warning does not point at the calling location.
"""


def test_deprecate_func():
with pytest.warns(FutureWarning) as record:
_deprecated_func()
testing.assert_stacklevel(record)

assert len(record) == 1
assert record[0].message.args[0] == (
"`_deprecated_func` is deprecated since version x and will be removed in "
"version y. You are on your own."
)


@deprecate_parameter("old1", start_version="0.10", stop_version="0.12")
@deprecate_parameter("old0", start_version="0.10", stop_version="0.12")
def _func_deprecated_params(arg0, old0=DEPRECATED, old1=DEPRECATED, arg1=None):
Expand Down Expand Up @@ -478,15 +507,15 @@ def test_wrong_call_signature(self):
_func_deprecated_params(1, 2, old0=2)

def test_wrong_param_name(self):
with pytest.raises(ValueError, match="'old' is not in list"):
with pytest.raises(ValueError, match="'old' not in parameters"):

@deprecate_parameter(
"old", start_version="0.10", stop_version="0.12"
)
def foo(arg0):
pass

with pytest.raises(ValueError, match="'new' is not in list"):
with pytest.raises(ValueError, match="'new' not in parameters"):

@deprecate_parameter(
"old", new_name="new", start_version="0.10", stop_version="0.12"
Expand All @@ -509,7 +538,8 @@ def test_stacklevel(self):
def foo(arg0, old=DEPRECATED):
pass

with pytest.raises(RuntimeError, match="Set stacklevel manually"):
regex = "Cannot determine stacklevel.*Set the stacklevel manually"
with pytest.raises(ValueError, match=regex):
foo(0, 1)

@deprecate_parameter(
Expand All @@ -526,3 +556,24 @@ def bar(arg0, old=DEPRECATED):
) as records:
bar(0, 1)
testing.assert_stacklevel(records)


def test_failed_estimation():
msg = "Something went wrong with estimation"
fe = FailedEstimation(msg)
assert fe.message == msg
assert str(fe) == msg
assert repr(fe).startswith("FailedEstimation(")
assert bool(fe) is False

regex = re.compile(
"FailedEstimation is not callable.*Hint", flags=re.DOTALL
)
with pytest.raises(FailedEstimationAccessError, match=regex):
fe(np.ones((10, 2)))

regex = re.compile(
"FailedEstimation has no attribute 'params'.*Hint", flags=re.DOTALL
)
with pytest.raises(FailedEstimationAccessError, match=regex):
fe.params
Loading
Loading