-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Add nuts_sampler_kwargs to pm.sample #6581
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
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
299e556
Reinstate nuts_kwargs in sample for passing arguments to numpyro
fonnesbeck b9befb6
Removed redundant condition from if statement
fonnesbeck 2fbaab2
Added sampler_kwargs
fonnesbeck ded6cbf
Rename sampler_kwargs; fix test failures
fonnesbeck c99f18b
Ensure nuts_kwargs get passed to pymc nuts
fonnesbeck a539290
Fix test_step_args failure
fonnesbeck 2dc3537
Moved numpyro test; use nuts_sampler_kwargs
fonnesbeck 3098120
Test failure fix
fonnesbeck 4964c3b
Fix docstrings for nuts/sampler kwargs; debugging target accept argum…
fonnesbeck 0f65dab
Removed passing kwargs to external samplers; only nuts_sampler_kwargs…
fonnesbeck bc8e564
Revert nuts_kwargs to nuts
fonnesbeck 64ac855
Fix failures in test_mcmc_external
fonnesbeck 29f41ce
Revert argument parameterization
fonnesbeck 1e08e55
Update pymc/sampling/mcmc.py
fonnesbeck File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,13 +13,11 @@ | |
# limitations under the License. | ||
|
||
import numpy as np | ||
import numpy.testing as npt | ||
import pytest | ||
|
||
from pymc import Model, Normal, sample | ||
|
||
# turns all warnings into errors for this module | ||
pytestmark = pytest.mark.filterwarnings("error") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If a test raises a warning it should be caught explicitly with |
||
|
||
|
||
@pytest.mark.parametrize("nuts_sampler", ["pymc", "nutpie", "blackjax", "numpyro"]) | ||
def test_external_nuts_sampler(recwarn, nuts_sampler): | ||
|
@@ -63,3 +61,16 @@ def test_external_nuts_sampler(recwarn, nuts_sampler): | |
assert idata1.posterior.chain.size == 2 | ||
assert idata1.posterior.draw.size == 500 | ||
np.testing.assert_array_equal(idata1.posterior.x, idata2.posterior.x) | ||
|
||
|
||
def test_step_args(): | ||
with Model() as model: | ||
a = Normal("a") | ||
idata = sample( | ||
nuts_sampler="numpyro", | ||
target_accept=0.5, | ||
nuts={"max_treedepth": 10}, | ||
random_seed=1410, | ||
) | ||
|
||
npt.assert_almost_equal(idata.sample_stats.acceptance_rate.mean(), 0.5, decimal=1) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.