Skip to content

Commit

Permalink
Merge pull request #1024 from rhayes777/feature/samples_summary_model
Browse files Browse the repository at this point in the history
feature/samples summary model
  • Loading branch information
Jammy2211 authored Jul 23, 2024
2 parents c0ab8cd + 8a9b6a7 commit a468317
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 16 deletions.
5 changes: 4 additions & 1 deletion autofit/database/model/fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,10 @@ def __getitem__(self, item: str):
"""
for p in self.jsons + self.arrays + self.hdus + self.pickles:
if p.name == item:
return p.value
value = p.value
if item == "samples_summary":
value.model = self.model
return value

return getattr(self, item)

Expand Down
9 changes: 9 additions & 0 deletions test_autofit/database/test_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,12 @@ def test_model_with_parameterless_component():
def test_instance_in_collection():
collection = af.Collection(gaussian=af.Gaussian())
assert list(collection.items()) == [("gaussian", af.Gaussian())]


def test_samples_summary_model():
fit = af.db.Fit()
model = af.Model(af.Gaussian)
fit["samples_summary"] = af.Samples(model=model, sample_list=[])
fit.model = model

assert fit["samples_summary"].model.cls == af.Gaussian
46 changes: 31 additions & 15 deletions test_autofit/serialise/test_samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,6 @@ def make_summary_dict():
"type": "instance",
"class_path": "autofit.non_linear.samples.summary.SamplesSummary",
"arguments": {
"errors_at_sigma_1": {
"type": "list",
"values": [(2.0, 0.0), (3.0, 0.0), (4.0, 0.0)],
},
"errors_at_sigma_3": {
"type": "list",
"values": [(2.0, 0.0), (3.0, 0.0), (4.0, 0.0)],
},
"values_at_sigma_3": {
"type": "list",
"values": [(0.0, 2.0), (1.0, 4.0), (2.0, 6.0)],
},
"max_log_likelihood_sample": {
"type": "instance",
"class_path": "autofit.non_linear.samples.sample.Sample",
Expand All @@ -81,11 +69,14 @@ def make_summary_dict():
},
},
},
"values_at_sigma_1": {
"values_at_sigma_3": {
"type": "list",
"values": [(0.0, 2.0), (1.0, 4.0), (2.0, 6.0)],
"values": [
{"type": "tuple", "values": [0.0, 2.0]},
{"type": "tuple", "values": [1.0, 4.0]},
{"type": "tuple", "values": [2.0, 6.0]},
],
},
"log_evidence": None,
"median_pdf_sample": {
"type": "instance",
"class_path": "autofit.non_linear.samples.sample.Sample",
Expand All @@ -103,6 +94,31 @@ def make_summary_dict():
},
},
},
"errors_at_sigma_3": {
"type": "list",
"values": [
{"type": "tuple", "values": [2.0, 0.0]},
{"type": "tuple", "values": [3.0, 0.0]},
{"type": "tuple", "values": [4.0, 0.0]},
],
},
"values_at_sigma_1": {
"type": "list",
"values": [
{"type": "tuple", "values": [0.0, 2.0]},
{"type": "tuple", "values": [1.0, 4.0]},
{"type": "tuple", "values": [2.0, 6.0]},
],
},
"errors_at_sigma_1": {
"type": "list",
"values": [
{"type": "tuple", "values": [2.0, 0.0]},
{"type": "tuple", "values": [3.0, 0.0]},
{"type": "tuple", "values": [4.0, 0.0]},
],
},
"log_evidence": None,
},
}

Expand Down

0 comments on commit a468317

Please sign in to comment.