diff --git a/bilby/core/sampler/dynesty.py b/bilby/core/sampler/dynesty.py index adc28f84922f5ef32b7a7b3a8fc78bb24a2bd04a..bad9636bee98a2981a7388e24f8bfbbf7ce05a7e 100644 --- a/bilby/core/sampler/dynesty.py +++ b/bilby/core/sampler/dynesty.py @@ -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) diff --git a/requirements.txt b/requirements.txt index c3bf8ebb8cd090bad2f14fb49ae7620aec7cb436..99b3eedbbf9e86b09300ce89e8b466e824c62536 100644 --- a/requirements.txt +++ b/requirements.txt @@ -11,4 +11,4 @@ tqdm h5py tables astropy -attrs +attrs \ No newline at end of file diff --git a/test/check_author_list.py b/test/check_author_list.py index c43f0f0030d657148ec5991faf807bac6b4192ca..98352318a503eb588b566d6b6b368e24caa5f1d9 100644 --- a/test/check_author_list.py +++ b/test/check_author_list.py @@ -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: