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
38cd6d54
Commit
38cd6d54
authored
6 years ago
by
Colm Talbot
Committed by
Moritz Huebner
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
fix the emcee writing to file for the prerelease
parent
3e1a47e3
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bilby/core/sampler/emcee.py
+11
-7
11 additions, 7 deletions
bilby/core/sampler/emcee.py
with
11 additions
and
7 deletions
bilby/core/sampler/emcee.py
+
11
−
7
View file @
38cd6d54
...
...
@@ -51,6 +51,11 @@ class Emcee(MCMCSampler):
use_ratio
=
False
,
plot
=
False
,
skip_import_verification
=
False
,
pos0
=
None
,
nburn
=
None
,
burn_in_fraction
=
0.25
,
resume
=
True
,
burn_in_act
=
3
,
**
kwargs
):
import
emcee
if
LooseVersion
(
emcee
.
__version__
)
>
LooseVersion
(
'
2.2.1
'
):
self
.
prerelease
=
True
else
:
self
.
prerelease
=
False
MCMCSampler
.
__init__
(
self
,
likelihood
=
likelihood
,
priors
=
priors
,
outdir
=
outdir
,
label
=
label
,
use_ratio
=
use_ratio
,
plot
=
plot
,
...
...
@@ -82,7 +87,6 @@ class Emcee(MCMCSampler):
@property
def
sampler_function_kwargs
(
self
):
import
emcee
keys
=
[
'
lnprob0
'
,
'
rstate0
'
,
'
blobs0
'
,
'
iterations
'
,
'
thin
'
,
'
storechain
'
,
'
mh_proposal
'
]
# updated function keywords for emcee > v2.2.1
...
...
@@ -93,7 +97,7 @@ class Emcee(MCMCSampler):
function_kwargs
=
{
key
:
self
.
kwargs
[
key
]
for
key
in
keys
if
key
in
self
.
kwargs
}
function_kwargs
[
'
p0
'
]
=
self
.
pos0
if
LooseVersion
(
emcee
.
__version__
)
>
LooseVersion
(
'
2.2.1
'
)
:
if
self
.
prerelease
:
if
function_kwargs
[
'
mh_proposal
'
]
is
not
None
:
logger
.
warning
(
"
The
'
mh_proposal
'
option is no longer used
"
"
in emcee v{}, and will be ignored.
"
.
format
(
emcee
.
__version__
))
...
...
@@ -109,8 +113,6 @@ class Emcee(MCMCSampler):
@property
def
sampler_init_kwargs
(
self
):
import
emcee
init_kwargs
=
{
key
:
value
for
key
,
value
in
self
.
kwargs
.
items
()
if
key
not
in
self
.
sampler_function_kwargs
}
...
...
@@ -122,7 +124,7 @@ class Emcee(MCMCSampler):
updatekeys
=
{
'
dim
'
:
'
ndim
'
,
'
lnpostfn
'
:
'
log_prob_fn
'
}
if
LooseVersion
(
emcee
.
__version__
)
>
LooseVersion
(
'
2.2.1
'
)
:
if
self
.
prerelease
:
for
key
in
updatekeys
:
if
key
in
init_kwargs
:
init_kwargs
[
updatekeys
[
key
]]
=
init_kwargs
.
pop
(
key
)
...
...
@@ -193,8 +195,10 @@ class Emcee(MCMCSampler):
for
sample
in
tqdm
(
sampler
.
sample
(
**
self
.
sampler_function_kwargs
),
total
=
self
.
nsteps
):
points
=
np
.
hstack
([
sample
[
0
],
np
.
array
(
sample
[
3
])])
# import IPython; IPython.embed()
if
self
.
prerelease
:
points
=
np
.
hstack
([
sample
.
coords
,
sample
.
blobs
])
else
:
points
=
np
.
hstack
([
sample
[
0
],
np
.
array
(
sample
[
3
])])
with
open
(
out_file
,
"
a
"
)
as
ff
:
for
ii
,
point
in
enumerate
(
points
):
ff
.
write
(
template
.
format
(
ii
,
*
point
))
...
...
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