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

Fix check for missing rv in factorized_joint_logprob #151

Merged
merged 2 commits into from
Jul 5, 2022
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
11 changes: 6 additions & 5 deletions aeppl/joint_logprob.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,12 @@ def factorized_joint_logprob(
if not outputs:
continue

if warn_missing_rvs and any(o not in updated_rv_values for o in outputs):
warnings.warn(
"Found a random variable that was neither among the observations "
f"nor the conditioned variables: {node.outputs}"
)
if any(o not in updated_rv_values for o in outputs):
if warn_missing_rvs:
warnings.warn(
"Found a random variable that was neither among the observations "
f"nor the conditioned variables: {node.outputs}"
)
continue

q_value_vars = [replacements[q_rv_var] for q_rv_var in outputs]
Expand Down
6 changes: 6 additions & 0 deletions tests/test_joint_logprob.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import warnings

import aesara
import aesara.tensor as at
import numpy as np
Expand Down Expand Up @@ -261,6 +263,10 @@ def test_warn_random_not_found():
with pytest.warns(UserWarning):
factorized_joint_logprob({y_rv: y_vv})

with warnings.catch_warnings():
warnings.simplefilter("error")
factorized_joint_logprob({y_rv: y_vv}, warn_missing_rvs=False)


def test_multiple_rvs_to_same_value_raises():
x_rv1 = at.random.normal(name="x1")
Expand Down
1 change: 1 addition & 0 deletions tests/test_scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ def scan_fn(mus_t, sigma_t, Y_t_val, S_t_val, Gamma_t):


@aesara.config.change_flags(compute_test_value="raise")
larryshamalama marked this conversation as resolved.
Show resolved Hide resolved
@pytest.mark.xfail(reason="see #148")
def test_initial_values():
srng = at.random.RandomStream(seed=2320)

Expand Down