Skip to content

Commit 5d2fe4f

Browse files
aseyboldttwiecki
authored andcommitted
Better error message for empty models
1 parent bb25d7b commit 5d2fe4f

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

pymc3/step_methods/arraystep.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ def __new__(cls, *args, **kwargs):
4949
# get the actual inputs from the vars
5050
vars = inputvars(vars)
5151

52+
if len(vars) == 0:
53+
raise ValueError('No free random variables to sample.')
54+
5255
if not blocked and len(vars) > 1:
5356
# In this case we create a separate sampler for each var
5457
# and append them to a CompoundStep

pymc3/theanof.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,9 @@ def join_nonshared_inputs(xs, vars, shared, make_shared=False):
212212
tensors : list of same tensors but with inarray as input
213213
inarray : vector of inputs
214214
"""
215+
if not vars:
216+
raise ValueError('Empty list of variables.')
217+
215218
joined = tt.concatenate([var.ravel() for var in vars])
216219

217220
if not make_shared:

pymc3/variational/advi.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ def advi(vars=None, start=None, model=None, n=5000, accurate_elbo=False,
111111
vars = model.vars
112112
vars = pm.inputvars(vars)
113113

114+
if len(vars) == 0:
115+
raise ValueError('No free random variables to fit.')
116+
114117
if not pm.model.all_continuous(vars):
115118
raise ValueError('Model can not include discrete RVs for ADVI.')
116119

0 commit comments

Comments
 (0)