Skip to content

Commit

Permalink
loglikelihood without derived parameters (#110)
Browse files Browse the repository at this point in the history
* actually allow loglikelihood to return just logL and no derived parameters

* missing space

* version bump

* remove seed used for testing

* finish version bump (fingers crossed)
  • Loading branch information
AdamOrmondroyd authored Jan 9, 2024
1 parent 0d0c47e commit 370b70a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
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.21.1
PolyChord v 1.21.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.21.1"
__version__ = "1.21.2"
from pypolychord.settings import PolyChordSettings
from pypolychord.polychord import run_polychord
12 changes: 10 additions & 2 deletions pypolychord/polychord.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,11 @@ def run_polychord(loglikelihood, nDims, nDerived, settings,
settings.read_resume=True

def wrap_loglikelihood(theta, phi):
logL, phi[:] = loglikelihood(theta)
logL = loglikelihood(theta)
try:
logL, phi[:] = logL
except TypeError:
pass
return logL

def wrap_prior(cube, theta):
Expand Down Expand Up @@ -241,7 +245,11 @@ def make_resume_file(settings, loglikelihood, prior):
for i in np.array_split(np.arange(len(settings.cube_samples)), size)[rank]:
cube = settings.cube_samples[i]
theta = prior(cube)
logL, derived = loglikelihood(theta)
logL = loglikelihood(theta)
try:
logL, derived = logL
except TypeError:
derived = []
nDims = len(theta)
nDerived = len(derived)
lives.append(np.concatenate([cube,theta,derived,[logL_birth, logL]]))
Expand Down
2 changes: 1 addition & 1 deletion src/polychord/feedback.f90
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ 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.21.1")')
write(stdout_unit,'(" version: 1.21.2")')
write(stdout_unit,'(" release: 9th Jan 2024")')
write(stdout_unit,'(" email: wh260@mrao.cam.ac.uk")')
write(stdout_unit,'("")')
Expand Down

0 comments on commit 370b70a

Please sign in to comment.