Skip to content

Allow censoring Categorical distributions #7662

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

Merged
merged 1 commit into from
Jul 15, 2025

Conversation

ricardoV94
Copy link
Member

@ricardoV94 ricardoV94 commented Jan 28, 2025

Copy link

codecov bot commented Jan 28, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.92%. Comparing base (ae43026) to head (a48e8c6).
Report is 4 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #7662   +/-   ##
=======================================
  Coverage   92.92%   92.92%           
=======================================
  Files         107      107           
  Lines       18299    18308    +9     
=======================================
+ Hits        17004    17013    +9     
  Misses       1295     1295           
Files with missing lines Coverage Δ
pymc/distributions/discrete.py 99.42% <100.00%> (+0.01%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@jessegrabowski jessegrabowski left a comment

Choose a reason for hiding this comment

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

Add a test for the logcdf?

res = pt.switch(
def logp(value, p):
k = pt.shape(p)[-1]
value, safe_value_p = Categorical._safe_index_value_p(value, p)
Copy link
Member

Choose a reason for hiding this comment

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

I don't love making _safe_index_value_p a method. What's the conceptual advantage vs just being a function?

Copy link
Member Author

Choose a reason for hiding this comment

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

doesn't clutter the namespace, that's the only difference

@ricardoV94
Copy link
Member Author

Add a test for the logcdf?

I did... it's in the Censored. Since there is no Categorical scipy distribution, I would just be comparing two implementations written by me?

@ricardoV94
Copy link
Member Author

Ah, I tested the logp... hmm okay okay

@ricardoV94 ricardoV94 marked this pull request as draft January 28, 2025 15:41
@ricardoV94 ricardoV94 marked this pull request as ready for review January 30, 2025 08:46
lambda value, p: categorical_logpdf(value, p),
)

def test_categorical_logp_batch_dims(self):
check_selfconsistency_discrete_logcdf(
Copy link
Member Author

Choose a reason for hiding this comment

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

This tests the logcdf

@ricardoV94 ricardoV94 merged commit dea3aef into pymc-devs:main Jul 15, 2025
25 checks passed
@ricardoV94 ricardoV94 deleted the censored_cat branch July 15, 2025 13:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants