Skip to content
Snippets Groups Projects
Commit bbc53943 authored by Colm Talbot's avatar Colm Talbot
Browse files

Merge branch 'pymc3-test-patch' into 'master'

Remove pymc3 tests until dependency issue resolves

See merge request !1060
parents c14012d6 c5c414c3
No related branches found
No related tags found
1 merge request!1060Remove pymc3 tests until dependency issue resolves
Pipeline #346652 passed
...@@ -327,4 +327,4 @@ pypi-release: ...@@ -327,4 +327,4 @@ pypi-release:
script: script:
- twine upload dist/* - twine upload dist/*
only: only:
- tags - tags
...@@ -8,6 +8,10 @@ import bilby ...@@ -8,6 +8,10 @@ import bilby
@pytest.mark.skipif(sys.version_info[1] <= 6, reason="pymc3 is broken in py36") @pytest.mark.skipif(sys.version_info[1] <= 6, reason="pymc3 is broken in py36")
@pytest.mark.xfail(
raises=AttributeError,
reason="Dependency issue with pymc3 causes attribute error on import",
)
class TestPyMC3(unittest.TestCase): class TestPyMC3(unittest.TestCase):
def setUp(self): def setUp(self):
self.likelihood = MagicMock() self.likelihood = MagicMock()
......
...@@ -34,8 +34,8 @@ class TestRunningSamplers(unittest.TestCase): ...@@ -34,8 +34,8 @@ class TestRunningSamplers(unittest.TestCase):
@staticmethod @staticmethod
def conversion_function(parameters, likelihood, prior): def conversion_function(parameters, likelihood, prior):
converted = parameters.copy() converted = parameters.copy()
if 'derived' not in converted: if "derived" not in converted:
converted['derived'] = converted['m'] * converted['c'] converted["derived"] = converted["m"] * converted["c"]
return converted return converted
def tearDown(self): def tearDown(self):
...@@ -52,9 +52,9 @@ class TestRunningSamplers(unittest.TestCase): ...@@ -52,9 +52,9 @@ class TestRunningSamplers(unittest.TestCase):
sampler="cpnest", sampler="cpnest",
nlive=100, nlive=100,
resume=False, resume=False,
**self.kwargs **self.kwargs,
) )
assert 'derived' in res.posterior assert "derived" in res.posterior
assert res.log_likelihood_evaluations is not None assert res.log_likelihood_evaluations is not None
def test_run_dnest4(self): def test_run_dnest4(self):
...@@ -71,7 +71,7 @@ class TestRunningSamplers(unittest.TestCase): ...@@ -71,7 +71,7 @@ class TestRunningSamplers(unittest.TestCase):
num_particles=50, num_particles=50,
**self.kwargs, **self.kwargs,
) )
assert 'derived' in res.posterior assert "derived" in res.posterior
assert res.log_likelihood_evaluations is not None assert res.log_likelihood_evaluations is not None
def test_run_dynesty(self): def test_run_dynesty(self):
...@@ -83,7 +83,7 @@ class TestRunningSamplers(unittest.TestCase): ...@@ -83,7 +83,7 @@ class TestRunningSamplers(unittest.TestCase):
nlive=100, nlive=100,
**self.kwargs, **self.kwargs,
) )
assert 'derived' in res.posterior assert "derived" in res.posterior
assert res.log_likelihood_evaluations is not None assert res.log_likelihood_evaluations is not None
def test_run_dynamic_dynesty(self): def test_run_dynamic_dynesty(self):
...@@ -100,7 +100,7 @@ class TestRunningSamplers(unittest.TestCase): ...@@ -100,7 +100,7 @@ class TestRunningSamplers(unittest.TestCase):
bound="single", bound="single",
**self.kwargs, **self.kwargs,
) )
assert 'derived' in res.posterior assert "derived" in res.posterior
assert res.log_likelihood_evaluations is not None assert res.log_likelihood_evaluations is not None
def test_run_emcee(self): def test_run_emcee(self):
...@@ -113,7 +113,7 @@ class TestRunningSamplers(unittest.TestCase): ...@@ -113,7 +113,7 @@ class TestRunningSamplers(unittest.TestCase):
nwalkers=10, nwalkers=10,
**self.kwargs, **self.kwargs,
) )
assert 'derived' in res.posterior assert "derived" in res.posterior
assert res.log_likelihood_evaluations is not None assert res.log_likelihood_evaluations is not None
def test_run_kombine(self): def test_run_kombine(self):
...@@ -127,7 +127,7 @@ class TestRunningSamplers(unittest.TestCase): ...@@ -127,7 +127,7 @@ class TestRunningSamplers(unittest.TestCase):
autoburnin=False, autoburnin=False,
**self.kwargs, **self.kwargs,
) )
assert 'derived' in res.posterior assert "derived" in res.posterior
assert res.log_likelihood_evaluations is not None assert res.log_likelihood_evaluations is not None
def test_run_nestle(self): def test_run_nestle(self):
...@@ -139,7 +139,7 @@ class TestRunningSamplers(unittest.TestCase): ...@@ -139,7 +139,7 @@ class TestRunningSamplers(unittest.TestCase):
nlive=100, nlive=100,
**self.kwargs, **self.kwargs,
) )
assert 'derived' in res.posterior assert "derived" in res.posterior
assert res.log_likelihood_evaluations is not None assert res.log_likelihood_evaluations is not None
def test_run_nessai(self): def test_run_nessai(self):
...@@ -153,7 +153,7 @@ class TestRunningSamplers(unittest.TestCase): ...@@ -153,7 +153,7 @@ class TestRunningSamplers(unittest.TestCase):
max_iteration=1000, max_iteration=1000,
**self.kwargs, **self.kwargs,
) )
assert 'derived' in res.posterior assert "derived" in res.posterior
assert res.log_likelihood_evaluations is not None assert res.log_likelihood_evaluations is not None
def test_run_pypolychord(self): def test_run_pypolychord(self):
...@@ -165,7 +165,7 @@ class TestRunningSamplers(unittest.TestCase): ...@@ -165,7 +165,7 @@ class TestRunningSamplers(unittest.TestCase):
nlive=100, nlive=100,
**self.kwargs, **self.kwargs,
) )
assert 'derived' in res.posterior assert "derived" in res.posterior
assert res.log_likelihood_evaluations is not None assert res.log_likelihood_evaluations is not None
def test_run_ptemcee(self): def test_run_ptemcee(self):
...@@ -181,10 +181,14 @@ class TestRunningSamplers(unittest.TestCase): ...@@ -181,10 +181,14 @@ class TestRunningSamplers(unittest.TestCase):
frac_threshold=0.5, frac_threshold=0.5,
**self.kwargs, **self.kwargs,
) )
assert 'derived' in res.posterior assert "derived" in res.posterior
assert res.log_likelihood_evaluations is not None assert res.log_likelihood_evaluations is not None
@pytest.mark.skipif(sys.version_info[1] <= 6, reason="pymc3 is broken in py36") @pytest.mark.skipif(sys.version_info[1] <= 6, reason="pymc3 is broken in py36")
@pytest.mark.xfail(
raises=AttributeError,
reason="Dependency issue with pymc3 causes attribute error on import",
)
def test_run_pymc3(self): def test_run_pymc3(self):
pytest.importorskip("pymc3") pytest.importorskip("pymc3")
res = bilby.run_sampler( res = bilby.run_sampler(
...@@ -196,7 +200,7 @@ class TestRunningSamplers(unittest.TestCase): ...@@ -196,7 +200,7 @@ class TestRunningSamplers(unittest.TestCase):
n_init=250, n_init=250,
**self.kwargs, **self.kwargs,
) )
assert 'derived' in res.posterior assert "derived" in res.posterior
assert res.log_likelihood_evaluations is not None assert res.log_likelihood_evaluations is not None
def test_run_pymultinest(self): def test_run_pymultinest(self):
...@@ -206,9 +210,9 @@ class TestRunningSamplers(unittest.TestCase): ...@@ -206,9 +210,9 @@ class TestRunningSamplers(unittest.TestCase):
priors=self.priors, priors=self.priors,
sampler="pymultinest", sampler="pymultinest",
nlive=100, nlive=100,
**self.kwargs **self.kwargs,
) )
assert 'derived' in res.posterior assert "derived" in res.posterior
assert res.log_likelihood_evaluations is not None assert res.log_likelihood_evaluations is not None
def test_run_PTMCMCSampler(self): def test_run_PTMCMCSampler(self):
...@@ -220,36 +224,44 @@ class TestRunningSamplers(unittest.TestCase): ...@@ -220,36 +224,44 @@ class TestRunningSamplers(unittest.TestCase):
Niter=101, Niter=101,
burn=2, burn=2,
isave=100, isave=100,
**self.kwargs **self.kwargs,
) )
assert 'derived' in res.posterior assert "derived" in res.posterior
assert res.log_likelihood_evaluations is not None assert res.log_likelihood_evaluations is not None
def test_run_ultranest(self): def test_run_ultranest(self):
pytest.importorskip("ultranest") pytest.importorskip("ultranest")
# run using NestedSampler (with nlive specified) # run using NestedSampler (with nlive specified)
res = bilby.run_sampler( res = bilby.run_sampler(
likelihood=self.likelihood, priors=self.priors, likelihood=self.likelihood,
sampler="ultranest", nlive=100, **self.kwargs, priors=self.priors,
sampler="ultranest",
nlive=100,
**self.kwargs,
) )
assert 'derived' in res.posterior assert "derived" in res.posterior
assert res.log_likelihood_evaluations is not None assert res.log_likelihood_evaluations is not None
# run using ReactiveNestedSampler (with no nlive given) # run using ReactiveNestedSampler (with no nlive given)
res = bilby.run_sampler( res = bilby.run_sampler(
likelihood=self.likelihood, priors=self.priors, likelihood=self.likelihood,
sampler='ultranest', **self.kwargs, priors=self.priors,
sampler="ultranest",
**self.kwargs,
) )
assert 'derived' in res.posterior assert "derived" in res.posterior
assert res.log_likelihood_evaluations is not None assert res.log_likelihood_evaluations is not None
def test_run_bilby_mcmc(self): def test_run_bilby_mcmc(self):
res = bilby.run_sampler( res = bilby.run_sampler(
likelihood=self.likelihood, priors=self.priors, likelihood=self.likelihood,
sampler="bilby_mcmc", nsamples=200, **self.kwargs, priors=self.priors,
sampler="bilby_mcmc",
nsamples=200,
**self.kwargs,
printdt=1, printdt=1,
) )
assert 'derived' in res.posterior assert "derived" in res.posterior
assert res.log_likelihood_evaluations is not None assert res.log_likelihood_evaluations is not None
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment