def test_list_with_model_classes(self): instance = [ mock.MockClassx2(1.0, 2.0), mock.ComplexClass(mock.MockClassx2(1.0, 2.0)), ] model = af.AbstractPriorModel.from_instance( instance, model_classes=(mock.ComplexClass, )) assert model.prior_count == 2 assert model[0].prior_count == 0 assert model[1].prior_count == 2
def test_dict_with_model_classes(self): instance = { "one": mock.MockClassx2(1.0, 2.0), "two": mock.ComplexClass(mock.MockClassx2(1.0, 2.0)), } model = af.AbstractPriorModel.from_instance( instance, model_classes=(mock.ComplexClass, )) assert model.prior_count == 2 assert model[0].prior_count == 0 assert model[1].prior_count == 2 assert model.one.one == 1.0 assert model.one.two == 2.0 assert isinstance(model.two.simple.one, af.Prior) assert isinstance(model.two.simple.two, af.Prior)
def test_with_model_classes(self): instance = mock.ComplexClass(mock.MockClassx2(1.0, 2.0)) model = af.AbstractPriorModel.from_instance( instance, model_classes=(mock.MockClassx2, )) assert model.prior_count == 2
def make_complex_prior_model(): instance = mock.ComplexClass(mock.MockClassx2(1.0, 2.0)) return af.AbstractPriorModel.from_instance(instance)