Skip to content

Commit 18ceae8

Browse files
added function that checks if multinest has finished
1 parent 73fb5c6 commit 18ceae8

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

pymultinest/run.py

+19
Original file line numberDiff line numberDiff line change
@@ -241,4 +241,23 @@ def dumper(nSamples,nlive,nPar,
241241
c_int(context))
242242
signal.signal(signal.SIGINT, prev_handler)
243243

244+
def _is_newer(filea, fileb):
245+
return os.stat(filea).st_mtime > os.stat(fileb).st_mtime
246+
def multinest_complete(outputfiles_basename = "chains/1-"):
247+
"""
248+
Checks the output files of multinest to see if they are complete.
249+
This also requires the presence of params.json, which your code should
250+
write after calling run()
251+
252+
returns True or False
253+
"""
254+
names = ['stats.dat', 'post_equal_weights.dat', '.txt', 'resume.dat', 'params.json']
255+
for n in names:
256+
if not os.path.exists(basename + n):
257+
return False
258+
# if stats.dat and post_equal_weights.dat are newer than .txt and resume.dat exists
259+
if not _is_newer(basename + 'post_equal_weights.dat', basename + '.txt'):
260+
return False
261+
return True
262+
244263

0 commit comments

Comments
 (0)