Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Rhiannon Udall
bilby
Commits
ee5ac8fd
Commit
ee5ac8fd
authored
Apr 05, 2019
by
Moritz
Browse files
Fixed dynesty boundaries and moved some stuff
parent
717db707
Changes
4
Hide whitespace changes
Inline
Side-by-side
bilby/core/sampler/base_sampler.py
View file @
ee5ac8fd
...
...
@@ -416,14 +416,6 @@ class Sampler(object):
if
use_cache
is
False
:
self
.
cached_result
=
None
def
_periodic_boundaries_to_binary_list
(
self
,
keyword
):
self
.
kwargs
[
keyword
]
=
[]
for
param
,
value
in
self
.
priors
.
items
():
if
value
.
periodic_boundary
:
self
.
kwargs
[
keyword
].
append
(
1
)
else
:
self
.
kwargs
[
keyword
].
append
(
0
)
def
_log_summary_for_sampler
(
self
):
"""Print a summary of the sampler used and its kwargs"""
if
self
.
cached_result
is
None
:
...
...
bilby/core/sampler/dynesty.py
View file @
ee5ac8fd
...
...
@@ -176,7 +176,10 @@ class Dynesty(NestedSampler):
def
_apply_dynesty_boundaries
(
self
):
if
self
.
kwargs
[
'periodic'
]
is
None
:
self
.
_periodic_boundaries_to_binary_list
(
'periodic'
)
self
.
kwargs
[
'periodic'
]
=
[]
for
i
,
value
in
enumerate
(
self
.
priors
.
values
()):
if
value
.
periodic_boundary
:
self
.
kwargs
[
'periodic'
].
append
(
i
)
def
run_sampler
(
self
):
import
dynesty
...
...
bilby/core/sampler/pymultinest.py
View file @
ee5ac8fd
...
...
@@ -85,7 +85,12 @@ class Pymultinest(NestedSampler):
def
_apply_multinest_boundaries
(
self
):
if
self
.
kwargs
[
'wrapped_params'
]
is
None
:
self
.
_periodic_boundaries_to_binary_list
(
'wrapped_params'
)
self
.
kwargs
[
'wrapped_params'
]
=
[]
for
param
,
value
in
self
.
priors
.
items
():
if
value
.
periodic_boundary
:
self
.
kwargs
[
'wrapped_params'
].
append
(
1
)
else
:
self
.
kwargs
[
'wrapped_params'
].
append
(
0
)
def
run_sampler
(
self
):
import
pymultinest
...
...
test/sampler_test.py
View file @
ee5ac8fd
...
...
@@ -156,7 +156,7 @@ class TestDynesty(unittest.TestCase):
logl_max
=
np
.
inf
,
add_live
=
True
,
print_progress
=
True
,
save_bounds
=
True
,
walks
=
10
,
update_interval
=
300
,
print_func
=
'func'
)
self
.
sampler
.
kwargs
[
'print_func'
]
=
'func'
# set this manually as this is not testable otherwise
self
.
assertListEqual
([
1
,
0
],
self
.
sampler
.
kwargs
[
'periodic'
])
# Check this separately
self
.
assertListEqual
([
0
],
self
.
sampler
.
kwargs
[
'periodic'
])
# Check this separately
self
.
sampler
.
kwargs
[
'periodic'
]
=
None
# The dict comparison can't handle lists
for
key
in
self
.
sampler
.
kwargs
.
keys
():
print
(
key
)
...
...
@@ -165,7 +165,7 @@ class TestDynesty(unittest.TestCase):
self
.
assertDictEqual
(
expected
,
self
.
sampler
.
kwargs
)
def
test_translate_kwargs
(
self
):
expected
=
dict
(
bound
=
'multi'
,
sample
=
'rwalk'
,
periodic
=
[
1
,
0
],
verbose
=
True
,
expected
=
dict
(
bound
=
'multi'
,
sample
=
'rwalk'
,
periodic
=
[
0
],
verbose
=
True
,
check_point_delta_t
=
600
,
nlive
=
250
,
first_update
=
None
,
npdim
=
None
,
rstate
=
None
,
queue_size
=
None
,
pool
=
None
,
use_pool
=
None
,
live_points
=
None
,
logl_args
=
None
,
logl_kwargs
=
None
,
...
...
@@ -457,8 +457,9 @@ class TestRunningSamplers(unittest.TestCase):
self
.
likelihood
=
bilby
.
likelihood
.
GaussianLikelihood
(
self
.
x
,
self
.
y
,
self
.
model
,
self
.
sigma
)
self
.
priors
=
dict
(
m
=
bilby
.
core
.
prior
.
Uniform
(
0
,
5
),
c
=
bilby
.
core
.
prior
.
Uniform
(
-
2
,
2
))
self
.
priors
=
bilby
.
core
.
prior
.
PriorDict
()
self
.
priors
[
'm'
]
=
bilby
.
core
.
prior
.
Uniform
(
0
,
5
,
periodic_boundary
=
False
)
self
.
priors
[
'c'
]
=
bilby
.
core
.
prior
.
Uniform
(
-
2
,
2
,
periodic_boundary
=
False
)
bilby
.
core
.
utils
.
check_directory_exists_and_if_not_mkdir
(
'outdir'
)
def
tearDown
(
self
):
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment