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

Merge branch 'fix-ci' into 'master'

Fix CI failures

See merge request lscsoft/bilby!1095
parents 6532c63d 64518bfe
No related branches found
No related tags found
1 merge request!1095Fix CI failures
Pipeline #378782 passed
...@@ -213,7 +213,7 @@ docs: ...@@ -213,7 +213,7 @@ docs:
image: containers.ligo.org/lscsoft/bilby/v2-bilby-python39 image: containers.ligo.org/lscsoft/bilby/v2-bilby-python39
before_script: before_script:
- conda install -c conda-forge pandoc -y - conda install -c conda-forge pandoc -y
- python -m pip install ipykernel ipython jupyter - python -m pip install --upgrade ipykernel ipython jupyter nbconvert
- python -m ipykernel install - python -m ipykernel install
script: script:
# Make the documentation # Make the documentation
......
...@@ -5,7 +5,7 @@ repos: ...@@ -5,7 +5,7 @@ repos:
- id: check-merge-conflict # prevent committing files with merge conflicts - id: check-merge-conflict # prevent committing files with merge conflicts
- id: flake8 # checks for flake8 errors - id: flake8 # checks for flake8 errors
- repo: https://github.com/psf/black - repo: https://github.com/psf/black
rev: 21.12b0 rev: 22.3.0
hooks: hooks:
- id: black - id: black
language_version: python3 language_version: python3
......
...@@ -614,7 +614,7 @@ class BilbyPTMCMCSampler(object): ...@@ -614,7 +614,7 @@ class BilbyPTMCMCSampler(object):
elif pt_inputs.Tmax_from_SNR is not None: elif pt_inputs.Tmax_from_SNR is not None:
ndim = len(_priors.non_fixed_keys) ndim = len(_priors.non_fixed_keys)
target_hot_likelihood = ndim / 2 target_hot_likelihood = ndim / 2
Tmax = pt_inputs.Tmax_from_SNR ** 2 / (2 * target_hot_likelihood) Tmax = pt_inputs.Tmax_from_SNR**2 / (2 * target_hot_likelihood)
betas = np.logspace(0, -np.log10(Tmax), pt_inputs.ntemps) betas = np.logspace(0, -np.log10(Tmax), pt_inputs.ntemps)
else: else:
raise SamplerError("Unable to set temperature ladder from inputs") raise SamplerError("Unable to set temperature ladder from inputs")
......
...@@ -23,14 +23,14 @@ class ZeroLikelihood(bilby.core.likelihood.Likelihood): ...@@ -23,14 +23,14 @@ class ZeroLikelihood(bilby.core.likelihood.Likelihood):
def condition_func_y(reference_params, x): def condition_func_y(reference_params, x):
"""Condition function for our p(y|x) prior.""" """Condition function for our p(y|x) prior."""
radius = 0.5 * (reference_params["maximum"] - reference_params["minimum"]) radius = 0.5 * (reference_params["maximum"] - reference_params["minimum"])
y_max = np.sqrt(radius ** 2 - x ** 2) y_max = np.sqrt(radius**2 - x**2)
return dict(minimum=-y_max, maximum=y_max) return dict(minimum=-y_max, maximum=y_max)
def condition_func_z(reference_params, x, y): def condition_func_z(reference_params, x, y):
"""Condition function for our p(z|x, y) prior.""" """Condition function for our p(z|x, y) prior."""
radius = 0.5 * (reference_params["maximum"] - reference_params["minimum"]) radius = 0.5 * (reference_params["maximum"] - reference_params["minimum"])
z_max = np.sqrt(radius ** 2 - x ** 2 - y ** 2) z_max = np.sqrt(radius**2 - x**2 - y**2)
return dict(minimum=-z_max, maximum=z_max) return dict(minimum=-z_max, maximum=z_max)
......
...@@ -39,7 +39,7 @@ class SimpleGaussianLikelihood(bilby.Likelihood): ...@@ -39,7 +39,7 @@ class SimpleGaussianLikelihood(bilby.Likelihood):
sigma = self.parameters["sigma"] sigma = self.parameters["sigma"]
res = self.data - mu res = self.data - mu
return -0.5 * ( return -0.5 * (
np.sum((res / sigma) ** 2) + self.N * np.log(2 * np.pi * sigma ** 2) np.sum((res / sigma) ** 2) + self.N * np.log(2 * np.pi * sigma**2)
) )
......
...@@ -78,8 +78,8 @@ fig2.savefig("outdir/hyper_parameter_combined_posteriors.png") ...@@ -78,8 +78,8 @@ fig2.savefig("outdir/hyper_parameter_combined_posteriors.png")
def hyper_prior(dataset, mu, sigma): def hyper_prior(dataset, mu, sigma):
return ( return (
np.exp(-((dataset["c0"] - mu) ** 2) / (2 * sigma ** 2)) np.exp(-((dataset["c0"] - mu) ** 2) / (2 * sigma**2))
/ (2 * np.pi * sigma ** 2) ** 0.5 / (2 * np.pi * sigma**2) ** 0.5
) )
......
...@@ -85,7 +85,7 @@ class Polynomial(bilby.Likelihood): ...@@ -85,7 +85,7 @@ class Polynomial(bilby.Likelihood):
res = self.y - self.polynomial(self.x, self.parameters) res = self.y - self.polynomial(self.x, self.parameters)
return -0.5 * ( return -0.5 * (
np.sum((res / self.sigma) ** 2) np.sum((res / self.sigma) ** 2)
+ self.N * np.log(2 * np.pi * self.sigma ** 2) + self.N * np.log(2 * np.pi * self.sigma**2)
) )
......
...@@ -27,8 +27,8 @@ bilby.utils.check_directory_exists_and_if_not_mkdir(outdir) ...@@ -27,8 +27,8 @@ bilby.utils.check_directory_exists_and_if_not_mkdir(outdir)
def gaussian(xs, amplitude, mu, sigma): def gaussian(xs, amplitude, mu, sigma):
return ( return (
amplitude amplitude
/ np.sqrt(2 * np.pi * sigma ** 2) / np.sqrt(2 * np.pi * sigma**2)
* np.exp(-0.5 * (xs - mu) ** 2 / sigma ** 2) * np.exp(-0.5 * (xs - mu) ** 2 / sigma**2)
) )
......
...@@ -26,10 +26,14 @@ gw_args = [(fname.split("/")[-1][:-3], fname) for fname in gw_examples] ...@@ -26,10 +26,14 @@ gw_args = [(fname.split("/")[-1][:-3], fname) for fname in gw_examples]
def _execute_file(name, fname): def _execute_file(name, fname):
print("Running {}".format(fname)) dname, fname = os.path.split(fname)
old_directory = os.getcwd()
os.chdir(dname)
print(f"Running {fname} from {dname}")
spec = importlib.util.spec_from_file_location(name, fname) spec = importlib.util.spec_from_file_location(name, fname)
foo = importlib.util.module_from_spec(spec) foo = importlib.util.module_from_spec(spec)
spec.loader.exec_module(foo) spec.loader.exec_module(foo)
os.chdir(old_directory)
class ExampleTest(unittest.TestCase): class ExampleTest(unittest.TestCase):
......
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