Skip to content
Snippets Groups Projects

Bugfix Slabspike Sampling

Merged Rhiannon Udall requested to merge rhiannon.udall/bilby:bugfix-slabspike into master
All threads resolved!

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).

Edited by Rhiannon Udall

Merge request reports

Pipeline #507083 passed

Pipeline passed for 3e7f6b74 on rhiannon.udall:bugfix-slabspike

Test coverage 68.00% (0.00%) from 1 job
Approval is optional

Merged by Gregory AshtonGregory Ashton 2 years ago (Apr 7, 2023 8:18am UTC)

Merge details

  • Changes merged into master with c07e51d4 (commits were squashed).
  • Deleted the source branch.

Pipeline #513393 failed

Pipeline failed for c07e51d4 on master

Test coverage 68.00% (0.00%) from 1 job

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Hi @rhiannon.udall thanks for fixing this! I just added a small suggestion.

  • Rhiannon Udall resolved all threads

    resolved all threads

  • Rhiannon Udall added 1 commit

    added 1 commit

    • 3e7f6b74 - Remove dangerous assertion, type on numbers.Number, use a try except block, apply to more functions

    Compare with previous version

  • 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.

  • Colm Talbot changed milestone to %2.1.0

    changed milestone to %2.1.0

  • Gregory Ashton changed milestone to %2.0.3

    changed milestone to %2.0.3

  • Colm Talbot approved this merge request

    approved this merge request

  • added <10 lines label

  • Gregory Ashton approved this merge request

    approved this merge request

  • Gregory Ashton mentioned in commit c07e51d4

    mentioned in commit c07e51d4

  • Colm Talbot picked the changes into the branch release/2.0.x with commit 236165f9

    picked the changes into the branch release/2.0.x with commit 236165f9

  • Gregory Ashton mentioned in commit 236165f9

    mentioned in commit 236165f9

  • Gregory Ashton changed milestone to %2.1.0

    changed milestone to %2.1.0

  • Please register or sign in to reply
    Loading