Skip to content

docs: add embedding network examples and fix example headings - #2120

Merged
janfb merged 4 commits into
sbi-dev:mainfrom
Ashwini8686:docs/cnn-embedding-example
Nov 15, 2026
Merged

janfb merged 4 commits into
sbi-dev:mainfrom
Ashwini8686:docs/cnn-embedding-example

Conversation

@Ashwini8686

Copy link
Copy Markdown
Contributor

What does this PR do?

  • Add a runnable usage example to the FCEmbedding class docstring.
  • Demonstrate passing a batch through the network and displaying the output shape.
  • Retain the existing CNNEmbedding usage example.

Validation

  • Both examples produced the expected output shape: (32, 20).
  • Embedding network tests passed.
  • Ruff lint and formatting checks passed.
  • Git whitespace checks passed.

@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Embedding docstrings now include usage examples. Other docstrings use “Example” without a colon, and the contributing guide describes the heading and code-block format. No implementation behavior or public declarations changed.

Changes: Documentation examples

Layer / File(s) Summary
Embedding usage examples
sbi/neural_nets/embedding_nets/cnn.py, sbi/neural_nets/embedding_nets/fully_connected.py
The class docstrings show how to construct each embedding network, run inputs through it, and inspect the output shape.
Example heading updates
sbi/inference/posteriors/ensemble_posterior.py, sbi/inference/potentials/vector_field_adaptor.py, sbi/inference/trainers/*, sbi/utils/torchutils.py, sbi/utils/user_input_checks*.py
Docstrings change the example heading from “Example:” to “Example”.
Docstring example guidance
docs/contributing.md
The guide adds an example and describes the heading and code-block format.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Change: Other

Suggested reviewers: michaeldeistler

Merge Risk: Minimal · up to 70b61

This documentation-only change adds usage examples for the embedding networks and standardizes example headings. It does not change runtime behavior, so merging it carries minimal risk.

Pre-merge checks: Passed 4

Check name Status Explanation
Description check Passed The description states what the PR adds: a runnable FCEmbedding usage example that passes a batch through the network and prints the output shape. It keeps the existing CNNEmbedding example and report…
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.
Title check Passed The title names two changes: new embedding network examples and fixed example headings. The changeset adds an example to the FCEmbedding docstring and a contributing guide example. It also changes man…
Full details: Description check

Explanation

The description states what the PR adds: a runnable FCEmbedding usage example that passes a batch through the network and prints the output shape. It keeps the existing CNNEmbedding example and reports validation results. It follows the template's "What does this PR do?" and "Validation" content. It omits the template sections "Does this close any issues?" and the checklist, and it does not mention the heading-style changes across about 26 other docstrings and the contributing guide, which the objectives describe.

Full details: Title check

Explanation

The title names two changes: new embedding network examples and fixed example headings. The changeset adds an example to the FCEmbedding docstring and a contributing guide example. It also changes many 'Example:' headings to 'Example' across docstrings. The title matches the main changes, so it is related to the changeset. It omits the wider heading-format change, which the title does not need to cover.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b314f36d-e5ca-4b85-8eec-b8680666bc77
Commits

Reviewing files that changed from the base of the PR and between 3cd30b7 and 70b61eb.

Files selected for processing: 20

  • docs/contributing.md
  • sbi/inference/posteriors/ensemble_posterior.py
  • sbi/inference/potentials/vector_field_adaptor.py
  • sbi/inference/trainers/marginal/marginal_base.py
  • sbi/inference/trainers/nle/mnle.py
  • sbi/inference/trainers/nle/nle_a.py
  • sbi/inference/trainers/npe/mnpe.py
  • sbi/inference/trainers/npe/npe_a.py
  • sbi/inference/trainers/npe/npe_b.py
  • sbi/inference/trainers/npe/npe_c.py
  • sbi/inference/trainers/nre/bnre.py
  • sbi/inference/trainers/nre/nre_a.py
  • sbi/inference/trainers/nre/nre_b.py
  • sbi/inference/trainers/nre/nre_c.py
  • sbi/inference/trainers/vfpe/fmpe.py
  • sbi/inference/trainers/vfpe/npse.py
  • sbi/neural_nets/embedding_nets/fully_connected.py
  • sbi/utils/torchutils.py
  • sbi/utils/user_input_checks.py
  • sbi/utils/user_input_checks_utils.py
Files skipped from review as they are similar to previous changes: 1

  • sbi/neural_nets/embedding_nets/fully_connected.py

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

@janfb janfb self-assigned this Oct 31, 2026
@janfb

janfb commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

@Ashwini8686 thanks for the PR! I will review it after November 9.

Thanks, Jan

@manuelgloeckler
manuelgloeckler self-requested a review November 11, 2026 19:25
26 docstrings started their example with "Example:" over a dashed underline. That is neither the Google form ("Example:" with an indented block) nor the numpy form ("Example" with an underline), so napoleon passed the heading through as raw reST. The API reference then turned it into a page section that also took in the method documentation below it, for example on the NPE_C page.
Dropping the colon makes it a numpy-style section, which renders as a label inside the docstring, like the new CNNEmbedding and FCEmbedding examples. The contributing guide now shows this form.
@janfb

janfb commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

@Ashwini8686 thanks for adding the examples! Both run as shown, also with the recent changes to these embedding nets on main.

While checking how they render, I found that most other docstring examples in sbi use an Example: heading with a dashed underline. The API reference turns that into a page section that also takes in the method documentation below it. Your heading without the colon renders correctly, so I will add a commit on top that fixes the other docstrings the same way:

  • I merged main into the branch.
  • I removed the colon from the 26 other example headings.
  • I added the correct form to the docstring section of the contributing guide.

thanks, Jan

@janfb janfb changed the title docs: add embedding network usage examples+ docs: add embedding network examples and fix example headings Nov 15, 2026
@codecov

codecov Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.30%. Comparing base (799e324) to head (70b61eb).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2120   +/-   ##
=======================================
  Coverage   91.30%   91.30%           
=======================================
  Files         148      148           
  Lines       14970    14970           
=======================================
  Hits        13669    13669           
  Misses       1301     1301           
Flag Coverage Δ
fast 87.66% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
sbi/inference/posteriors/ensemble_posterior.py 95.48% <ø> (ø)
sbi/inference/potentials/vector_field_adaptor.py 88.83% <ø> (ø)
sbi/inference/trainers/marginal/marginal_base.py 94.61% <ø> (ø)
sbi/inference/trainers/nle/mnle.py 97.05% <ø> (ø)
sbi/inference/trainers/nle/nle_a.py 100.00% <ø> (ø)
sbi/inference/trainers/npe/mnpe.py 97.05% <ø> (ø)
sbi/inference/trainers/npe/npe_a.py 85.00% <ø> (ø)
sbi/inference/trainers/npe/npe_b.py 100.00% <ø> (ø)
sbi/inference/trainers/npe/npe_c.py 95.95% <ø> (ø)
sbi/inference/trainers/nre/bnre.py 97.29% <ø> (ø)
... and 10 more

@janfb
janfb merged commit f2dc994 into sbi-dev:main Nov 15, 2026
18 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