Exemplo n.º 1
0
 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)
Exemplo n.º 2
0
 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)
Exemplo n.º 3
0
 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'))
Exemplo n.º 4
0
 def test_sample_takes_strategy_object(self):
     strategy = EmceeStrategy(nsamples=2)
     result = sample(DATA, SimpleModel(), strategy)
     self.assertEqual(result.strategy, strategy)