Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into test
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamOrmondroyd committed Jan 9, 2024
2 parents 65a2808 + bd24bc7 commit 09140c7
Show file tree
Hide file tree
Showing 9 changed files with 85 additions and 316 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.20.2
PolyChord v 1.21.3

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.20.2"
__version__ = "1.21.3"
from pypolychord.settings import PolyChordSettings
from pypolychord.polychord import run_polychord
22 changes: 15 additions & 7 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 All @@ -250,16 +258,16 @@ def make_resume_file(settings, loglikelihood, prior):
sendbuf = np.array(lives).flatten()
sendcounts = np.array(comm.gather(len(sendbuf)))
if rank == 0:
recvbuf = np.empty(sum(sendcounts), dtype=int)
recvbuf = np.empty(sum(sendcounts))
else:
recvbuf = None
comm.Gatherv(sendbuf=sendbuf, recvbuf=(recvbuf, sendcounts), root=0)

lives = np.reshape(sendbuf, (len(settings.cube_samples), len(lives[0])))
else:
lives = np.array(lives)

if rank == 0:
if MPI:
lives = np.reshape(recvbuf, (len(settings.cube_samples), len(lives[0])))
else:
lives = np.array(lives)
with open(resume_filename,"w") as f:
def write(var):
var = np.atleast_1d(var)
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.20.2")')
write(stdout_unit,'(" release: 1st June 2021")')
write(stdout_unit,'(" version: 1.21.3")')
write(stdout_unit,'(" release: 9th Jan 2024")')
write(stdout_unit,'(" email: wh260@mrao.cam.ac.uk")')
write(stdout_unit,'("")')
end if
Expand Down
Loading

0 comments on commit 09140c7

Please sign in to comment.