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

Incorporate upstream changes from scikit-image 0.25 #806

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
d718725
import lazy as _lazy
grlee77 Dec 15, 2024
5dcbfca
remove deprecated 'output' parameter name from gaussian
grlee77 Dec 15, 2024
d65467a
remove unimplemented test case that no longer exists upstream
grlee77 Dec 15, 2024
2dd0a58
update docstring examples for gabor
grlee77 Dec 15, 2024
59ca72e
port upstream updates to regionprops.py from skimage v0.25
grlee77 Dec 15, 2024
15c51c7
add sparse_type kwarg to 'contingency_table'
grlee77 Dec 15, 2024
f4a75be
deprecate square, rectangle, cube in favor of footprint_rectangle
grlee77 Dec 15, 2024
bf40b17
update submodule description strings in __init__.py
grlee77 Dec 16, 2024
3c1d144
update richardson_lucy docstring
grlee77 Dec 16, 2024
a1f6824
update assert_stacklevel test utility
grlee77 Dec 16, 2024
ca8d9f0
CuPy v14 compatibility for random_walker
grlee77 Dec 16, 2024
a9e6fb4
cast integer type in join_segmentations
grlee77 Dec 16, 2024
005003c
update deprecate_parameter with version from skimage 0.25
grlee77 Dec 16, 2024
57b0f1f
use from_euler from scipy
grlee77 Dec 16, 2024
0239788
update map_array.__array__ signature
grlee77 Dec 16, 2024
f437df3
update cucim.skimage.__init__.py so only desired modules are visible
grlee77 Dec 16, 2024
65a17aa
bump minimum NumPy and SciPy supported for consistency with scikit-image
grlee77 Dec 16, 2024
87835d5
bump scikit-image max version
grlee77 Dec 16, 2024
5e13cf4
bump pytest version range
grlee77 Dec 16, 2024
b69b41f
misc min version updates from scikit-image
grlee77 Dec 16, 2024
c2d4b97
fix Euler matrix test cases
grlee77 Dec 16, 2024
b6b0a6b
fix private import to work across scikit-image versions
grlee77 Dec 16, 2024
c9faa55
Apply suggestions from code review
grlee77 Jan 10, 2025
b9ebd63
Merge branch 'branch-25.02' into grelee/skimage025-api-updates
grlee77 Jan 10, 2025
0d34eef
Apply suggestions from code review
grlee77 Jan 16, 2025
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
14 changes: 7 additions & 7 deletions conda/environments/all_cuda-118_arch-x86_64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ dependencies:
- gcc_linux-64=11.*
- imagecodecs>=2021.6.8
- ipython
- lazy_loader>=0.1
- lazy-loader>=0.4
- libcufile-dev=1.4.0.31
- libcufile=1.4.0.31
- libnvjpeg-dev=11.6.0.55
- libnvjpeg=11.6.0.55
- matplotlib-base
- matplotlib-base>=3.7
- nbsphinx
- ninja
- numpy>=1.23.4,<3.0a0
Expand All @@ -36,15 +36,15 @@ dependencies:
- pytest-cov>=2.12.1
- pytest-lazy-fixtures>=1.0.0
- pytest-xdist
- pytest>=6.2.4,<8.0.0a0
- pytest>=7.0.0,<9.0.0a0
- python>=3.10,<3.13
- pywavelets>=1.0
- pywavelets>=1.6
- recommonmark
- scikit-image>=0.19.0,<0.25.0a0
- scipy>=1.6.0
- scikit-image>=0.19.0,<0.26.0a0
- scipy>=1.11.2
- sphinx<6
- sysroot_linux-64==2.17
- tifffile>=2022.7.28
- tifffile>=2022.8.12
- yasm
- pip:
- opencv-python-headless>=4.6
Expand Down
14 changes: 7 additions & 7 deletions conda/environments/all_cuda-125_arch-x86_64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ dependencies:
- gcc_linux-64=11.*
- imagecodecs>=2021.6.8
- ipython
- lazy_loader>=0.1
- lazy-loader>=0.4
- libcufile-dev
- libnvjpeg-dev
- libnvjpeg-static
- matplotlib-base
- matplotlib-base>=3.7
- nbsphinx
- ninja
- numpy>=1.23.4,<3.0a0
Expand All @@ -35,15 +35,15 @@ dependencies:
- pytest-cov>=2.12.1
- pytest-lazy-fixtures>=1.0.0
- pytest-xdist
- pytest>=6.2.4,<8.0.0a0
- pytest>=7.0.0,<9.0.0a0
- python>=3.10,<3.13
- pywavelets>=1.0
- pywavelets>=1.6
- recommonmark
- scikit-image>=0.19.0,<0.25.0a0
- scipy>=1.6.0
- scikit-image>=0.19.0,<0.26.0a0
- scipy>=1.11.2
- sphinx<6
- sysroot_linux-64==2.17
- tifffile>=2022.7.28
- tifffile>=2022.8.12
- yasm
- pip:
- opencv-python-headless>=4.6
Expand Down
18 changes: 9 additions & 9 deletions dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -258,10 +258,10 @@ dependencies:
- output_types: [conda, requirements, pyproject]
packages:
- click
- lazy_loader>=0.1
- lazy-loader>=0.4
grlee77 marked this conversation as resolved.
Show resolved Hide resolved
- numpy>=1.23.4,<3.0a0
- scikit-image>=0.19.0,<0.25.0a0
- scipy>=1.6.0
- scikit-image>=0.19.0,<0.26.0a0
- scipy>=1.11.2
- output_types: conda
packages:
- cupy>=12.0.0
Expand All @@ -285,17 +285,17 @@ dependencies:
- output_types: [conda, requirements, pyproject]
packages:
- psutil>=5.8.0
- pytest>=6.2.4,<8.0.0a0
- pytest>=7.0.0,<9.0.0a0
- pytest-cov>=2.12.1
- pytest-lazy-fixtures>=1.0.0
- pytest-xdist
- tifffile>=2022.7.28
- tifffile>=2022.8.12
- pooch>=1.6.0 # needed to download scikit-image sample data
- pywavelets>=1.0
- pywavelets>=1.6
- output_types: [conda]
packages:
- imagecodecs>=2021.6.8
- matplotlib-base
- matplotlib-base>=3.7
- openslide-python>=1.3.0
- pip
- pip:
Expand All @@ -305,9 +305,9 @@ dependencies:
# skip packages on arm64 that don't provide a wheel
- imagecodecs>=2021.6.8; platform_machine=='x86_64'
- openslide-python>=1.3.0; platform_machine=='x86_64'
- matplotlib
- matplotlib>=3.7
- opencv-python-headless>=4.6
- output_types: [pyproject]
packages:
# Already added to requirements via docs. This is for tests.
- numpydoc>=1.5
- numpydoc>=1.7
16 changes: 8 additions & 8 deletions python/cucim/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ requires-python = ">=3.10"
dependencies = [
"click",
"cupy-cuda11x>=12.0.0",
"lazy_loader>=0.1",
"lazy-loader>=0.4",
"numpy>=1.23.4,<3.0a0",
"scikit-image>=0.19.0,<0.25.0a0",
"scipy>=1.6.0",
"scikit-image>=0.19.0,<0.26.0a0",
"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 = [
"Development Status :: 4 - Beta",
Expand Down Expand Up @@ -58,18 +58,18 @@ Tracker = "https://github.com/rapidsai/cucim/issues"
[project.optional-dependencies]
test = [
"imagecodecs>=2021.6.8; platform_machine=='x86_64'",
"matplotlib",
"numpydoc>=1.5",
"matplotlib>=3.7",
"numpydoc>=1.7",
"opencv-python-headless>=4.6",
"openslide-python>=1.3.0; platform_machine=='x86_64'",
"pooch>=1.6.0",
"psutil>=5.8.0",
"pytest-cov>=2.12.1",
"pytest-lazy-fixtures>=1.0.0",
"pytest-xdist",
"pytest>=6.2.4,<8.0.0a0",
"pywavelets>=1.0",
"tifffile>=2022.7.28",
"pytest>=7.0.0,<9.0.0a0",
"pywavelets>=1.6",
"tifffile>=2022.8.12",
] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`.
developer = [
"black",
Expand Down
4 changes: 2 additions & 2 deletions python/cucim/src/cucim/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@
except ImportError:
pass

import lazy_loader as lazy
import lazy_loader as _lazy

__getattr__, __lazy_dir__, _ = lazy.attach_stub(__name__, __file__)
__getattr__, __lazy_dir__, _ = _lazy.attach_stub(__name__, __file__)


def __dir__():
Expand Down
40 changes: 31 additions & 9 deletions python/cucim/src/cucim/skimage/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,24 @@
exposure
Image intensity adjustment, e.g., histogram equalization, etc.
feature
Feature detection and extraction, e.g., texture analysis corners, etc.
Feature detection and extraction, e.g., texture analysis, corners, etc.
filters
Sharpening, edge finding, rank filters, thresholding, etc.
measure
Measurement of image properties, e.g., region properties and contours.
Measurement of image properties, e.g., region properties, moments.
metrics
Metrics corresponding to images, e.g. distance metrics, similarity, etc.
Metrics corresponding to images, e.g., distance metrics, similarity, etc.
morphology
Morphological operations, e.g., opening or skeletonization.
Morphological algorithms, e.g., closing, opening, skeletonization.
registration
Image registration algorithms, e.g., optical flow or phase cross
correlation.
restoration
Restoration algorithms, e.g., deconvolution algorithms, denoising, etc.
segmentation
Partitioning an image into multiple regions.
Algorithms to partition images into meaningful regions or boundaries.
transform
Geometric and other transforms, e.g., rotation or the Radon transform.
Geometric and other transformations, e.g., rotations, warp.
util
Generic utilities.

Expand Down Expand Up @@ -60,13 +63,32 @@

"""

import lazy_loader as lazy
import lazy_loader as _lazy

__getattr__, __lazy_dir__, _ = lazy.attach_stub(__name__, __file__)
__getattr__, __lazy_dir__, _ = _lazy.attach_stub(__name__, __file__)

# Don't use the `__all__` and `__dir__` returned by `attach_stub` since that
# one would expose utility functions we don't want to advertise in our
# top-level module anymore.
__all__ = [
"color",
"data",
"exposure",
"feature",
"filters",
"measure",
"metrics",
"morphology",
"registration",
"restoration",
"segmentation",
"transform",
"util",
]


def __dir__():
return __lazy_dir__()
return __all__.copy()


# Legacy imports into the root namespace; not advertised in __all__
Expand Down
2 changes: 0 additions & 2 deletions python/cucim/src/cucim/skimage/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import lazy_loader as lazy # noqa: F401

submodules = [
"color",
"data",
Expand Down
11 changes: 1 addition & 10 deletions python/cucim/src/cucim/skimage/_shared/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,12 @@

import cucim.skimage._vendored.ndimage as ndi

from .._shared.utils import (
DEPRECATED,
_supported_float_type,
convert_to_float,
deprecate_parameter,
)
from .._shared.utils import _supported_float_type, convert_to_float


@deprecate_parameter(
"output", new_name="out", start_version="24.06", stop_version="25.02"
)
def gaussian(
image,
sigma=1,
output=DEPRECATED,
mode="nearest",
cval=0,
preserve_range=False,
Expand Down
11 changes: 10 additions & 1 deletion python/cucim/src/cucim/skimage/_shared/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def assert_stacklevel(warnings, *, offset=-1):
When cucim.skimage raises warnings, the stacklevel should ideally be set
so that the origin of the warnings will point to the public function
that was called by the user and not necessarily the very place where the
warnings were emitted (which may be inside of some internal function).
warnings were emitted (which may be inside some internal function).
This utility function helps with checking that
the stacklevel was set correctly on warnings captured by `pytest.warns`.

Expand Down Expand Up @@ -84,10 +84,19 @@ def assert_stacklevel(warnings, *, offset=-1):
... )
... assert_stacklevel(record, offset=-3)
"""
__tracebackhide__ = True # Hide traceback for py.test

frame = inspect.stack()[1].frame # 0 is current frame, 1 is outer frame
line_number = frame.f_lineno + offset
filename = frame.f_code.co_filename
expected = f"{filename}:{line_number}"
for warning in warnings:
actual = f"{warning.filename}:{warning.lineno}"
assert actual == expected, f"{actual} != {expected}"
msg = (
"Warning with wrong stacklevel:\n"
f" Expected: {expected}\n"
f" Actual: {actual}\n"
f" {warning.category.__name__}: {warning.message}"
)
assert actual == expected, msg
18 changes: 4 additions & 14 deletions python/cucim/src/cucim/skimage/_shared/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,31 +319,21 @@ def test_warning_removed_param(self):
r".*_func_deprecated_params`."
)
with pytest.warns(FutureWarning, match=match):
assert _func_deprecated_params(1, 2) == (
1,
DEPRECATED,
DEPRECATED,
None,
)
assert _func_deprecated_params(1, 2) == (1, 2, DEPRECATED, None)
with pytest.warns(FutureWarning, match=match):
assert _func_deprecated_params(1, 2, 3) == (
1,
DEPRECATED,
DEPRECATED,
None,
)
assert _func_deprecated_params(1, 2, 3) == (1, 2, 3, None)
with pytest.warns(FutureWarning, match=match):
assert _func_deprecated_params(1, old0=2) == (
1,
DEPRECATED,
2,
DEPRECATED,
None,
)
with pytest.warns(FutureWarning, match=match):
assert _func_deprecated_params(1, old1=2) == (
1,
DEPRECATED,
DEPRECATED,
2,
None,
)

