Skip to content

Commit

Permalink
beat summarize: only create summary file if stage_number -1
Browse files Browse the repository at this point in the history
  • Loading branch information
hvasbath committed Aug 23, 2018
1 parent b86e9e3 commit 66642a3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
36 changes: 20 additions & 16 deletions apps/beat
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,7 @@ def command_summarize(args):

stage = Stage(homepath=problem.outfolder)
stage_numbers = stage.handler.get_stage_indexes(options.stage_number)
logger.info('Summarizing stage(s): %s' % list2string(stage_numbers))
if len(stage_numbers) == 0:
raise ValueError('No stage result found where sampling completed!')

Expand Down Expand Up @@ -787,26 +788,29 @@ def command_summarize(args):
logger.info(
'Summarized trace exists! Use force=True to overwrite!')

stage.load_results(model=problem.model, stage_number=-1, chains=[-1])
rtrace = stage.mtrace
final_stage = -1
if final_stage in stage_numbers:
stage.load_results(
model=problem.model, stage_number=final_stage, chains=[-1])
rtrace = stage.mtrace

if len(rtrace) == 0:
raise ValueError(
'Trace collection previously failed. Please rerun'
' "beat summarize <project_dir> --force!"')
if len(rtrace) == 0:
raise ValueError(
'Trace collection previously failed. Please rerun'
' "beat summarize <project_dir> --force!"')

summary_file = pjoin(problem.outfolder, config.summary_name)
summary_file = pjoin(problem.outfolder, config.summary_name)

if os.path.exists(summary_file) and options.force:
os.remove(summary_file)
if os.path.exists(summary_file) and options.force:
os.remove(summary_file)

if not os.path.exists(summary_file) or options.force:
logger.info('Writing summary to %s' % summary_file)
df = summary(rtrace)
with open(summary_file, 'w') as outfile:
df.to_string(outfile)
else:
logger.info('Summary exists! Use force=True to overwrite!')
if not os.path.exists(summary_file) or options.force:
logger.info('Writing summary to %s' % summary_file)
df = summary(rtrace)
with open(summary_file, 'w') as outfile:
df.to_string(outfile)
else:
logger.info('Summary exists! Use force=True to overwrite!')


def command_build_gfs(args):
Expand Down
2 changes: 1 addition & 1 deletion data/examples/FullMT/config_geometry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ sampler_config: !beat.SamplerConfig
proposal_dist: MultivariateNormal
check_bnd: true
update_covariances: false
rm_flag: true
rm_flag: false
hyper_sampler_config: !beat.SamplerConfig
name: Metropolis
progressbar: true
Expand Down

0 comments on commit 66642a3

Please sign in to comment.