Skip to content

Commit add0f71

Browse files
committed
model.py: fix issue with length 1 shared variables
- this patch fixes an issue highlighted in pymc-devs#3122 where imputation of a single missing observation fails. It implements the suggestion from the theano error message to manual force a TensorType change in cases where the variable has a length of one.
1 parent b64f810 commit add0f71

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

pymc3/model.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,9 @@ def __init__(self, cost, grad_vars, extra_vars=None, dtype=None,
437437
self._extra_vars_shared = {}
438438
for var in extra_vars:
439439
shared = theano.shared(var.tag.test_value, var.name + '_shared__')
440+
if isinstance(var.tag.test_value, np.ndarray):
441+
if len(var.tag.test_value) == 1:
442+
shared.type = theano.tensor.TensorType(var.dtype, (True,))
440443
self._extra_vars_shared[var.name] = shared
441444
givens.append((var, shared))
442445

0 commit comments

Comments
 (0)