Bugfix Slabspike Sampling
I found that when calling .sample() with no argument for SlabSpikePrior, it returned an array with one element. This is different from other priors, which just return a float or int.
That is
test = SlabSpike(bilby.core.prior.Uniform(-1, 1, "test"), spike_location=None, spike_height=0.5)
test.sample()
should return a float between -1 and 1, but was instead returning an array whose only element was that float.
This fixes that by checking the original type and, if it is not an array, takes instead the element of the output array (after also checking said output has only one element, as it should).
Merge request reports
Activity
- Automatically resolved by Rhiannon Udall
Hi @rhiannon.udall thanks for fixing this! I just added a small suggestion.
added 1 commit
- 3e7f6b74 - Remove dangerous assertion, type on numbers.Number, use a try except block, apply to more functions
Hi @colm.talbot - thank you for the feedback! These are good points: I've gotten rid of the assert (switching it to a try-except that should leave the result unchanged if it can't get the element correctly), and typed on numbers.Number now.
I also realized from further testing that the same issue was showing up in prop() and ln_prob(), so I applied the same fixes there.
changed milestone to %2.1.0
changed milestone to %2.0.3
added <10 lines label
mentioned in commit c07e51d4
picked the changes into the branch
release/2.0.x
with commit 236165f9mentioned in commit 236165f9
changed milestone to %2.1.0