Skip to content
Snippets Groups Projects
Commit ccf3f4a2 authored by Gregory Ashton's avatar Gregory Ashton
Browse files

Merge branch 'nestcheck-bilby' into 'master'

Nestcheck test

See merge request !1005
parents 30fb4f9a e1a4e86d
No related branches found
No related tags found
1 merge request!1005Nestcheck test
Pipeline #298554 passed
......@@ -148,7 +148,8 @@ class Dynesty(NestedSampler):
def __init__(self, likelihood, priors, outdir='outdir', label='label',
use_ratio=False, plot=False, skip_import_verification=False,
check_point=True, check_point_plot=True, n_check_point=None,
check_point_delta_t=600, resume=True, exit_code=130, **kwargs):
check_point_delta_t=600, resume=True, nestcheck=False, exit_code=130, **kwargs):
super(Dynesty, self).__init__(likelihood=likelihood, priors=priors,
outdir=outdir, label=label, use_ratio=use_ratio,
plot=plot, skip_import_verification=skip_import_verification,
......@@ -162,6 +163,8 @@ class Dynesty(NestedSampler):
self._reflective = list()
self._apply_dynesty_boundaries()
self.nestcheck = nestcheck
if self.n_check_point is None:
self.n_check_point = 1000
self.check_point_delta_t = check_point_delta_t
......@@ -302,6 +305,14 @@ class Dynesty(NestedSampler):
self.kwargs["periodic"] = self._periodic
self.kwargs["reflective"] = self._reflective
def nestcheck_data(self, out_file):
import nestcheck.data_processing
import pickle
ns_run = nestcheck.data_processing.process_dynesty_run(out_file)
nestcheck_result = "{}/{}_nestcheck.pickle".format(self.outdir, self.label)
with open(nestcheck_result, 'wb') as file_nest:
pickle.dump(ns_run, file_nest)
def _setup_pool(self):
if self.kwargs["pool"] is not None:
logger.info("Using user defined pool.")
......@@ -396,6 +407,10 @@ class Dynesty(NestedSampler):
print("")
check_directory_exists_and_if_not_mkdir(self.outdir)
if self.nestcheck:
self.nestcheck_data(out)
dynesty_result = "{}/{}_dynesty.pickle".format(self.outdir, self.label)
with open(dynesty_result, 'wb') as file:
dill.dump(out, file)
......
......@@ -11,4 +11,4 @@ tqdm
h5py
tables
astropy
attrs
attrs
\ No newline at end of file
......@@ -14,10 +14,26 @@ lines = subprocess.check_output(["git", "shortlog", "HEAD", "-sn"]).decode("utf-
if len(lines) == 0:
raise Exception("No authors to check against")
def remove_accents(raw_text):
raw_text = re.sub(u"[àáâãäå]", 'a', raw_text)
raw_text = re.sub(u"[èéêë]", 'e', raw_text)
raw_text = re.sub(u"[ìíîï]", 'i', raw_text)
raw_text = re.sub(u"[òóôõö]", 'o', raw_text)
raw_text = re.sub(u"[ùúûü]", 'u', raw_text)
raw_text = re.sub(u"[ýÿ]", 'y', raw_text)
raw_text = re.sub(u"[ß]", 'ss', raw_text)
raw_text = re.sub(u"[ñ]", 'n', raw_text)
return(raw_text)
fail_test = False
for line in lines:
line = line.replace(".", " ")
line = re.sub('([A-Z][a-z]+)', r' \1', re.sub('([A-Z]+)', r' \1', line))
line = remove_accents(line)
for element in line.split()[1:]:
element = element.lower()
if element not in AUTHORS_list and element not in special_cases:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment