|
32 | 32 | import packaging
|
33 | 33 | import xarray
|
34 | 34 |
|
| 35 | +from aesara.tensor.sharedvar import SharedVariable |
35 | 36 | from arviz import InferenceData
|
36 | 37 | from fastprogress.fastprogress import progress_bar
|
37 | 38 |
|
@@ -1730,15 +1731,21 @@ def sample_posterior_predictive(
|
1730 | 1731 | inputs_and_names = [
|
1731 | 1732 | (rv, rv.name)
|
1732 | 1733 | for rv in rv_ancestors(vars_to_sample, walk_past_rvs=True)
|
1733 |
| - if rv not in vars_to_sample and rv in model.named_vars.values() |
| 1734 | + if rv not in vars_to_sample |
| 1735 | + and rv in model.named_vars.values() |
| 1736 | + and not isinstance(rv, SharedVariable) |
1734 | 1737 | ]
|
1735 | 1738 | if inputs_and_names:
|
1736 | 1739 | inputs, input_names = zip(*inputs_and_names)
|
1737 | 1740 | else:
|
1738 | 1741 | inputs, input_names = [], []
|
1739 | 1742 | else:
|
1740 | 1743 | output_names = [v.name for v in vars_to_sample if v.name is not None]
|
1741 |
| - input_names = [n for n in _trace.varnames if n not in output_names] |
| 1744 | + input_names = [ |
| 1745 | + n |
| 1746 | + for n in _trace.varnames |
| 1747 | + if n not in output_names and not isinstance(model[n], SharedVariable) |
| 1748 | + ] |
1742 | 1749 | inputs = [model[n] for n in input_names]
|
1743 | 1750 |
|
1744 | 1751 | if size is not None:
|
@@ -1987,7 +1994,7 @@ def sample_prior_predictive(
|
1987 | 1994 | names = get_default_varnames(vars_, include_transformed=False)
|
1988 | 1995 |
|
1989 | 1996 | vars_to_sample = [model[name] for name in names]
|
1990 |
| - inputs = [i for i in inputvars(vars_to_sample)] |
| 1997 | + inputs = [i for i in inputvars(vars_to_sample) if not isinstance(i, SharedVariable)] |
1991 | 1998 | sampler_fn = aesara.function(
|
1992 | 1999 | inputs,
|
1993 | 2000 | vars_to_sample,
|
|
0 commit comments