Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bilby
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
lscsoft
bilby
Commits
debf73ee
Commit
debf73ee
authored
5 years ago
by
Bruce Edelman
Browse files
Options
Downloads
Patches
Plain Diff
made PriorDict hashable and fixed caching
parent
8d340cc2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!704
Resolve #430 (Add normalisation flag to constrained prior)
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bilby/core/prior/dict.py
+11
-6
11 additions, 6 deletions
bilby/core/prior/dict.py
with
11 additions
and
6 deletions
bilby/core/prior/dict.py
+
11
−
6
View file @
debf73ee
...
...
@@ -381,15 +381,20 @@ class PriorDict(dict):
@lru_cache
()
def
normalize_constraint_factor
(
self
,
keys
):
min_accept
=
5
0
sampling_chunk
=
2
50
min_accept
=
100
0
sampling_chunk
=
50
00
samples
=
self
.
sample_subset
(
keys
=
keys
,
size
=
sampling_chunk
)
keep
=
np
.
array
(
self
.
evaluate_constraints
(
samples
))
keep
=
np
.
atleast_1d
(
self
.
evaluate_constraints
(
samples
))
if
len
(
keep
)
==
1
:
return
1
all_samples
=
{
key
:
np
.
array
([])
for
key
in
keys
}
_first_key
=
list
(
all_samples
.
keys
())[
0
]
while
np
.
count_nonzero
(
keep
)
<
min_accept
:
new_
samples
=
self
.
sample_subset
(
keys
=
keys
,
size
=
sampling_chunk
)
samples
=
self
.
sample_subset
(
keys
=
keys
,
size
=
sampling_chunk
)
for
key
in
samples
:
samples
[
key
]
=
np
.
hstack
([
samples
[
key
],
new_samples
[
key
]])
keep
=
np
.
array
(
self
.
evaluate_constraints
(
samples
))
all_samples
[
key
]
=
np
.
hstack
(
[
all_samples
[
key
],
samples
[
key
].
flatten
()])
keep
=
np
.
array
(
self
.
evaluate_constraints
(
all_samples
),
dtype
=
bool
)
return
len
(
keep
)
/
np
.
count_nonzero
(
keep
)
def
prob
(
self
,
sample
,
**
kwargs
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment