MAINT: tweaks to prior constraints#1096
Conversation
|
I think we may need to have an option where this doesn't raise an error since it is called in |
We could add this to the CBCPriorDict? |
d0a2ebf to
b0c3259
Compare
I've added |
b0c3259 to
a7e2493
Compare
ColmTalbot
left a comment
There was a problem hiding this comment.
It looks like this is a hard condition on the sample, prob, and ln_prob methods.
I don't know that the latter two are correctly handled.
For example, the following is currently valid, but I suspect will fail under this change.
Is that right?
import bilby
priors = bilby.gw.prior.BBHPriorDict
priors.ln_prob(dict(a_1=0.3, tilt_1=0.7))| def _estimate_normalization(self, keys, min_accept, sampling_chunk): | ||
| samples = self.sample_subset(keys=keys, size=sampling_chunk) | ||
| keep = np.atleast_1d(self.evaluate_constraints(samples)) | ||
| if len(keep) == 1: |
There was a problem hiding this comment.
Why has this been removed?
There was a problem hiding this comment.
My understanding was that this was a hacky check for if there aren't any constraints. Prior to #1028, evaluate_constraints would return 1.0 if there weren't any constraints, so this would skip the rest of this function.
After the changes 1028, that only happens if the sampling_chunk=1 is, so it's not clear to me this actually serves it's intended purpose.
Looking at this again, I think the lines above this may be redundant as well and this whole thing could be replaced with a has_constraints (or similar) property.
Yes, this fails but I think it would fail before as well since the conversion function would fail with a You raise a good point though, I had assumed |
Some tweaks to prior contraints
evaluate_constraintsreturned 1.0 if there were no valid constraints and there was a check for this where the normalization was set to 1. I've removed this for now. Alternatively we could return 1.0 if all values are true but the while should do this anyway.