From f04c56a8142292056224bbf974502095b1462a12 Mon Sep 17 00:00:00 2001 From: Richard Date: Mon, 22 Jul 2024 14:27:39 +0100 Subject: [PATCH 1/3] fix test --- test_autofit/serialise/test_samples.py | 46 +++++++++++++++++--------- 1 file changed, 31 insertions(+), 15 deletions(-) diff --git a/test_autofit/serialise/test_samples.py b/test_autofit/serialise/test_samples.py index 918f05e2a..12e039ef4 100644 --- a/test_autofit/serialise/test_samples.py +++ b/test_autofit/serialise/test_samples.py @@ -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", @@ -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", @@ -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, }, } From 23759667f04114efb8cdd92a645ac4d426740b8b Mon Sep 17 00:00:00 2001 From: Richard Date: Mon, 22 Jul 2024 14:30:58 +0100 Subject: [PATCH 2/3] readd model to samples summary when aggregating in database --- autofit/database/model/fit.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/autofit/database/model/fit.py b/autofit/database/model/fit.py index e1cf0e78f..bde40c5b0 100644 --- a/autofit/database/model/fit.py +++ b/autofit/database/model/fit.py @@ -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) From 8a9b6a774cc022102fbae3b382690f6888664aa3 Mon Sep 17 00:00:00 2001 From: Richard Date: Mon, 22 Jul 2024 14:33:23 +0100 Subject: [PATCH 3/3] test --- test_autofit/database/test_regression.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test_autofit/database/test_regression.py b/test_autofit/database/test_regression.py index bae58d94e..19d90ac31 100644 --- a/test_autofit/database/test_regression.py +++ b/test_autofit/database/test_regression.py @@ -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