Skip to content

Commit 54ca772

Browse files
committed
Test for using CustomDist in multiprocess smc sampling
1 parent 9757434 commit 54ca772

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

tests/smc/test_smc.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,18 @@ def test_unobserved_categorical(self):
133133

134134
assert np.all(np.median(trace["mu"], axis=0) == [1, 2])
135135

136+
def test_parallel_custom(self):
137+
def _logp(value, mu):
138+
return -((value - mu) ** 2)
139+
140+
def _random(mu, rng=None, size=None):
141+
return rng.normal(loc=mu, scale=1, size=size)
142+
143+
with pm.Model():
144+
mu = pm.CustomDist("mu", 0, logp=_logp, random=_random)
145+
pm.CustomDist("y", mu, logp=_logp, class_name="", random=_random, observed=[1, 2])
146+
pm.sample_smc(draws=6, cores=2)
147+
136148
def test_marginal_likelihood(self):
137149
"""
138150
Verifies that the log marginal likelihood function

0 commit comments

Comments
 (0)