Skip to content

Commit

Permalink
test_model.py: check shared tensor type conversion in ValueGradFunction
Browse files Browse the repository at this point in the history
 - test the error described in pymc-devs#3122 and fixed in pymc-devs#3335.
  • Loading branch information
mattpitkin authored Jan 14, 2019
1 parent 2419872 commit e93efce
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions pymc3/tests/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,3 +288,16 @@ def test_edge_case(self):
assert logp.size == 1
assert dlogp.size == 4
npt.assert_allclose(dlogp, 0., atol=1e-5)

def test_tensor_type_conversion(self):
# case described in #3122
X = np.random.binomial(1, 0.5, 10)
X[0] = -1 # masked a single value
X = np.ma.masked_values(X, value=-1)
with pm.Model() as m:
x1 = pm.Uniform('x1', 0., 1.)
x2 = pm.Bernoulli('x2', x1, observed=X)

gf = m.logp_dlogp_function()

assert m['x2_missing'].type == gf._extra_vars_shared['x2_missing'].type

0 comments on commit e93efce

Please sign in to comment.