Skip to content

uncomment test from #4297 #4302

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 2 commits into from
Dec 7, 2020
Merged

Conversation

MarcoGorelli
Copy link
Contributor

#4297 had a commented-out test, so here's a little PR to uncomment it

If we set a global variable PLATFORM in pymc3/distributions/distribution.py then we can patch it during testing without affecting sys.platform and hence not affecting theano

@MarcoGorelli MarcoGorelli requested a review from Spaak December 5, 2020 18:39
@codecov
Copy link

codecov bot commented Dec 5, 2020

Codecov Report

Merging #4302 (8076a26) into master (3fa3d1f) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #4302   +/-   ##
=======================================
  Coverage   87.69%   87.69%           
=======================================
  Files          88       88           
  Lines       14355    14356    +1     
=======================================
+ Hits        12588    12590    +2     
+ Misses       1767     1766    -1     
Impacted Files Coverage Δ
pymc3/distributions/distribution.py 94.52% <100.00%> (+0.26%) ⬆️

Copy link
Member

@Spaak Spaak left a comment

Choose a reason for hiding this comment

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

Looks good, though see my comment on pytest.raises vs xfail. I leave the decision up to @MarcoGorelli .

def test_spawn_densitydist_bound_method():
with pm.Model() as model:
mu = pm.Normal("mu", 0, 1)
normal_dist = pm.Normal.dist(mu, 1)
obs = pm.DensityDist("density_dist", normal_dist.logp, observed=np.random.randn(100))
trace = pm.sample(draws=10, tune=10, step=pm.Metropolis(), cores=2, mp_ctx="spawn")
msg = "logp for DensityDist is a bound method, leading to RecursionError while serializing"
with pytest.raises(ValueError, match=msg):
Copy link
Member

Choose a reason for hiding this comment

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

I considered pytest.raises, but the code in DensityDist is not guaranteed to raise the error. It will try to serialize as normal, and only if a RecursionError occurs (at the moment, expected to happen), it's wrapped and re-raised. It's possible that a later fix in dill or so will prevent the error from happening altogether. So I decided on xfail instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah, I see - thanks for explaining!

It's possible that a later fix in dill or so will prevent the error from happening altogether

If that happens, maybe it's good that this test fails (i.e. doesn't raise a ValueError) because then we will get a loud and clear notice that the error no longer happens and then we can set a minimum dill version?

Copy link
Member

Choose a reason for hiding this comment

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

Yep, sounds good to me :)

@twiecki twiecki merged commit a5d1697 into pymc-devs:master Dec 7, 2020
@twiecki
Copy link
Member

twiecki commented Dec 7, 2020

Thanks @MarcoGorelli!

@MarcoGorelli MarcoGorelli deleted the uncomment-test branch December 7, 2020 11:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants