Skip to content

Comments

fix(losses): add missing docstring entries for default parameters#8755

Open
yushiran wants to merge 1 commit intoProject-MONAI:devfrom
yushiran:fix-losses-docstrings
Open

fix(losses): add missing docstring entries for default parameters#8755
yushiran wants to merge 1 commit intoProject-MONAI:devfrom
yushiran:fix-losses-docstrings

Conversation

@yushiran
Copy link

@yushiran yushiran commented Feb 23, 2026

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

  • Docstring-only change (no logic modified)
  • No new tests required
  • DCO sign-off included

- Add missing `alpha` parameter (default 2.0) to HausdorffDTLoss.__init__ docstring
- Add "Defaults to X" notes to SoftclDiceLoss and SoftDiceclDiceLoss docstrings
  for `iter_`, `smooth`, and `alpha` parameters

Signed-off-by: Shiran Yu <shiran.yu@bristol.ac.uk>
Copilot AI review requested due to automatic review settings February 23, 2026 19:42
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 23, 2026

📝 Walkthrough

Walkthrough

Docstring updates across two loss module files. SoftclDiceLoss and SoftDiceclDiceLoss docstrings now explicitly state default parameter values (iter_: 3, smooth: 1.0; iter_: 3, alpha: 0.5, smooth: 1.0). HausdorffDTLoss docstring documents the alpha parameter. No changes to function signatures, logic, or behavior.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed Title clearly and concisely describes the main change: adding missing docstring entries for default parameters in loss modules.
Description check ✅ Passed Description covers all changes with specifics, references pattern from prior PR, and completes required checklist items appropriately.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds missing and incomplete default parameter documentation to loss function docstrings, following the convention established in PR #8701. The changes are purely documentary with no code logic modifications.

Changes:

  • Added missing alpha parameter documentation to HausdorffDTLoss.__init__ in hausdorff_loss.py
  • Updated parameter descriptions in cldice.py to include default values for better API documentation

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
monai/losses/hausdorff_loss.py Added missing docstring entry for alpha parameter (default 2.0) that was present in function signature but undocumented
monai/losses/cldice.py Added "Defaults to X." to parameter descriptions for iter_, smooth, and alpha in SoftclDiceLoss and SoftDiceclDiceLoss classes

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@monai/losses/cldice.py`:
- Around line 163-165: The docstring parameter list is out of order: the
function/class signature declares alpha before smooth, but the docstring lists
smooth first; update the docstring in monai/losses/cldice.py to list alpha
before smooth (and ensure the descriptions match the signature order for
parameters alpha and smooth, e.g., alpha: ... then smooth: ...), referencing the
initializer/function name (CLDice or its __init__/forward where the signature
appears) so the docstring aligns with the actual parameter order.

ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting

📥 Commits

Reviewing files that changed from the base of the PR and between 2147c11 and ce54c94.

📒 Files selected for processing (2)
  • monai/losses/cldice.py
  • monai/losses/hausdorff_loss.py

Comment on lines +163 to +165
iter_: Number of iterations for skeletonization. Defaults to 3.
smooth: Smoothing parameter. Defaults to 1.0.
alpha: Weighing factor for cldice. Defaults to 0.5.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Docstring parameter order doesn't match the signature.

The signature declares alpha before smooth, but the docstring lists smooth first. Swap to keep them aligned.

📝 Proposed fix
         Args:
             iter_: Number of iterations for skeletonization. Defaults to 3.
-            smooth: Smoothing parameter. Defaults to 1.0.
             alpha: Weighing factor for cldice. Defaults to 0.5.
+            smooth: Smoothing parameter. Defaults to 1.0.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
iter_: Number of iterations for skeletonization. Defaults to 3.
smooth: Smoothing parameter. Defaults to 1.0.
alpha: Weighing factor for cldice. Defaults to 0.5.
iter_: Number of iterations for skeletonization. Defaults to 3.
alpha: Weighing factor for cldice. Defaults to 0.5.
smooth: Smoothing parameter. Defaults to 1.0.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@monai/losses/cldice.py` around lines 163 - 165, The docstring parameter list
is out of order: the function/class signature declares alpha before smooth, but
the docstring lists smooth first; update the docstring in monai/losses/cldice.py
to list alpha before smooth (and ensure the descriptions match the signature
order for parameters alpha and smooth, e.g., alpha: ... then smooth: ...),
referencing the initializer/function name (CLDice or its __init__/forward where
the signature appears) so the docstring aligns with the actual parameter order.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant