From 30228db238ca3816a9124fecbbd7a120dd08cd4d Mon Sep 17 00:00:00 2001 From: Avi Vajpeyi <avi.vajpeyi@ligo.org> Date: Mon, 27 May 2019 01:58:32 -0500 Subject: [PATCH] moved the initial save of samples after the bayes factor calculation (quick calculation compared to samples_to_posterior post-processing) --- CONTRIBUTING.md | 4 ++-- bilby/core/sampler/__init__.py | 15 +++++++-------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f8c4bde71..b5cad3bcd 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -33,7 +33,7 @@ when you change the code your installed version will automatically be updated. #### Removing previously installed versions If you have previously installed `bilby` using `pip` (or generally find buggy -behaviour). It may be worthwhile purging your system and reinstalling. To do +behaviour), it may be worthwhile purging your system and reinstalling. To do this, first find out where the module is being imported from: from any directory that is *not* the source directory, do the following @@ -170,7 +170,7 @@ interested party) please key these three things in mind * If you open a discussion, be timely in responding to the submitter. Note, the reverse does not need to apply. -* Keep your questions/comments focussed on the scope of the merge request. If +* Keep your questions/comments focused on the scope of the merge request. If while reviewing the code you notice other things which could be improved, open a new issue. * Be supportive - merge requests represent a lot of hard work and effort and diff --git a/bilby/core/sampler/__init__.py b/bilby/core/sampler/__init__.py index b77831e64..ade037191 100644 --- a/bilby/core/sampler/__init__.py +++ b/bilby/core/sampler/__init__.py @@ -169,10 +169,6 @@ def run_sampler(likelihood, priors=None, label='label', outdir='outdir', else: result = sampler.run_sampler() - # Initial save of the sampler in case of failure in post-processing - if save: - result.save_to_file(extension=save, gzip=gzip) - end_time = datetime.datetime.now() result.sampling_time = (end_time - start_time).total_seconds() logger.info('Sampling time: {}'.format(end_time - start_time)) @@ -187,10 +183,13 @@ def run_sampler(likelihood, priors=None, label='label', outdir='outdir', result.log_bayes_factor = \ result.log_evidence - result.log_noise_evidence - if result.injection_parameters is not None: - if conversion_function is not None: - result.injection_parameters = conversion_function( - result.injection_parameters) + # Initial save of the sampler in case of failure in post-processing + if save: + result.save_to_file(extension=save, gzip=gzip) + + if None not in [result.injection_parameters, conversion_function]: + result.injection_parameters = conversion_function( + result.injection_parameters) result.samples_to_posterior(likelihood=likelihood, priors=result.priors, conversion_function=conversion_function) -- GitLab