Skip to content

docs: fix docstring parameter name, add missing Args and Raises secti…#8849

Merged
ericspod merged 2 commits into
Project-MONAI:devfrom
chhayankjain:docs/fix-losses-docstrings
May 18, 2026
Merged

docs: fix docstring parameter name, add missing Args and Raises secti…#8849
ericspod merged 2 commits into
Project-MONAI:devfrom
chhayankjain:docs/fix-losses-docstrings

Conversation

@chhayankjain
Copy link
Copy Markdown
Contributor

Description

Fix several docstring issues across loss functions in monai/losses/:

  • barlow_twins.py: fix parameter name typo (lamblambd) in Args section
  • nacl_loss.py: add missing kernel_ops arg, update distance_type/alpha with defaults, add Raises section
  • multi_scale.py: add missing reduction arg, add Raises section
  • ds_loss.py: add forward docstring with Args and Raises section
  • perceptual.py: add Raises section to class docstring

No functional changes.

Types of changes

  • Non-breaking change (fix or new feature that would not break existing functionality).

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 12, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c51b9e20-467c-431e-b65d-d7d608e1418d

📥 Commits

Reviewing files that changed from the base of the PR and between e90190e and 47d58a3.

📒 Files selected for processing (5)
  • monai/losses/barlow_twins.py
  • monai/losses/ds_loss.py
  • monai/losses/multi_scale.py
  • monai/losses/nacl_loss.py
  • monai/losses/perceptual.py
✅ Files skipped from review due to trivial changes (2)
  • monai/losses/perceptual.py
  • monai/losses/nacl_loss.py
🚧 Files skipped from review as they are similar to previous changes (3)
  • monai/losses/multi_scale.py
  • monai/losses/barlow_twins.py
  • monai/losses/ds_loss.py

📝 Walkthrough

Walkthrough

This PR updates docstrings in five MONAI loss modules: monai/losses/barlow_twins.py, ds_loss.py, multi_scale.py, nacl_loss.py, and perceptual.py. Changes correct a parameter name in BarlowTwinsLoss and expand docstrings to document arguments, supported values, and raised exceptions (including DeepSupervisionLoss.forward, MultiScaleLoss.init, NACLLoss.init, and PerceptualLoss). No runtime behavior, control flow, or public API signatures were changed.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'docs: fix docstring parameter name, add missing Args and Raises secti…' directly summarizes the main changes—fixing docstring issues and adding missing documentation sections.
Description check ✅ Passed The description covers all required sections: it lists specific files and docstring fixes, notes no functional changes, and correctly marks 'Non-breaking change' in Types of changes.
Docstring Coverage ✅ Passed Docstring coverage is 83.33% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@chhayankjain chhayankjain marked this pull request as ready for review May 12, 2026 09:19
Copy link
Copy Markdown
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: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@monai/losses/ds_loss.py`:
- Around line 72-79: The forward method's docstring in monai/losses/ds_loss.py
is missing a Returns section; update the docstring for the forward function
(method name: forward, class: DSLoss/DeeplySupervisedLoss if present) to include
a Returns section that states it returns a torch.Tensor (describe shape/meaning,
e.g., scalar loss tensor or per-sample loss tensor) and any dtype/device
expectations, and keep the existing Args/Raises content unchanged so readers
know what the function returns.

In `@monai/losses/multi_scale.py`:
- Around line 64-66: The docstring for the function in
monai/losses/multi_scale.py documents a ValueError only for invalid ``kernel``
but omits that invalid ``reduction`` values also raise ValueError; update the
Raises section to list ValueError for unsupported ``reduction`` values (e.g.,
describe when ``reduction`` is not one of the accepted options) so users know
both error conditions raised by the function that uses the ``reduction``
parameter.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: e8f36a6b-375a-47a2-9839-f7a39b7703c1

📥 Commits

Reviewing files that changed from the base of the PR and between 586dea1 and 151f509.

📒 Files selected for processing (5)
  • monai/losses/barlow_twins.py
  • monai/losses/ds_loss.py
  • monai/losses/multi_scale.py
  • monai/losses/nacl_loss.py
  • monai/losses/perceptual.py

Comment thread monai/losses/ds_loss.py
Comment thread monai/losses/multi_scale.py
@chhayankjain chhayankjain force-pushed the docs/fix-losses-docstrings branch 2 times, most recently from 23266b7 to e90190e Compare May 13, 2026 00:33
@chhayankjain
Copy link
Copy Markdown
Contributor Author

@virginiafdez @KumoLiu @ericspod @Nic-Ma
Hello Team,
This PR is ready from my end. Could you please review it and let me know if everything looks good to you? Thank you!

Copy link
Copy Markdown
Member

@ericspod ericspod left a comment

Choose a reason for hiding this comment

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

Hi @chhayankjain looks good to me, thanks!

@ericspod ericspod enabled auto-merge (squash) May 18, 2026 13:50
…ons in losses

Signed-off-by: chhayankjain <chhayank44@gmail.com>
auto-merge was automatically disabled May 18, 2026 16:03

Head branch was pushed to by a user without write access

@chhayankjain chhayankjain force-pushed the docs/fix-losses-docstrings branch from c2115f7 to 47d58a3 Compare May 18, 2026 16:03
@ericspod ericspod merged commit 063081f into Project-MONAI:dev May 18, 2026
24 checks passed
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.

2 participants