Skip to content
Snippets Groups Projects

Resolve #430 (Add normalisation flag to constrained prior)

Merged Bruce Edelman requested to merge bruce.edelman/bilby:constraint into master

This MR resolves issue #430 (closed) to properly normalize ConstrainedPriorDict.prob() when sampling the prior. This MR allows for users to input a normalisation flag when creating an instance of a Constraint prior and when calling ConstrainedPriorDict.prob() if there are normalisation constants given will return the normalisation*prob and otherwise use the ratio of total samples to kept samples as this normalisation constant. Pass normalisation=1 when creating a Constraint Prior for behaviour before this MR.

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Bruce Edelman resolved all threads

    resolved all threads

  • Bruce Edelman resolved all threads

    resolved all threads

  • Bruce Edelman added 1 commit

    added 1 commit

    • 3f71d89d - remove unnecessary checks for constraints

    Compare with previous version

    • Resolved by Colm Talbot

      @colm.talbot, I am having trouble with the caching as implemented here. To cache the ratio the arguments which are the list of keys to evaluate prob over, and self, both need to be hashable to be used as keys in the cache dict. However, python dicts are not hashable, so it does not like having reference to self(PriorDict) in the cached method. I found a workaround to make a hashable dictionary here https://stackoverflow.com/questions/1151658/python-hashable-dicts but it does mention that this will not work if the dictionary needs to be mutable after being set as a key for the cache.

      Do you have ideas on this and maybe the best way to cache this? The necessary keys for our caching dict need to include the details of the PriorDict of course since different bounds on parameters will affect this. This is also complicated since the cached method uses other methods of the PriorDict..

      Edited by Bruce Edelman
  • Bruce Edelman added 2 commits

    added 2 commits

    • 8d340cc2 - tried making PriorDict Hashable
    • debf73ee - made PriorDict hashable and fixed caching

    Compare with previous version

  • Bruce Edelman added 1 commit

    added 1 commit

    • 1b781bd0 - changed lru_cache to be functools not methodtools version

    Compare with previous version

  • Bruce Edelman added 1 commit

    added 1 commit

    • f74f85fa - remove old commented out print statement

    Compare with previous version

  • Bruce Edelman added 1 commit

    added 1 commit

    • 5b1a5778 - change from lru_cached to just a plain dictionary approach for ease of application

    Compare with previous version

  • Bruce Edelman added 1 commit

    added 1 commit

    • d1a295c4 - changed from repr to tuple to convert list to something that can be used as a...

    Compare with previous version

  • Bruce Edelman added 1 commit

    added 1 commit

    • 6b64ce09 - remove redundant tuple conversions

    Compare with previous version

  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Please register or sign in to reply
    Loading