Skip to content

FIX: Cube samples in new interface #123

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
:target: https://arxiv.org/abs/1506.00171
:alt: Open-access paper

PolyChord v 1.22.1
PolyChord v 1.22.2

Will Handley, Mike Hobson & Anthony Lasenby

Expand Down
2 changes: 1 addition & 1 deletion pypolychord/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
__version__ = "1.22.1"
__version__ = "1.22.2"
from pypolychord.settings import PolyChordSettings
from pypolychord.polychord import run_polychord, run
14 changes: 6 additions & 8 deletions pypolychord/polychord.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,7 @@ def run(loglikelihood, nDims, **kwargs):
'grade_dims': [nDims],
'nlives': {},
'seed': -1,
'cube_samples': None,
}
default_kwargs['grade_frac'] = ([1.0]*len(default_kwargs['grade_dims'])
if 'grade_dims' not in kwargs else
Expand All @@ -573,10 +574,10 @@ def run(loglikelihood, nDims, **kwargs):
(kwargs['file_root'] + ".paramnames"))


if 'cube_samples' in kwargs:
_make_resume_file(loglikelihood, kwargs['prior'], **kwargs)
read_resume = kwargs['read_resume']
kwargs['read_resume'] = True
read_resume = kwargs['read_resume']
if kwargs['cube_samples'] is not None:
_make_resume_file(loglikelihood, **kwargs)
read_resume = True

def wrap_loglikelihood(theta, phi):
logL = loglikelihood(theta)
Expand Down Expand Up @@ -617,7 +618,7 @@ def wrap_prior(cube, theta):
kwargs['cluster_posteriors'],
kwargs['write_resume'],
kwargs['write_paramnames'],
kwargs['read_resume'],
read_resume,
kwargs['write_stats'],
kwargs['write_live'],
kwargs['write_dead'],
Expand All @@ -633,9 +634,6 @@ def wrap_prior(cube, theta):
kwargs['seed'],
)

if 'cube_samples' in kwargs:
kwargs['read_resume'] = read_resume

try:
import anesthetic
except ImportError:
Expand Down
4 changes: 2 additions & 2 deletions src/polychord/feedback.f90
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ subroutine write_opening_statement(settings)
write(stdout_unit,'("")')
write(stdout_unit,'("PolyChord: Next Generation Nested Sampling")')
write(stdout_unit,'("copyright: Will Handley, Mike Hobson & Anthony Lasenby")')
write(stdout_unit,'(" version: 1.22.1")')
write(stdout_unit,'(" release: 10th Jan 2024")')
write(stdout_unit,'(" version: 1.22.2")')
write(stdout_unit,'(" release: 27th Sep 2024")')
write(stdout_unit,'(" email: [email protected]")')
write(stdout_unit,'("")')
end if
Expand Down
11 changes: 10 additions & 1 deletion tests/test_run_pypolychord.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def test_run(likelihood, nDims, nDerived):

ns = pypolychord.run(likelihood, nDims, nDerived=nDerived,
prior=uniform_prior, paramnames=paramnames,
read_resume=False)
read_resume=False, feedback=0)
assert isinstance(ns, ac.NestedSamples)


Expand Down Expand Up @@ -128,3 +128,12 @@ def test_grade_dims():
pypolychord.run(gaussian_likelihood, 5, nDerived=1,
prior=uniform_prior, read_resume=False,
grade_dims=grade_dims)


def test_cube_samples():
cube_samples = np.array([[0.1, 0.2, 0.3, 0.4],
[0.5, 0.6, 0.7, 0.8]])
pypolychord.run(gaussian_likelihood, 4, nDerived=1,
prior=uniform_prior,
read_resume=False,
cube_samples=cube_samples)
Loading