Skip to content

Commit 839206b

Browse files
committed
Fix issue 3840.
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.
1 parent b566060 commit 839206b

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

pymc3/sampling.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1568,7 +1568,13 @@ def sample_posterior_predictive(
15681568
raise IncorrectArgumentsError("Should not specify both keep_size and size argukments")
15691569

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

15731579
if samples < len_trace * nchain:
15741580
warnings.warn(

0 commit comments

Comments
 (0)