Expand Down
17 changes: 11 additions & 6 deletions python/cucim/src/cucim/skimage/_shared/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,14 +294,19 @@ def fixed_func(*args, **kwargs):
# Extract value of deprecated parameter
if len(args) > deprecated_idx:
deprecated_value = args[deprecated_idx]
args = (
args[:deprecated_idx]
+ (DEPRECATED,)
+ args[deprecated_idx + 1 :]
)
# Overwrite old with DEPRECATED if replacement exists
if self.new_name is not None:
args = (
args[:deprecated_idx]
+ (DEPRECATED,)
+ args[deprecated_idx + 1 :]
)
if self.deprecated_name in kwargs.keys():
deprecated_value = kwargs[self.deprecated_name]
kwargs[self.deprecated_name] = DEPRECATED
# Overwrite old with DEPRECATED if replacement exists
if self.new_name is not None:
kwargs[self.deprecated_name] = DEPRECATED

# Extract value of new parameter (if present)
if new_idx is not False and len(args) > new_idx:
new_value = args[new_idx]
Expand Down
2 changes: 2 additions & 0 deletions python/cucim/src/cucim/skimage/color/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""Color space conversion."""

from .colorconv import (
ahx_from_rgb,
bex_from_rgb,
Expand Down
4 changes: 2 additions & 2 deletions python/cucim/src/cucim/skimage/data/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import lazy_loader as lazy
import lazy_loader as _lazy

__getattr__, __dir__, __all__ = lazy.attach_stub(__name__, __file__)
__getattr__, __dir__, __all__ = _lazy.attach_stub(__name__, __file__)
6 changes: 4 additions & 2 deletions python/cucim/src/cucim/skimage/exposure/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import lazy_loader as lazy
"""Image intensity adjustment, e.g., histogram equalization, etc."""

__getattr__, __dir__, __all__ = lazy.attach_stub(__name__, __file__)
import lazy_loader as _lazy

__getattr__, __dir__, __all__ = _lazy.attach_stub(__name__, __file__)
6 changes: 4 additions & 2 deletions python/cucim/src/cucim/skimage/feature/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import lazy_loader as lazy
"""Feature detection and extraction, e.g., blobs, corners, etc."""

__getattr__, __dir__, __all__ = lazy.attach_stub(__name__, __file__)
import lazy_loader as _lazy

__getattr__, __dir__, __all__ = _lazy.attach_stub(__name__, __file__)
6 changes: 4 additions & 2 deletions python/cucim/src/cucim/skimage/filters/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import lazy_loader as lazy
"""Sharpening, edge finding, thresholding, etc."""

__getattr__, __dir__, __all__ = lazy.attach_stub(__name__, __file__)
import lazy_loader as _lazy

__getattr__, __dir__, __all__ = _lazy.attach_stub(__name__, __file__)
Loading
Loading