Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion autofit/non_linear/samples/pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ def save_covariance_matrix(self, filename: Union[pathlib.Path, str]):

@property
def log_evidence(self):
return None
return self.samples_info.get("log_evidence")


def marginalize(
Expand Down
24 changes: 22 additions & 2 deletions autofit/non_linear/search/abstract_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,8 +505,16 @@ class represented by model M and gives a score for their fitness.
info=info,
)
else:
if hasattr(self.paths, '_save_model_info'):
self.paths._save_model_info(model=model)
# Bypass mode still needs the metadata + identifier files written
# so downstream aggregator scraping can discover the search
# directory. `save_all` is lightweight (a handful of JSON dumps)
# and skips the expensive `analysis.save_attributes` /
# `visualize_before_fit` calls that `pre_fit_output` would add.
if hasattr(self.paths, "save_all"):
self.paths.save_all(
search_config_dict=self.config_dict_search,
info=info,
)

if not self.paths.is_complete:
result = self.start_resume_fit(
Expand Down Expand Up @@ -852,17 +860,29 @@ def _fit_bypass_test_mode(
log_likelihood=log_likelihood,
)

# Stub log_evidence in samples_info so downstream arithmetic
# (grid search log_evidences, subhalo Bayesian model comparison,
# scrape aggregator assertions) doesn't crash on None. SamplesPDF
# reads log_evidence from samples_info.
samples = SamplesPDF(
model=model,
sample_list=sample_list,
samples_info={
"total_iterations": 1,
"time": 0.0,
"log_evidence": log_likelihood,
},
)

samples_summary = samples.summary()

# Persist samples + summary to disk so downstream code that reads
# from the output folder (database scrape, paths.load_samples_summary)
# sees a complete result. Matches the docstring's promise. NullPaths
# and DatabasePaths both handle these calls safely.
self.paths.save_samples_summary(samples_summary=samples_summary)
self.paths.save_samples(samples=samples)

result = analysis.make_result(
samples_summary=samples_summary,
paths=self.paths,
Expand Down
Loading