def test_fit(method, kwargs, error): with _model: if error is not None: with pytest.raises(error): fit(10, method=method, **kwargs) else: fit(10, method=method, **kwargs)
def test_error_on_local_rv_for_svgd(another_simple_model): with another_simple_model: with pytest.raises(ValueError) as e: fit(10, method='svgd', local_rv={another_simple_model.free_RVs[0]: (0, 1)}) assert e.match('does not support AEVB')
def test_fit_fn_text(method, kwargs, error, another_simple_model): with another_simple_model: if error is not None: with pytest.raises(error): fit(10, method=method, **kwargs) else: fit(10, method=method, **kwargs)
def test_combined(self): with models.multidimensional_model()[1]: self.assertRaises(ValueError, fit, 10, method='advi->fullrank_advi', frac=1) fit(10, method='advi->fullrank_advi', frac=.5)
def test_approximate(self): with models.multidimensional_model()[1]: meth = ADVI() fit(10, method=meth) with pytest.raises(KeyError): fit(10, method='undefined') with pytest.raises(TypeError): fit(10, method=1)
def test_fit_fn_oo(fit_method_with_object, another_simple_model): with another_simple_model: fit(10, method=fit_method_with_object)
def test_error_on_local_rv_for_svgd(another_simple_model): with another_simple_model: with pytest.raises(ValueError) as e: fit(10, method='svgd', local_rv={ another_simple_model.free_RVs[0]: (0, 1)}) assert e.match('does not support AEVB')
def test_approximate(self): with models.multidimensional_model()[1]: fit(10, method='fullrank_advi')
def test_approximate(self): with models.multidimensional_model()[1]: meth = ADVI() fit(10, method=meth) self.assertRaises(KeyError, fit, 10, method='undefined') self.assertRaises(TypeError, fit, 10, method=1)
def test_combined(self): with models.multidimensional_model()[1]: with pytest.raises(ValueError): fit(10, method='advi->fullrank_advi', frac=1) fit(10, method='advi->fullrank_advi', frac=.5)