From 3f71d89d02745f32a835256b57c66bb53acd6c71 Mon Sep 17 00:00:00 2001 From: Bruce Edelman <bruce.edelman@ligo.org> Date: Tue, 18 Feb 2020 09:33:39 -0800 Subject: [PATCH] remove unnecessary checks for constraints --- bilby/core/prior/dict.py | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/bilby/core/prior/dict.py b/bilby/core/prior/dict.py index 97c613225..732bcf149 100644 --- a/bilby/core/prior/dict.py +++ b/bilby/core/prior/dict.py @@ -410,14 +410,7 @@ class PriorDict(dict): prob = np.product([self[key].prob(sample[key]) for key in sample], **kwargs) - ratio = 1 - 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()], Constraint))): - # If constraint exists in keys, caclulate the cached normalization constant - ratio = self.normalize_constraint_factor(sample.keys()) - + ratio = self.normalize_constraint_factor(sample.keys()) if np.all(prob == 0.): return prob else: @@ -451,14 +444,7 @@ class PriorDict(dict): ln_prob = np.sum([self[key].ln_prob(sample[key]) for key in sample], axis=axis) - ratio = 1 - 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()], Constraint))): - # If constraint exists in keys, caclulate the cached normalization constant - ratio = self.normalize_constraint_factor(sample.keys()) - + ratio = self.normalize_constraint_factor(sample.keys()) if np.all(np.isinf(ln_prob)): return ln_prob else: -- GitLab