Skip to content
Snippets Groups Projects

Resolve #430 (Add normalisation flag to constrained prior)

Merged Resolve #430 (Add normalisation flag to constrained prior)
All threads resolved!
Merged Bruce Edelman requested to merge bruce.edelman/bilby:constraint into master
All threads resolved!
1 file
+ 6
2
Compare changes
  • Side-by-side
  • Inline
+ 6
2
@@ -404,7 +404,11 @@ class PriorDict(dict):
for key in sample], **kwargs)
ratio = 1
if np.any(isinstance([self[key] for key in sample], Constraint)):
outsample = self.conversion_function(sample)
# Check if there is a constraint in sample/outsample
if (np.any(isinstance([self[key] for key in sample.keys()], Constraint)) or
np.any(isinstance([self[key] for key in outsample.keys()]))):
# If constraint exists in keys, caclulate the cached normalization constant
ratio = self.normalize_constraint_factor(sample.keys())
if np.all(prob == 0.):
@@ -418,7 +422,7 @@ class PriorDict(dict):
else:
constrained_prob = np.zeros_like(prob)
keep = np.array(self.evaluate_constraints(sample), dtype=bool)
constrained_prob[keep] = prob[keep]*ratio
constrained_prob[keep] = prob[keep] * ratio
return constrained_prob
def ln_prob(self, sample, axis=None):
Loading