Skip to content

Commit ceb0baf

Browse files
Merge pull request #123 from AdamOrmondroyd/cube_samples
FIX: Cube samples in new interface
2 parents 1f75b71 + 9f138b9 commit ceb0baf

5 files changed

Lines changed: 20 additions & 13 deletions

File tree

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
:target: https://arxiv.org/abs/1506.00171
66
:alt: Open-access paper
77

8-
PolyChord v 1.22.2
8+
PolyChord v 1.22.3
99

1010
Will Handley, Mike Hobson & Anthony Lasenby
1111

pypolychord/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
__version__ = "1.22.2"
1+
__version__ = "1.22.3"
22
from pypolychord.settings import PolyChordSettings
33
from pypolychord.polychord import run_polychord, run

pypolychord/polychord.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,7 @@ def run(loglikelihood, nDims, **kwargs):
552552
'grade_dims': [nDims],
553553
'nlives': {},
554554
'seed': -1,
555+
'cube_samples': None,
555556
}
556557
default_kwargs['grade_frac'] = ([1.0]*len(default_kwargs['grade_dims'])
557558
if 'grade_dims' not in kwargs else
@@ -573,10 +574,10 @@ def run(loglikelihood, nDims, **kwargs):
573574
(kwargs['file_root'] + ".paramnames"))
574575

575576

576-
if 'cube_samples' in kwargs:
577-
_make_resume_file(loglikelihood, kwargs['prior'], **kwargs)
578-
read_resume = kwargs['read_resume']
579-
kwargs['read_resume'] = True
577+
read_resume = kwargs['read_resume']
578+
if kwargs['cube_samples'] is not None:
579+
_make_resume_file(loglikelihood, **kwargs)
580+
read_resume = True
580581

581582
def wrap_loglikelihood(theta, phi):
582583
logL = loglikelihood(theta)
@@ -617,7 +618,7 @@ def wrap_prior(cube, theta):
617618
kwargs['cluster_posteriors'],
618619
kwargs['write_resume'],
619620
kwargs['write_paramnames'],
620-
kwargs['read_resume'],
621+
read_resume,
621622
kwargs['write_stats'],
622623
kwargs['write_live'],
623624
kwargs['write_dead'],
@@ -633,9 +634,6 @@ def wrap_prior(cube, theta):
633634
kwargs['seed'],
634635
)
635636

636-
if 'cube_samples' in kwargs:
637-
kwargs['read_resume'] = read_resume
638-
639637
try:
640638
import anesthetic
641639
except ImportError:

src/polychord/feedback.f90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ subroutine write_opening_statement(settings)
2828
write(stdout_unit,'("")')
2929
write(stdout_unit,'("PolyChord: Next Generation Nested Sampling")')
3030
write(stdout_unit,'("copyright: Will Handley, Mike Hobson & Anthony Lasenby")')
31-
write(stdout_unit,'(" version: 1.22.2")')
32-
write(stdout_unit,'(" release: 10th Jan 2024")')
31+
write(stdout_unit,'(" version: 1.22.3")')
32+
write(stdout_unit,'(" release: 22nd Nov 2025")')
3333
write(stdout_unit,'(" email: wh260@mrao.cam.ac.uk")')
3434
write(stdout_unit,'("")')
3535
end if

tests/test_run_pypolychord.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def test_run(likelihood, nDims, nDerived):
7070

7171
ns = pypolychord.run(likelihood, nDims, nDerived=nDerived,
7272
prior=uniform_prior, paramnames=paramnames,
73-
read_resume=False)
73+
read_resume=False, feedback=0)
7474
assert isinstance(ns, ac.NestedSamples)
7575

7676

@@ -128,3 +128,12 @@ def test_grade_dims():
128128
pypolychord.run(gaussian_likelihood, 5, nDerived=1,
129129
prior=uniform_prior, read_resume=False,
130130
grade_dims=grade_dims)
131+
132+
133+
def test_cube_samples():
134+
cube_samples = np.array([[0.1, 0.2, 0.3, 0.4],
135+
[0.5, 0.6, 0.7, 0.8]])
136+
pypolychord.run(gaussian_likelihood, 4, nDerived=1,
137+
prior=uniform_prior,
138+
read_resume=False,
139+
cube_samples=cube_samples)

0 commit comments

Comments
 (0)