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

Fix repr for custom distributions, add optional constraint #2395

Merged
merged 6 commits into from Jan 17, 2024

Conversation

martinkim0
Copy link
Contributor

@martinkim0 martinkim0 commented Jan 17, 2024

Fixes #2392

NegativeBinomial and ZeroInflatedNegativeBinomial would raise an ambiguous ValueError when the following conditions were met:

  • scale not passed in and thus defaulted to None
  • log_prob called on a tensor not within support

This caused an error on this line when calling __repr__ since self.scale evaluated to None.

Another issue was that validate_args could not be True when any optional parameters are left as None. Fixed with an optional constraint wrapper.

@martinkim0 martinkim0 added the on-merge: backport to 1.1.x on-merge: backport to 1.1.x label Jan 17, 2024
Copy link

codecov bot commented Jan 17, 2024

Codecov Report

Attention: 6 lines in your changes are missing coverage. Please review.

Comparison is base (f0ef18d) 89.20% compared to head (f8699f7) 89.17%.

Files Patch % Lines
scvi/distributions/_negative_binomial.py 76.92% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2395      +/-   ##
==========================================
- Coverage   89.20%   89.17%   -0.03%     
==========================================
  Files         152      153       +1     
  Lines       12492    12518      +26     
==========================================
+ Hits        11143    11163      +20     
- Misses       1349     1355       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@martinkim0 martinkim0 merged commit 4a05665 into main Jan 17, 2024
7 checks passed
@martinkim0 martinkim0 deleted the torch-dist-repr branch January 17, 2024 22:48
meeseeksmachine pushed a commit to meeseeksmachine/scvi-tools that referenced this pull request Jan 17, 2024
martinkim0 added a commit that referenced this pull request Jan 17, 2024
…nstraint (#2398)

Co-authored-by: Martin Kim <46072231+martinkim0@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
on-merge: backport to 1.1.x on-merge: backport to 1.1.x
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PyTorch distribution __repr__ error with custom distributions
1 participant