def test_group_api_params(three_var_model, raises, params, type_, kw, formula): with three_var_model, raises: g = Group([three_var_model.one], params=params, **kw) assert isinstance(g, type_) if g.has_logq: # should work as well logq = g.logq logq = g.set_size_and_deterministic(logq, 1, 0) logq.eval()
def test_group_api_vfam(three_var_model, raises, vfam, type_, kw): with three_var_model, raises: g = Group([three_var_model.one], vfam, **kw) assert isinstance(g, type_) assert not hasattr(g, "_kwargs") if isinstance(g, NormalizingFlowGroup): assert isinstance(g.flow, pm.flows.AbstractFlow) assert g.flow.formula == vfam
def __init__(self, *args, **kwargs): local_rv = kwargs.get("local_rv") groups = [self._group_class(None, *args, **kwargs)] if local_rv is not None: groups.extend([ Group([v], params=p, local=True, model=kwargs.get("model")) for v, p in local_rv.items() ]) super().__init__(groups, model=kwargs.get("model"))
def test_rowwise_approx(three_var_model, parametric_grouped_approxes): # add to inference that supports aevb cls, kw = parametric_grouped_approxes with three_var_model: try: approx = Approximation([ cls([three_var_model.one], rowwise=True, **kw), Group(None, vfam="mf") ]) inference = pm.KLqp(approx) approx = inference.fit(3, obj_n_mc=2) approx.sample(10) approx.sample_node(three_var_model.one).eval() except pm.opvi.BatchedGroupError: pytest.skip("Does not support rowwise grouping")
def test_group_api_vfam(three_var_model, raises, vfam, type_, kw): with three_var_model, raises: g = Group([three_var_model.one], vfam, **kw) assert isinstance(g, type_) assert not hasattr(g, "_kwargs")