예제 #1
0
파일: test_step.py 프로젝트: zzwwqqq/pymc3
    def test_demcmc_tune_parameter(self):
        """Tests that validity of the tune setting is checked"""
        with Model() as model:
            Normal("n", mu=0, sigma=1, shape=(2,3))
            
            step = DEMetropolis()
            assert step.tune is None

            step = DEMetropolis(tune='scaling')
            assert step.tune == 'scaling'

            step = DEMetropolis(tune='lambda')
            assert step.tune == 'lambda'

            with pytest.raises(ValueError):
                DEMetropolis(tune='foo')
        pass
예제 #2
0
파일: test_step.py 프로젝트: zzwwqqq/pymc3
 def test_demcmc_warning_on_small_populations(self):
     """Test that a warning is raised when n_chains <= n_dims"""
     with Model() as model:
         Normal("n", mu=0, sigma=1, shape=(2,3))
         with pytest.warns(UserWarning) as record:
             sample(
                 draws=5, tune=5, chains=6, step=DEMetropolis(),
                 # make tests faster by not parallelizing; disable convergence warning
                 cores=1, compute_convergence_checks=False
             )
     pass
예제 #3
0
파일: test_step.py 프로젝트: zzwwqqq/pymc3
    def test_parallelized_chains_are_random(self):
        with Model() as model:
            x = Normal("x", 0, 1)
            for stepper in TestPopulationSamplers.steppers:
                step = stepper()
                trace = sample(chains=4, cores=4, draws=20, tune=0, step=DEMetropolis())
                samples = np.array(trace.get_values("x", combine=False))[:, 5]

                assert len(set(samples)) == 4, "Parallelized {} " "chains are identical.".format(
                    stepper
                )
        pass