fix(mmm): allow constant tensors in adstock sample_prior (fixes #1749)#2304
fix(mmm): allow constant tensors in adstock sample_prior (fixes #1749)#2304shivamlalakiya wants to merge 4 commits intopymc-labs:mainfrom
Conversation
PR SummaryLow Risk Overview Adds regression tests for issue #1749 verifying Written by Cursor Bugbot for commit c940cf4. This will update automatically on new commits. Configure here. |
|
There's not really any prior being sampled... |
|
@ricardoV94 You're right — no actual sampling is happening here. The goal was to unblock the plot curve workflow from #1749 which needs an InferenceData to proceed. Would you prefer a different approach? For example, wrapping constants in pm.DiracDelta, emitting a warnings.warn to be explicit, or something else entirely? Happy to rework it based on your guidance. |
|
I was being just pedantic. It makes sense to support |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2304 +/- ##
===========================================
- Coverage 93.05% 23.31% -69.74%
===========================================
Files 78 78
Lines 12230 12235 +5
===========================================
- Hits 11381 2853 -8528
- Misses 849 9382 +8533 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Description
Fixes #1749
Previously,
sample_priorwould fail if an adstock transformation (e.g.,GeometricAdstock) was initialized with constant tensors instead of PyMC distributions, aspm.sample_prior_predictiverequires free random variables.This PR adds a fallback mechanism: if no free random variables are detected in the model, it evaluates the constant tensors deterministically and returns a valid
InferenceDataobject.Changes
sample_priorintransformers.pyto handleValueErrorfromsample_prior_predictive.tests/mmm/test_issue_1749.pyto verify constant inputs work.Related Issue
Checklist
pre-commit.ci autofixto auto-fix.📚 Documentation preview 📚: https://pymc-marketing--2304.org.readthedocs.build/en/2304/