Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Omit nans in plotting functions, cast to numpy before plotting, fix axes indexing for 1D #1185

Merged
merged 13 commits into from
Jun 26, 2024

Conversation

Matthijspals
Copy link
Contributor

@Matthijspals Matthijspals commented Jun 24, 2024

What does this implement/fix? Explain your changes

  • gives a warning if NaNs or Infs are detected, removes the entryu
  • tries to cast data to numpy arrays, if not already numpy (or torch)
  • checks if data is 1D and we should not index matplotlib axes.

Does this close any currently open issues?

Fixes #1184 #1059

Any relevant code examples, logs, error output, etc?

Any other comments?

Checklist

Put an x in the boxes that apply. You can also fill these out after creating
the PR. If you're unsure about any of them, don't hesitate to ask. We're here to
help! This is simply a reminder of what we are going to look for before merging
your code.

  • I have read and understood the contribution
    guidelines
  • I agree with re-licensing my contribution from AGPLv3 to Apache-2.0.
  • I have commented my code, particularly in hard-to-understand areas
  • I have added tests that prove my fix is effective or that my feature works
  • I have reported how long the new tests run and potentially marked them
    with pytest.mark.slow.
  • New and existing unit tests pass locally with my changes
  • I performed linting and formatting as described in the contribution
    guidelines
  • I rebased on main (or there are no conflicts with main)
  • For reviewer: The continuous deployment (CD) workflow are passing.

@manuelgloeckler manuelgloeckler self-requested a review June 24, 2024 14:28
Copy link

codecov bot commented Jun 24, 2024

Codecov Report

Attention: Patch coverage is 72.00000% with 14 lines in your changes missing coverage. Please review.

Project coverage is 75.78%. Comparing base (6f61662) to head (e009fef).

❗ There is a different number of reports uploaded between BASE (6f61662) and HEAD (e009fef). Click for more details.

HEAD has 1 upload more than BASE | Flag | BASE (6f61662) | HEAD (e009fef) | |------|------|------| |unittests|1|2|
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1185      +/-   ##
==========================================
- Coverage   82.13%   75.78%   -6.36%     
==========================================
  Files          93       93              
  Lines        7458     7476      +18     
==========================================
- Hits         6126     5666     -460     
- Misses       1332     1810     +478     
Flag Coverage Δ
unittests 75.78% <72.00%> (-6.36%) ⬇️

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

Files Coverage Δ
sbi/analysis/plot.py 66.15% <72.00%> (+24.36%) ⬆️

... and 23 files with indirect coverage changes

Copy link
Contributor

@manuelgloeckler manuelgloeckler left a comment

Choose a reason for hiding this comment

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

Great work :) Thanks for fixing these issues. I found a few typos in the notebook.

You can also add the new notebook to the website/documentation i.e. add it (here)[https://github.com/sbi-dev/sbi/blob/main/docs/mkdocs.yml] to e.g. Analysis.

Additionally, CodeCov does complain that there are no unit tests. As this is purely for visualization (and was like this before), this is fine. But it might also be good to add a few simple tests to avoid errors like this in the future.

  • Run plotting one 1d and nd, and assert if an error occurs.
  • Run plotting on a list of samples, assert if error occurs
  • Run plotting on nan and inf samples, assert if error occurs

tutorials/19_plotting_functionality.ipynb Outdated Show resolved Hide resolved
tutorials/19_plotting_functionality.ipynb Outdated Show resolved Hide resolved
tutorials/19_plotting_functionality.ipynb Outdated Show resolved Hide resolved
tutorials/19_plotting_functionality.ipynb Outdated Show resolved Hide resolved
tutorials/19_plotting_functionality.ipynb Outdated Show resolved Hide resolved
tutorials/19_plotting_functionality.ipynb Outdated Show resolved Hide resolved
sbi/analysis/plot.py Outdated Show resolved Hide resolved
sbi/analysis/plot.py Show resolved Hide resolved
sbi/analysis/plot.py Show resolved Hide resolved
@Matthijspals
Copy link
Contributor Author

I added tests. Not sure about what counts as a slow test. on my Mac, pytest tests/plot_test.py take 14.18s

Copy link
Contributor

@manuelgloeckler manuelgloeckler left a comment

Choose a reason for hiding this comment

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

Looks good. Great work.

Tests are sufficiently fast.

I tried to build the docs to check if the new notebook is rendered correctly on the website. But for some reason building the docs locally does not work anymore (i.e. building fails as mkdocs does not find any source). It does not work also on main, @janfb do you have any idea why?

@janfb
Copy link
Contributor

janfb commented Jun 26, 2024

Yes, please see this comment: #1147 (comment)

Please note that we should only build the website locally (mkdocs serve) and not deploy it yet, because we want the docs and API refs on the website to be in sync with the latest release (Dec 2023).

@manuelgloeckler manuelgloeckler merged commit 1db7aaf into sbi-dev:main Jun 26, 2024
6 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.

pairplot with 1 dimensional tensor returns an error
3 participants