diff --git a/pymc/model.py b/pymc/model.py index 7d3972a4c6a..490bd08b9fb 100644 --- a/pymc/model.py +++ b/pymc/model.py @@ -1456,7 +1456,7 @@ def make_obs_var( # Create deterministic that combines observed and missing # Note: This can widely increase memory consumption during sampling for large datasets - rv_var = at.zeros(data.shape) + rv_var = at.empty(data.shape, dtype=observed_rv_var.type.dtype) rv_var = at.set_subtensor(rv_var[mask.nonzero()], missing_rv_var) rv_var = at.set_subtensor(rv_var[antimask_idx], observed_rv_var) rv_var = Deterministic(name, rv_var, self, dims) diff --git a/pymc/tests/test_model.py b/pymc/tests/test_model.py index 84f814e6104..aea3f730258 100644 --- a/pymc/tests/test_model.py +++ b/pymc/tests/test_model.py @@ -356,6 +356,9 @@ def test_missing_data(self): assert m["x2_missing"].type == gf._extra_vars_shared["x2_missing"].type + # The dtype of the merged observed/missing deterministic should match the RV dtype + assert m.deterministics[0].type.dtype == x2.type.dtype + pnt = m.initial_point(random_seed=None).copy() del pnt["x2_missing"]