Skip to content

docs: add missing docstrings, Raises sections, and fix Args in networ…#8850

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

docs: add missing docstrings, Raises sections, and fix Args in networ…#8850
chhayankjain wants to merge 1 commit into
Project-MONAI:devfrom
chhayankjain:docs/fix-blocks-docstrings

Conversation

@chhayankjain
Copy link
Copy Markdown
Contributor

Description

Fix several docstring issues across network blocks in monai/networks/blocks/:

  • localnet_block.py: add class and __init__ docstrings with Args and Raises sections to ResidualBlock and
    LocalNetResidualBlock; fix broken indentation and incorrect parameter name (kernel_initializerinitializer) in
    LocalNetFeatureExtractorBlock
  • selfattention.py: add Raises section to SABlock.__init__
  • crossattention.py: add Raises section to CrossAttentionBlock.__init__
  • patchembedding.py: add Raises section to PatchEmbeddingBlock.__init__
  • upsample.py: add Raises section to UpSample.__init__
  • downsample.py: add Raises sections to DownSample.__init__ and SubpixelDownsample.__init__

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: 1f410674-eb85-423a-8f89-cbbf606df12a

📥 Commits

Reviewing files that changed from the base of the PR and between a1bf6f1 and a66d670.

📒 Files selected for processing (6)
  • monai/networks/blocks/crossattention.py
  • monai/networks/blocks/downsample.py
  • monai/networks/blocks/localnet_block.py
  • monai/networks/blocks/patchembedding.py
  • monai/networks/blocks/selfattention.py
  • monai/networks/blocks/upsample.py
✅ Files skipped from review due to trivial changes (5)
  • monai/networks/blocks/patchembedding.py
  • monai/networks/blocks/selfattention.py
  • monai/networks/blocks/crossattention.py
  • monai/networks/blocks/downsample.py
  • monai/networks/blocks/upsample.py

📝 Walkthrough

Walkthrough

This PR updates docstrings across multiple MONAI network block classes, adding explicit Raises: sections that document ValueError conditions for constructor parameters (crossattention, selfattention, patchembedding, downsample, upsample, localnet_block). Additionally, LocalNetFeatureExtractorBlock.__init__ renames a parameter from kernel_initializer to initializer (default "kaiming_uniform"). No runtime logic changes beyond the parameter rename.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed Title is truncated ('networ…') and partially relates to changes—mentions docstrings, Raises sections, and Args fixes across network blocks.
Description check ✅ Passed Description covers all modified files with specific changes and notes no functional impact. Matches template with Types of changes section.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% 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 force-pushed the docs/fix-blocks-docstrings branch from d9cfd74 to a1bf6f1 Compare May 12, 2026 09:20
@chhayankjain chhayankjain marked this pull request as ready for review May 13, 2026 00:25
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/networks/blocks/downsample.py`:
- Around line 133-134: Update the docstring ValueError clause for the downsample
block to precisely match the implemented check: state that the error is raised
only when mode is "maxpool" or "avgpool", pre_conv == "default", out_channels !=
in_channels, and in_channels is not provided; locate the exception description
in the downsample module's docstring (the section documenting raised exceptions
for parameters mode/pre_conv/in_channels/out_channels) and change the sentence
to include the additional condition out_channels != in_channels so the docs
mirror the actual code path.

In `@monai/networks/blocks/localnet_block.py`:
- Around line 302-303: The docstring for the initializer parameter in
LocalNetBlock (parameter name: initializer) claims the default is
"kaiming_uniform" but the implementation calls nn.init.kaiming_normal_; make
them consistent by either changing the docstring default to "kaiming_normal"
(and document accepted values accordingly) or changing the implementation to use
nn.init.kaiming_uniform_ when initializer=="kaiming_uniform"; update the
initializer handling logic in the LocalNetBlock __init__ (or the function that
performs weight initialization) and the docstring so the parameter name, allowed
string values, and applied nn.init.* call match exactly.
🪄 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: 07796a91-596c-4fbc-97ad-52cf3abecb3d

📥 Commits

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

📒 Files selected for processing (6)
  • monai/networks/blocks/crossattention.py
  • monai/networks/blocks/downsample.py
  • monai/networks/blocks/localnet_block.py
  • monai/networks/blocks/patchembedding.py
  • monai/networks/blocks/selfattention.py
  • monai/networks/blocks/upsample.py

Comment thread monai/networks/blocks/downsample.py Outdated
Comment thread monai/networks/blocks/localnet_block.py Outdated
…ks/blocks

Signed-off-by: chhayankjain <chhayank44@gmail.com>
@chhayankjain chhayankjain force-pushed the docs/fix-blocks-docstrings branch from a1bf6f1 to a66d670 Compare May 13, 2026 00:38
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