Skip to content
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

Suggest var_names when using deprecated API for partial traces #7289

Merged
merged 3 commits into from
May 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions pymc/sampling/mcmc.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,10 +630,7 @@ def sample(
else:
kwargs["nuts"] = {"target_accept": kwargs.pop("target_accept")}
if isinstance(trace, list):
raise DeprecationWarning(
"We have removed support for partial traces because it simplified things."
" Please open an issue if & why this is a problem for you."
)
raise ValueError("Please use `var_names` keyword argument for partial traces.")

model = modelcontext(model)
if not model.free_RVs:
Expand Down
4 changes: 2 additions & 2 deletions tests/sampling/test_mcmc.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,11 +507,11 @@ def test_empty_model():
error.match("any free variables")


def test_partial_trace_unsupported():
def test_partial_trace_with_trace_unsupported():
with pm.Model() as model:
a = pm.Normal("a", mu=0, sigma=1)
b = pm.Normal("b", mu=0, sigma=1)
with pytest.raises(DeprecationWarning, match="removed support"):
with pytest.raises(ValueError, match="var_names"):
pm.sample(trace=[a])


Expand Down
Loading