Skip to content

Commit 4a37e24

Browse files
committed
Fix docstrings.
The layout of parameters sections was wrong. Also pruned some dead code.
1 parent 6699447 commit 4a37e24

File tree

1 file changed

+10
-58
lines changed

1 file changed

+10
-58
lines changed

pymc3/distributions/posterior_predictive.py

+10-58
Original file line numberDiff line numberDiff line change
@@ -137,26 +137,26 @@ def fast_sample_posterior_predictive(trace: Union[MultiTrace, Dataset, List[Dict
137137
138138
Parameters
139139
----------
140-
trace : MultiTrace, xarray.Dataset, or List of points (dictionary)
140+
trace: MultiTrace, xarray.Dataset, or List of points (dictionary)
141141
Trace generated from MCMC sampling.
142-
samples : int, optional
142+
samples: int, optional
143143
Number of posterior predictive samples to generate. Defaults to one posterior predictive
144144
sample per posterior sample, that is, the number of draws times the number of chains. It
145145
is not recommended to modify this value; when modified, some chains may not be represented
146146
in the posterior predictive sample.
147-
model : Model (optional if in `with` context)
147+
model: Model (optional if in `with` context)
148148
Model used to generate `trace`
149-
var_names : Iterable[str]
149+
var_names: Iterable[str]
150150
List of vars to sample.
151-
keep_size : bool, optional
151+
keep_size: bool, optional
152152
Force posterior predictive sample to have the same shape as posterior and sample stats
153153
data: ``(nchains, ndraws, ...)``.
154-
random_seed : int
154+
random_seed: int
155155
Seed for the random number generator.
156156
157157
Returns
158158
-------
159-
samples : dict
159+
samples: dict
160160
Dictionary with the variable names as keys, and values numpy arrays containing
161161
posterior predictive samples.
162162
"""
@@ -468,16 +468,16 @@ def draw_value(self, param, trace: Optional[_TraceDict]=None, givens=None):
468468
469469
Parameters
470470
----------
471-
param : number, array like, theano variable or pymc3 random variable
471+
param: number, array like, theano variable or pymc3 random variable
472472
The value or distribution. Constants or shared variables
473473
will be converted to an array and returned. Theano variables
474474
are evaluated. If `param` is a pymc3 random variable, draw
475475
values from it and return that (as ``np.ndarray``), unless a
476476
value is specified in the ``trace``.
477-
trace : pm.MultiTrace, optional
477+
trace: pm.MultiTrace, optional
478478
A dictionary from pymc3 variable names to samples of their values
479479
used to provide context for evaluating ``param``.
480-
givens : dict, optional
480+
givens: dict, optional
481481
A dictionary from theano variables to their values. These values
482482
are used to evaluate ``param`` if it is a theano variable.
483483
"""
@@ -609,51 +609,3 @@ def _param_shape(var_desig, model: Model) -> Tuple[int, ...]:
609609
if shape == (1,):
610610
shape = tuple()
611611
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

Comments
 (0)