def test_sample_function_identical_to_strategy_method(self): model = SimpleModel() strategy = EmceeStrategy(nwalkers=6, nsamples=10, seed=123) strategy_result = strategy.sample(model, DATA) strategy_result.time = None model_result = sample(DATA, model, strategy) model_result.time = None self.assertEqual(strategy_result, model_result)
def test_default_sampling_strategy_is_emcee(self): # for speed, we monkey-patch emcee.default_nsamples # FIXME this is maybe not the best way to do this. put_back = EmceeStrategy._default_nsamples * 1 EmceeStrategy._default_nsamples = 1 result = sample(DATA, SimpleModel()) self.assertTrue(isinstance(result.strategy, EmceeStrategy)) # and put it back!! EmceeStrategy._default_nsamples = put_back self.assertNotEqual(EmceeStrategy._default_nsamples, 1)
def test_sample_function_calls_model_sample(self): result = sample(DATA, SimpleModel()) self.assertTrue(isinstance(result, SamplingResult)) self.assertTrue(isinstance(result.strategy, EmceeStrategy)) self.assertTrue(hasattr(result, 'samples'))
def test_sample_takes_strategy_object(self): strategy = EmceeStrategy(nsamples=2) result = sample(DATA, SimpleModel(), strategy) self.assertEqual(result.strategy, strategy)