-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Make do interventions shared variables by default #7596
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #7596 +/- ##
=======================================
Coverage 92.67% 92.67%
=======================================
Files 107 107
Lines 18313 18317 +4
=======================================
+ Hits 16971 16975 +4
Misses 1342 1342
|
d14cf22
to
840c21f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might not be strictly required for this issue, but would solve one of my recurring concerns... but could potentially add a test for something like
with pm.Model() as model:
a = pm.Normal("a")
b = pm.Deterministic("b", a*2)
c = pm.Normal("c", b/2)
then intervene on a
with pm.do
, resample with pm.sample_posterior_predictive
, and check that the values of c
have changed. Just an idea, might be not fully formed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@drbenvincent I am a bit conflicted. I do want to test that as a user, but not as part of the codebase as it's covering something that's orthogonal to it: #6876 This PR is not a solution to that problem, but sidesteps it in this specific case. Even if we didn't have that problem we would still want this PR so you can use |
Since I'm conflicted I'll add it @drbenvincent . It does test the behavior we want in the end |
Sure - totally fine for you to ignore my suggestion. There are a bunch of PR's which are all closely related and I don't have enough knowledge to know which exact PR would be relevant for a user-facing test like this. Feel free to ignore. Can possibly add a test along these lines to one of the other PR's potentially. |
840c21f
to
63cf0e8
Compare
Added a test @drbenvincent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new test looks cool
This behavior should be more intuitive, since do interventions create
Data
containers, and users expect those to be mutable by default. This also alleviates some issues related tosample_posterior_predictive
that currently does not look for sources of mutability on constants:Closes #6977 (I tested the MWE locally)
Related to #7069
We could consider something similar for
pm.observe
but that doesn't create data containers at all right now, so it's a tad less relevant and would require more changes.📚 Documentation preview 📚: https://pymc--7596.org.readthedocs.build/en/7596/