Skip to content

Commit 0b0a840

Browse files
yushiranericspodcoderabbitai[bot]
authored
fix(losses): add missing docstring entries for default parameters (#8755)
## Description Fixes missing and incomplete docstring parameter documentation in two loss files, consistent with the pattern established in #8701. ### Changes **`monai/losses/hausdorff_loss.py`** - `HausdorffDTLoss.__init__`: Added missing `alpha` parameter (default `2.0`) to the `Args` section. The parameter was present in the function signature but completely absent from the docstring. **`monai/losses/cldice.py`** - `SoftclDiceLoss.__init__`: Added `Defaults to X.` to `iter_` and `smooth` parameter descriptions. - `SoftDiceclDiceLoss.__init__`: Added `Defaults to X.` to `iter_`, `smooth`, and `alpha` parameter descriptions. ### Motivation These are pure docstring fixes — no code logic was changed. The missing `alpha` documentation in `HausdorffDTLoss` is the primary fix, and the `cldice.py` changes follow the same "document defaults" pattern from #8701. ## Checklist - [x] Docstring-only change (no logic modified) - [x] No new tests required - [x] DCO sign-off included --------- Signed-off-by: Shiran Yu <shiran.yu@bristol.ac.uk> Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> Co-authored-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent b2db04d commit 0b0a840

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

monai/losses/cldice.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ class SoftclDiceLoss(_Loss):
126126
def __init__(self, iter_: int = 3, smooth: float = 1.0) -> None:
127127
"""
128128
Args:
129-
iter_: Number of iterations for skeletonization
130-
smooth: Smoothing parameter
129+
iter_: Number of iterations for skeletonization. Defaults to 3.
130+
smooth: Smoothing parameter. Defaults to 1.0.
131131
"""
132132
super().__init__()
133133
self.iter = iter_
@@ -160,9 +160,9 @@ class SoftDiceclDiceLoss(_Loss):
160160
def __init__(self, iter_: int = 3, alpha: float = 0.5, smooth: float = 1.0) -> None:
161161
"""
162162
Args:
163-
iter_: Number of iterations for skeletonization
164-
smooth: Smoothing parameter
165-
alpha: Weighing factor for cldice
163+
iter_: Number of iterations for skeletonization. Defaults to 3.
164+
alpha: Weighing factor for cldice. Defaults to 0.5.
165+
smooth: Smoothing parameter. Defaults to 1.0.
166166
"""
167167
super().__init__()
168168
self.iter = iter_

monai/losses/hausdorff_loss.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ def __init__(
5454
) -> None:
5555
"""
5656
Args:
57+
alpha: the exponent to transform the distance when computing the loss. Defaults to 2.0.
5758
include_background: if False, channel index 0 (background category) is excluded from the calculation.
5859
if the non-background segmentations are small compared to the total image size they can get overwhelmed
5960
by the signal from the background so excluding it in such cases helps convergence.

0 commit comments

Comments
 (0)