Skip to content

Commit e93efce

Browse files
authored
test_model.py: check shared tensor type conversion in ValueGradFunction
- test the error described in pymc-devs#3122 and fixed in pymc-devs#3335.
1 parent 2419872 commit e93efce

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

pymc3/tests/test_model.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,3 +288,16 @@ def test_edge_case(self):
288288
assert logp.size == 1
289289
assert dlogp.size == 4
290290
npt.assert_allclose(dlogp, 0., atol=1e-5)
291+
292+
def test_tensor_type_conversion(self):
293+
# case described in #3122
294+
X = np.random.binomial(1, 0.5, 10)
295+
X[0] = -1 # masked a single value
296+
X = np.ma.masked_values(X, value=-1)
297+
with pm.Model() as m:
298+
x1 = pm.Uniform('x1', 0., 1.)
299+
x2 = pm.Bernoulli('x2', x1, observed=X)
300+
301+
gf = m.logp_dlogp_function()
302+
303+
assert m['x2_missing'].type == gf._extra_vars_shared['x2_missing'].type

0 commit comments

Comments
 (0)