Skip to content

Commit

Permalink
Remove old MultiObservedRV tests
Browse files Browse the repository at this point in the history
Closes #4534
  • Loading branch information
ricardoV94 committed Jan 13, 2022
1 parent b386ae5 commit 16d91f2
Showing 1 changed file with 0 additions and 57 deletions.
57 changes: 0 additions & 57 deletions pymc/tests/test_idata_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,63 +388,6 @@ def test_multiple_observed_rv(self, log_likelihood):
fails = check_multiple_attrs(test_dict, inference_data)
assert not fails

@pytest.mark.xfail(reason="MultiObservedRV is no longer used in v4")
def test_multiple_observed_rv_without_observations(self):
with pm.Model():
mu = pm.Normal("mu")
x = pm.DensityDist( # pylint: disable=unused-variable
"x", mu, logp=lambda value, mu: pm.Normal.logp(value, mu, 1), observed=0.1
)
inference_data = pm.sample(100, chains=2, return_inferencedata=True)
test_dict = {
"posterior": ["mu"],
"sample_stats": ["lp"],
"log_likelihood": ["x"],
"observed_data": ["value", "~x"],
}
fails = check_multiple_attrs(test_dict, inference_data)
assert not fails
assert inference_data.observed_data.value.dtype.kind == "f"

@pytest.mark.xfail(reason="MultiObservedRV is no longer used in v4")
@pytest.mark.parametrize("multiobs", (True, False))
def test_multiobservedrv_to_observed_data(self, multiobs):
# fake regression data, with weights (W)
np.random.seed(2019)
N = 100
X = np.random.uniform(size=N)
W = 1 + np.random.poisson(size=N)
a, b = 5, 17
Y = a + np.random.normal(b * X)

with pm.Model():
a = pm.Normal("a", 0, 10)
b = pm.Normal("b", 0, 10)
mu = a + b * X
sigma = pm.HalfNormal("sigma", 1)
w = W

def weighted_normal(value, mu, sigma, w):
return w * pm.Normal.logp(value, mu, sigma)

y_logp = pm.DensityDist( # pylint: disable=unused-variable
"y_logp", mu, sigma, w, logp=weighted_normal, observed=Y, size=N
)
idata = pm.sample(
20, tune=20, return_inferencedata=True, idata_kwargs={"density_dist_obs": multiobs}
)
multiobs_str = "" if multiobs else "~"
test_dict = {
"posterior": ["a", "b", "sigma"],
"sample_stats": ["lp"],
"log_likelihood": ["y_logp"],
f"{multiobs_str}observed_data": ["y", "w"],
}
fails = check_multiple_attrs(test_dict, idata)
assert not fails
if multiobs:
assert idata.observed_data.y.dtype.kind == "f"

def test_single_observation(self):
with pm.Model():
p = pm.Uniform("p", 0, 1)
Expand Down

0 comments on commit 16d91f2

Please sign in to comment.