Skip to content

Unify vector field tutorials, fix legend in pairplot - #1830

Merged
janfb merged 7 commits into
mainfrom
unify-ve-tutorials
Apr 2, 2026
Merged

janfb merged 7 commits into
mainfrom
unify-ve-tutorials

Conversation

@janfb

@janfb janfb commented Apr 2, 2026

Copy link
Copy Markdown
Contributor
  • unify FMPE and NPSE tutorials
  • add how-to-guide
  • fix bug in pairplot legend handling (brittle, need to discuss whether to include or refer to future PR).

@janfb
janfb requested a review from manuelgloeckler April 2, 2026 09:05
@janfb janfb mentioned this pull request Apr 2, 2026
3 tasks done
@codecov

codecov Bot commented Apr 2, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 81.81818% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.99%. Comparing base (1797e77) to head (e36fe00).
⚠️ Report is 2 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
sbi/analysis/plot.py 81.81% 8 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1830      +/-   ##
==========================================
- Coverage   88.01%   87.99%   -0.03%     
==========================================
  Files         140      140              
  Lines       12791    12831      +40     
==========================================
+ Hits        11258    11290      +32     
- Misses       1533     1541       +8     
Flag Coverage Δ
fast 82.76% <81.81%> (?)

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

Files with missing lines Coverage Δ
sbi/inference/trainers/vfpe/fmpe.py 91.30% <ø> (ø)
sbi/analysis/plot.py 77.18% <81.81%> (+0.13%) ⬆️

@manuelgloeckler manuelgloeckler left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks great! Love the new tutorial.

Just a few typos to fix, and some optional suggestions.

@manuelgloeckler

Copy link
Copy Markdown
Contributor

Actually #1758 also adds an 24_abstraction_levels.ipynb how to guide so maybe change the number prefix.

@janfb
janfb merged commit b27c576 into main Apr 2, 2026
9 checks passed
@janfb
janfb deleted the unify-ve-tutorials branch April 2, 2026 18:39
dgedon added a commit to dgedon/sbi that referenced this pull request Nov 10, 2026
With `fig_kwargs=dict(legend=True)` and an empty lower triangle, pairplot
puts the legend into the bottom-left cell. That cell got its x-label (e.g.
"dim 1") before it was turned off, and `_place_legend_in_empty_cell` (sbi-dev#1830)
turned it back on, hiding only its ticks and spines. Clear the labels too.

Only figures with a legend in the bottom-left cell change. The old
implementation never labels that cell, so it draws the same as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
dgedon added a commit that referenced this pull request Nov 23, 2026
…l under the legend (#2160)

* fix(plot): warn visibly before the old pairplot path is removed in v0.29

Passing old-style keyword arguments to `pairplot` or `marginal_plot` sends
the call to the pre-v0.23 implementation. Since #1631 the
DeprecationWarning pointed into sbi, so Python's default filters hid it. It
named no removal version, and the old implementation silently dropped the
newer arguments passed with it.

Raise a FutureWarning at the caller's line instead. It names the keys,
v0.29.0 and where the keys go, and lists the newer arguments that the call
ignores. `pairplot_dep`, `marginal_plot_dep` and `PlotOffDiagOptions` warn
too. The old implementation itself is unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs: pass tutorial 19's pairplot options in fig_kwargs

Cells 16, 19, 26 and 28 of advanced tutorial 19 passed `legend`,
`samples_labels`, `points_labels`, `points_colors` and `points_offdiag`
directly to `pairplot`. That sent them to the old implementation, which
ignored their `diag_kwargs` and `upper_kwargs`. Pass these options in
`fig_kwargs` instead, so that the requested contour levels and KDE bins
are drawn.

Also drop the deprecated `PlotOffDiagOptions` from tutorial 17's list of
option classes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs: rerun tutorial 19

Rerun advanced tutorial 19 so that its stored figures show what the cells
ask for: the 95 % contour and 100 KDE bins in the MAP figure, and the
99 % contours in the i.i.d. and guidance figures. Outputs are stored as
in the other docs notebooks: plots and printed output only, with
consecutive prints merged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(plot): don't draw the legend cell's x-label in pairplot

With `fig_kwargs=dict(legend=True)` and an empty lower triangle, pairplot
puts the legend into the bottom-left cell. That cell got its x-label (e.g.
"dim 1") before it was turned off, and `_place_legend_in_empty_cell` (#1830)
turned it back on, hiding only its ticks and spines. Clear the labels too.

Only figures with a legend in the bottom-left cell change. The old
implementation never labels that cell, so it draws the same as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs: rerun tutorials 17 and 19 with the legend fix

Their legend figures no longer show the stray x-label under the legend.
Outputs are stored as in the other docs notebooks: plots and printed
output only, consecutive prints merged, and no execution timestamps. This
also drops the timestamps that the previous rerun of tutorial 19 stored.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(plot): name a diag style that the old pairplot path doesn't draw

The old implementation draws only "hist" and "kde" on the diagonal, and
"scatter" only when the upper triangle is scatter too. With an old-style
keyword argument, `pairplot(s, legend=True, diag="bar")` and
`marginal_plot(s, legend=True, diag="scatter")` drew an empty diagonal,
and the warning did not say so. Name `diag` as ignored in these cases.

`_warn_deprecated_kwargs` now also checks the `LabeledSamples` names
itself, so `pairplot` and `marginal_plot` no longer repeat that check.

The removal of the old path in v0.29 is tracked in #2218.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(plot): warn about offdiag at the caller and name v0.29

`pairplot`'s `offdiag` argument has warned since v0.23.0 with a
`UserWarning` that points into `sbi/analysis/plot.py` and names no
removal version. Raise a `FutureWarning` at the caller's line instead,
like the other deprecated `pairplot` arguments, and say that it will be
removed in v0.29.0. It maps only to `upper`, so the message no longer
suggests `lower`.

The removal is tracked in #2218.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(plot): name diag as ignored exactly when the old diagonal doesn't draw it

Per sample, the old diagonal draws "hist" or "kde" if asked, and
otherwise draws scatter lines if that sample's upper style is "scatter",
and nothing if not. The warning approximated this. It named `diag` for
`diag=["scatter", "hist"], upper=["scatter", "hist"]`, which the old
path draws, and stayed silent for `diag=None, upper="scatter"`, where the
old path draws scatter lines nobody asked for. Pair each sample's `diag`
with its `upper` and apply the old rule.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(plot): compare only one diag and upper style per sample set

The old implementation uses one style per sample set and ignores extra
list entries. The warning compared all entries, so for one sample set,
`pairplot(s, legend=True, diag="scatter", upper=["scatter", "hist"])`
named `diag` although the old diagonal draws the scatter lines. Count
the sample sets as the old implementation does and compare only that
many pairs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
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