Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Gigon Bae <[email protected]>
  • Loading branch information
grlee77 and gigony authored Feb 26, 2025
1 parent 4594920 commit 3695936
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions python/cucim/src/cucim/skimage/morphology/convex_hull.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ def convex_hull_image(
.. [1] https://blogs.mathworks.com/steve/2011/10/04/binary-image-convex-hull-algorithm-notes/
"""
if cpu_fallback_threshold is not None and cpu_fallback_threshold < 0:
raise ValueError("cpu_fallback_threshold must be non-negative")
if cpu_fallback_threshold is None:
# Fallback to scikit-image implementation of total number of pixels
# is less than this
Expand Down Expand Up @@ -188,7 +190,7 @@ def convex_hull_image(
"Returning empty image",
UserWarning,
)
return np.zeros(image.shape, dtype=bool)
return cp.zeros(image.shape, dtype=bool)

if image.dtype != cp.dtype(bool):
if image.dtype == cp.uint8:
Expand Down Expand Up @@ -299,7 +301,6 @@ def convex_hull_object(
raise ValueError("`connectivity` must be between 1 and image.ndim.")

labeled_im = label(image, connectivity=connectivity, background=0)
convex_obj = cp.zeros(image.shape, dtype=bool)
convex_img = cp.zeros(image.shape, dtype=bool)

max_label = int(labeled_im.max())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ def test_few_points():
chimage3d = convex_hull_image(
image3d, offset_coordinates=True, cpu_fallback_threshold=0
)
chimage3d.sum() > 0
assert chimage3d.sum() > 0


"""
Expand Down

0 comments on commit 3695936

Please sign in to comment.