Skip to content

Commit

Permalink
Fix issue 3840.
Browse files Browse the repository at this point in the history
Previously, if the argument to sample_posterior_predictive was a list of points, AND the samples argument was not supplied, then spp would error out, because the code for computing samples assumed that the trace argument was a MultiTrace.
  • Loading branch information
rpgoldman committed Mar 19, 2020
1 parent b566060 commit 839206b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pymc3/sampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -1568,7 +1568,13 @@ def sample_posterior_predictive(
raise IncorrectArgumentsError("Should not specify both keep_size and size argukments")

if samples is None:
samples = sum(len(v) for v in trace._straces.values())
if isinstance(trace, MultiTrace):
samples = sum(len(v) for v in trace._straces.values())
elif isinstance(trace, list) and all((isinstance(x, dict) for x in trace)):
# this is a list of points
samples = len(trace)
else:
raise ValueError("Do not know how to compute number of samples for trace argument of type %s"%type(trace))

if samples < len_trace * nchain:
warnings.warn(
Expand Down

0 comments on commit 839206b

Please sign in to comment.