@@ -137,26 +137,26 @@ def fast_sample_posterior_predictive(trace: Union[MultiTrace, Dataset, List[Dict
137
137
138
138
Parameters
139
139
----------
140
- trace : MultiTrace, xarray.Dataset, or List of points (dictionary)
140
+ trace: MultiTrace, xarray.Dataset, or List of points (dictionary)
141
141
Trace generated from MCMC sampling.
142
- samples : int, optional
142
+ samples: int, optional
143
143
Number of posterior predictive samples to generate. Defaults to one posterior predictive
144
144
sample per posterior sample, that is, the number of draws times the number of chains. It
145
145
is not recommended to modify this value; when modified, some chains may not be represented
146
146
in the posterior predictive sample.
147
- model : Model (optional if in `with` context)
147
+ model: Model (optional if in `with` context)
148
148
Model used to generate `trace`
149
- var_names : Iterable[str]
149
+ var_names: Iterable[str]
150
150
List of vars to sample.
151
- keep_size : bool, optional
151
+ keep_size: bool, optional
152
152
Force posterior predictive sample to have the same shape as posterior and sample stats
153
153
data: ``(nchains, ndraws, ...)``.
154
- random_seed : int
154
+ random_seed: int
155
155
Seed for the random number generator.
156
156
157
157
Returns
158
158
-------
159
- samples : dict
159
+ samples: dict
160
160
Dictionary with the variable names as keys, and values numpy arrays containing
161
161
posterior predictive samples.
162
162
"""
@@ -468,16 +468,16 @@ def draw_value(self, param, trace: Optional[_TraceDict]=None, givens=None):
468
468
469
469
Parameters
470
470
----------
471
- param : number, array like, theano variable or pymc3 random variable
471
+ param: number, array like, theano variable or pymc3 random variable
472
472
The value or distribution. Constants or shared variables
473
473
will be converted to an array and returned. Theano variables
474
474
are evaluated. If `param` is a pymc3 random variable, draw
475
475
values from it and return that (as ``np.ndarray``), unless a
476
476
value is specified in the ``trace``.
477
- trace : pm.MultiTrace, optional
477
+ trace: pm.MultiTrace, optional
478
478
A dictionary from pymc3 variable names to samples of their values
479
479
used to provide context for evaluating ``param``.
480
- givens : dict, optional
480
+ givens: dict, optional
481
481
A dictionary from theano variables to their values. These values
482
482
are used to evaluate ``param`` if it is a theano variable.
483
483
"""
@@ -609,51 +609,3 @@ def _param_shape(var_desig, model: Model) -> Tuple[int, ...]:
609
609
if shape == (1 ,):
610
610
shape = tuple ()
611
611
return shape
612
-
613
- # # Posterior predictive sampling takes a "trace-like" argument that is
614
- # # either a `pm.MultiTrace` or a dictionary that acts like a
615
- # # trace. This smooths over that distinction
616
- # def _trace_varnames(trace_like: TraceLike) -> List[str]:
617
- # if hasattr(trace_like, 'varnames'):
618
- # trace_like = cast(MultiTrace, trace_like)
619
- # return trace_like.varnames
620
- # elif isinstance(trace_like, list):
621
- # varnames = [] # type: List[str]
622
- # for tl in trace_like:
623
- # varnames += _trace_varnames(tl)
624
- # return varnames
625
- # else:
626
- # return list(trace_like.keys())
627
-
628
-
629
- # class _PointIterator (Iterator[Dict[str, np.ndarray]]):
630
- # new_dict = None # type: Dict[str, np.ndarray]
631
- # def __init__(self, trace_dict: Dict[str, np.ndarray]):
632
- # new_dict = {name : val if len(val.shape) > 1 else val.reshape(val.shape + (1,))
633
- # for name, val in trace_dict.items() } # type: Dict[str, np.ndarray]
634
- # def __iter__(self):
635
- # return self.iter()
636
- # def iter(self) --> :
637
- # i = 0
638
- # def ifunc():
639
- # try:
640
- # point = {name: trace_dict[name][i,:] for name in self.new_dict.keys()}
641
- # yield point
642
- # except IndexError:
643
- # raise StopIteration
644
- # return ifunc
645
-
646
-
647
-
648
- # # Posterior predictive sampling takes a "trace-like" argument that is
649
- # # either a `pm.MultiTrace` or a dictionary that acts like a
650
- # # trace. This smooths over that distinction
651
- # def _trace_points(trace_like: TraceLike) -> Iterator[Dict[str, Any]]:
652
- # if isinstance(trace_like, MultiTrace):
653
- # return trace_like.points()
654
- # elif isinstance(trace_like, dict):
655
- # return _PointIterator(trace_like)
656
- # elif isinstance(trace_like, list):
657
- # raise ValueError("Cannot make point iterator for a list of traces.")
658
- # else:
659
- # raise ValueError("Do not know how to make point iterator for object of type %s"%type(trace_like))
0 commit comments