Skip to content

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

Open
chhayankjain wants to merge 1 commit into
Project-MONAI:devfrom
chhayankjain:docs/fix-losses-docstrings
Open

docs: fix docstring parameter name, add missing Args and Raises secti…#8849
chhayankjain wants to merge 1 commit 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: 879bec44-977e-4226-b314-b4a87a3ef642

📥 Commits

Reviewing files that changed from the base of the PR and between 23266b7 and e90190e.

📒 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 (5)
  • monai/losses/barlow_twins.py
  • monai/losses/multi_scale.py
  • monai/losses/nacl_loss.py
  • monai/losses/ds_loss.py
  • monai/losses/perceptual.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 Title accurately summarizes the main changes: fixing docstring parameter name and adding missing Args and Raises sections across loss files.
Description check ✅ Passed Description covers all file changes with specific details about docstring fixes. Template compliance is good with description and types of changes completed.
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 from 151f509 to 23266b7 Compare May 12, 2026 09:21
…ons in losses

Signed-off-by: chhayankjain <chhayank44@gmail.com>
@chhayankjain chhayankjain force-pushed the docs/fix-losses-docstrings branch from 23266b7 to e90190e Compare May 13, 2026 00:33
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