Skip to content

fix: improve plot summary arguments#1861

Open
janfb wants to merge 3 commits intomainfrom
fix-plot-summary-1733
Open

fix: improve plot summary arguments#1861
janfb wants to merge 3 commits intomainfrom
fix-plot-summary-1733

Conversation

@janfb
Copy link
Copy Markdown
Contributor

@janfb janfb commented Apr 26, 2026

continuation of @Abraham-y work on #1814

  • refactoring and small fixes, simplifications, leaner tests
  • rename inference to trainer to match our recent terminology; add deprecation warnings.

fixes #1733

@janfb janfb changed the title Fix plot summary 1733 fix: improve plot summary arguments 1733 Apr 26, 2026
@janfb janfb changed the title fix: improve plot summary arguments 1733 fix: improve plot summary arguments Apr 26, 2026
@janfb janfb requested a review from dgedon April 26, 2026 15:48
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 26, 2026

Codecov Report

❌ Patch coverage is 90.90909% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.86%. Comparing base (cd69050) to head (919b74a).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
sbi/analysis/tensorboard_output.py 90.90% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1861      +/-   ##
==========================================
+ Coverage   87.83%   87.86%   +0.02%     
==========================================
  Files         140      140              
  Lines       12958    12989      +31     
==========================================
+ Hits        11382    11413      +31     
  Misses       1576     1576              
Flag Coverage Δ
fast 82.71% <90.90%> (?)

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

Files with missing lines Coverage Δ
sbi/analysis/tensorboard_output.py 89.47% <90.90%> (+3.93%) ⬆️

Copy link
Copy Markdown
Collaborator

@dgedon dgedon left a comment

Choose a reason for hiding this comment

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

The input argument structure with overlay is not yet clean or needs some clarification at least. Also, is there supposed to be a how-to-guide attached to it?

plot_kwargs: Optional[Dict[str, Any]] = None,
verbose: bool = True,
tensorboard_scalar_limit: int = 10_000,
inference: Union[NeuralInference, Path, None] = None,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Potentially add a comment about deprecation of this variable in the future

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

it's marked as deprecated in the docstring below.

Comment on lines +133 to +138
for name, vals in (("colors", colors), ("labels", labels), ("ylabel", ylabel)):
if vals is not None and len(vals) != len(tags):
raise ValueError(
f"`{name}` must have the same length as `tags` "
f"(got {len(vals)} vs {len(tags)})."
)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Potentially first collect which vals are of the wrong length and then give a joint error about all mis-lengthed vals at once.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Isn't there the same condition on axes if overlay=False?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

on collecting vals lenghts first, I think it's fine to just do it on each iteration in the loop, it's only three times.

The other point is fixed with the recent commit.

Comment on lines +52 to +53
overlay: if True, plots all ``tags`` on a single axes (useful for
comparing training vs validation loss). Otherwise one subplot per tag.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

What happens if overlay=True and we have multiple axes as arguments? It seems that it ignores multple axes then from the code. Should be specified

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

good catch, there are multiple combinations of overlay and passing axes that will fail here. I will push a fix.

Copy link
Copy Markdown
Contributor Author

@janfb janfb left a comment

Choose a reason for hiding this comment

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

Thanks for the review @dgedon ! valid points, I will push a fix in a moment.

plot_kwargs: Optional[Dict[str, Any]] = None,
verbose: bool = True,
tensorboard_scalar_limit: int = 10_000,
inference: Union[NeuralInference, Path, None] = None,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

it's marked as deprecated in the docstring below.

Comment on lines +52 to +53
overlay: if True, plots all ``tags`` on a single axes (useful for
comparing training vs validation loss). Otherwise one subplot per tag.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

good catch, there are multiple combinations of overlay and passing axes that will fail here. I will push a fix.

Comment on lines +133 to +138
for name, vals in (("colors", colors), ("labels", labels), ("ylabel", ylabel)):
if vals is not None and len(vals) != len(tags):
raise ValueError(
f"`{name}` must have the same length as `tags` "
f"(got {len(vals)} vs {len(tags)})."
)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

on collecting vals lenghts first, I think it's fine to just do it on each iteration in the loop, it's only three times.

The other point is fixed with the recent commit.

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.

improve plot_summary function

3 participants