Skip to content

Conversation

mattiadg
Copy link
Contributor

@mattiadg mattiadg commented Oct 27, 2022

What is this PR about?
Add a seed to pm.sample() in BaseSampler, which is a SeededTest but its draws are not yet seeded.
This solves flaky tests like the one reported in #6246. Closes #6246
Given the complex structure of the tests in this file, made of many mixins of fixtures, each with its own class hierarchies, I found BaseSampler to be the only point where the seed can be added meaningfully.

Checklist

Docs / Maintenance

  • Seed BaseSampler class tests

@mattiadg mattiadg changed the title Seed pm.sample in BaseSampler to make test_sampling.py deterministic Seed pm.sample in BaseSampler(SeededTest) to make deriving test classes deterministic Oct 27, 2022
@codecov
Copy link

codecov bot commented Oct 27, 2022

Codecov Report

Merging #6251 (83e29a7) into main (3919ed3) will increase coverage by 30.62%.
The diff coverage is n/a.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##             main    #6251       +/-   ##
===========================================
+ Coverage   60.33%   90.96%   +30.62%     
===========================================
  Files         101      101               
  Lines       22235    22232        -3     
===========================================
+ Hits        13416    20223     +6807     
+ Misses       8819     2009     -6810     
Impacted Files Coverage Δ
pymc/tests/step_methods/test_slicer.py 0.00% <0.00%> (-100.00%) ⬇️
pymc/tests/step_methods/hmc/test_nuts.py 0.00% <0.00%> (-100.00%) ⬇️
pymc/tests/step_methods/test_metropolis.py 0.00% <0.00%> (-100.00%) ⬇️
pymc/step_methods/metropolis.py 54.56% <0.00%> (-28.43%) ⬇️
pymc/sampling.py 71.14% <0.00%> (-11.05%) ⬇️
pymc/backends/report.py 90.00% <0.00%> (-10.00%) ⬇️
pymc/step_methods/arraystep.py 89.36% <0.00%> (-4.97%) ⬇️
pymc/distributions/multivariate.py 92.32% <0.00%> (+0.10%) ⬆️
pymc/model.py 89.47% <0.00%> (+0.55%) ⬆️
pymc/tests/distributions/util.py 90.86% <0.00%> (+2.46%) ⬆️
... and 62 more

@ricardoV94 ricardoV94 merged commit 413d8c2 into pymc-devs:main Oct 28, 2022
@ricardoV94
Copy link
Member

Thanks @mattiadg

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.

Flaky test: pymc/tests/step_methods/hmc/test_nuts.py::TestNUTSNormal::test_kstest
2 participants