Skip to content
Snippets Groups Projects
Commit 49ad2186 authored by Gregory Ashton's avatar Gregory Ashton
Browse files

Adds a check if the prior is set when using marg. likel.

If the prior is not given to the likelihood when using the marginalized
likelihood, marginalization cannot be safely performed. This adds a
check and raises a ValueError if it is not set.

Closes #88
parent a86210ce
No related branches found
No related tags found
No related merge requests found
......@@ -64,6 +64,7 @@ class GravitationalWaveTransient(likelihood.Likelihood):
self.prior = prior
if self.distance_marginalization:
self.check_prior_is_set()
self.distance_array = np.array([])
self.delta_distance = 0
self.distance_prior_array = np.array([])
......@@ -71,10 +72,18 @@ class GravitationalWaveTransient(likelihood.Likelihood):
prior['luminosity_distance'] = 1 # this means the prior is a delta function fixed at the RHS value
if self.phase_marginalization:
self.check_prior_is_set()
self.bessel_function_interped = None
self.setup_phase_marginalization()
prior['phase'] = 0
if self.time_marginalization:
self.check_prior_is_set()
def check_prior_is_set(self):
if self.prior is None:
raise ValueError("You can't use a marginalized likelihood without specifying a prior")
@property
def prior(self):
return self.__prior
......
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