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
50b4c66f
Commit
50b4c66f
authored
3 years ago
by
Colm Talbot
Committed by
Moritz Huebner
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Allow ptemcee initialization with array
parent
678c4032
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!955
Allow ptemcee initialization with array
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bilby/core/sampler/ptemcee.py
+17
-2
17 additions, 2 deletions
bilby/core/sampler/ptemcee.py
with
17 additions
and
2 deletions
bilby/core/sampler/ptemcee.py
+
17
−
2
View file @
50b4c66f
...
...
@@ -92,13 +92,15 @@ class Ptemcee(MCMCSampler):
is not recommended for cases where tau is large.
ignore_keys_for_tau: str
A pattern used to ignore keys in estimating the autocorrelation time.
pos0: str, list
(
"
prior
"
)
pos0: str, list
, np.ndarray
If a string, one of
"
prior
"
or
"
minimize
"
. For
"
prior
"
, the initial
positions of the sampler are drawn from the sampler. If
"
minimize
"
,
a scipy.optimize step is applied to all parameters a number of times.
The walkers are then initialized from the range of values obtained.
If a list, for the keys in the list the optimization step is applied,
otherwise the initial points are drawn from the prior.
otherwise the initial points are drawn from the prior. If a numpy array
the shape should be (ntemps, nwalkers, ndim).
niterations_per_check: int (5)
The number of iteration steps to take before checking ACT. This
effectively pre-thins the chains. Larger values reduce the per-eval
...
...
@@ -363,6 +365,17 @@ class Ptemcee(MCMCSampler):
)
return
pos0
def
get_pos0_from_array
(
self
):
if
self
.
pos0
.
shape
!=
(
self
.
ntemps
,
self
.
nwalkers
,
self
.
ndim
):
raise
ValueError
(
"
Shape of starting array should be (ntemps, nwalkers, ndim).
"
"
In this case that is ({}, {}, {}), got {}
"
.
format
(
self
.
ntemps
,
self
.
nwalkers
,
self
.
ndim
,
self
.
pos0
.
shape
)
)
else
:
return
self
.
pos0
def
setup_sampler
(
self
):
"""
Either initialize the sampler or read in the resume file
"""
import
ptemcee
...
...
@@ -446,6 +459,8 @@ class Ptemcee(MCMCSampler):
return
self
.
get_pos0_from_minimize
()
elif
isinstance
(
self
.
pos0
,
list
):
return
self
.
get_pos0_from_minimize
(
minimize_list
=
self
.
pos0
)
elif
isinstance
(
self
.
pos0
,
np
.
ndarray
):
return
self
.
get_pos0_from_array
()
else
:
raise
SamplerError
(
"
pos0={} not implemented
"
.
format
(
self
.
pos0
))
...
...
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