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

Return InferenceData when there are no variables sampled and extend=True #7509

Merged
merged 1 commit into from
Sep 18, 2024

Conversation

OriolAbril
Copy link
Member

@OriolAbril OriolAbril commented Sep 18, 2024

Description

When there are no variables to sample and extend_inferencedata=True the returned object
is trace at that point in the code which in the common case of providing an InferenceData
to sample_posterior_predictive is only its posterior group. Consequently:

with model:
    idata = pm.sample_posterior_predictive(idata, var_names=[], extend_inferencedata=True)
# now `idata` is the xarray Dataset corresponding to the posterior group

This PR changes the behaviour so idata above continues to be the provided idata and adds
a test for it.

Related Issue

I considered it was easier to open the PR directly instead of first issue then PR.

Checklist

Type of change

  • New feature / enhancement
  • Bug fix
  • Documentation
  • Maintenance
  • Other (please specify):

📚 Documentation preview 📚: https://pymc--7509.org.readthedocs.build/en/7509/

Copy link

codecov bot commented Sep 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.43%. Comparing base (4300be1) to head (e216e02).
Report is 98 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #7509   +/-   ##
=======================================
  Coverage   92.43%   92.43%           
=======================================
  Files         103      103           
  Lines       17109    17109           
=======================================
+ Hits        15814    15815    +1     
+ Misses       1295     1294    -1     
Files with missing lines Coverage Δ
pymc/sampling/forward.py 96.15% <100.00%> (+0.42%) ⬆️

@ricardoV94 ricardoV94 added maintenance trace-backend Traces and ArviZ stuff labels Sep 18, 2024
@ricardoV94 ricardoV94 merged commit b9fbfed into pymc-devs:main Sep 18, 2024
23 checks passed
@OriolAbril OriolAbril deleted the sample_pp_empty_output branch September 18, 2024 14:32
@ricardoV94 ricardoV94 changed the title fix returned object when no vars to sample and extend=True Return InferenceData when there are no variables sampled and extend=True Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance trace-backend Traces and ArviZ stuff
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants