From 8bd4f75635c73f8ef2c9b6e31badb7418d4bca99 Mon Sep 17 00:00:00 2001 From: alexhroom Date: Tue, 14 Jan 2025 08:49:19 +0000 Subject: [PATCH 1/2] added nested sampler uncertainty to pybind and outputs --- RATapi/outputs.py | 2 ++ cpp/rat.cpp | 3 +++ tests/conftest.py | 1 + tests/test_outputs.py | 1 + 4 files changed, 7 insertions(+) diff --git a/RATapi/outputs.py b/RATapi/outputs.py index bfd7f521..4c4a00a0 100644 --- a/RATapi/outputs.py +++ b/RATapi/outputs.py @@ -149,6 +149,7 @@ class DreamOutput(RATResult): @dataclass class NestedSamplerOutput(RATResult): logZ: float + logZErr: float nestSamples: np.ndarray postSamples: np.ndarray @@ -230,6 +231,7 @@ def make_results( nested_sampler_output = NestedSamplerOutput( logZ=bayes_results.nestedSamplerOutput.logZ, + logZErr=bayes_results.nestedSamplerOutput.logZErr, nestSamples=bayes_results.nestedSamplerOutput.nestSamples, postSamples=bayes_results.nestedSamplerOutput.postSamples, ) diff --git a/cpp/rat.cpp b/cpp/rat.cpp index 37f57375..0f370368 100644 --- a/cpp/rat.cpp +++ b/cpp/rat.cpp @@ -315,6 +315,7 @@ struct ConfidenceIntervals struct NestedSamplerOutput { real_T logZ; + real_T logZErr; py::array_t nestSamples; py::array_t postSamples; }; @@ -1243,6 +1244,7 @@ BayesResults bayesResultsFromStruct9T(const RAT::struct9_T results) bayesResults.confidenceIntervals.mean = pyArrayFromRatArray2d(results.confidenceIntervals.mean); bayesResults.nestedSamplerOutput.logZ = results.nestedSamplerOutput.LogZ; + bayesResults.nestedSamplerOutput.logZErr = results.nestedSamplerOutput.LogZErr; bayesResults.nestedSamplerOutput.nestSamples = pyArrayFromRatArray2d(results.nestedSamplerOutput.nestSamples); bayesResults.nestedSamplerOutput.postSamples = pyArrayFromRatArray2d(results.nestedSamplerOutput.postSamples); @@ -1445,6 +1447,7 @@ PYBIND11_MODULE(rat_core, m) { py::class_(m, "NestedSamplerOutput") .def(py::init<>()) .def_readwrite("logZ", &NestedSamplerOutput::logZ) + .def_readwrite("logZErr", &NestedSamplerOutput::logZErr) .def_readwrite("nestSamples", &NestedSamplerOutput::nestSamples) .def_readwrite("postSamples", &NestedSamplerOutput::postSamples); diff --git a/tests/conftest.py b/tests/conftest.py index ecd9ddd6..0f81fdb2 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -5639,6 +5639,7 @@ def dream_results(): ), nestedSamplerOutput=RATapi.outputs.NestedSamplerOutput( logZ=0.0, + logZErr=0.0, nestSamples=np.array([[0.0, 0.0]]), postSamples=np.array([[0.0, 0.0]]), ), diff --git a/tests/test_outputs.py b/tests/test_outputs.py index fdd22dd7..e5758a4f 100644 --- a/tests/test_outputs.py +++ b/tests/test_outputs.py @@ -126,6 +126,7 @@ def dream_str(): "),\n" "nestedSamplerOutput = NestedSamplerOutput(\n" "\tlogZ = 0.0,\n" + "\tlogZErr = 0.0,\n" "\tnestSamples = Data array: [1 x 2],\n" "\tpostSamples = Data array: [1 x 2],\n" "),\n" From 8348905e2f16c859f62428434c1ebda83a6fad5a Mon Sep 17 00:00:00 2001 From: alexhroom Date: Tue, 14 Jan 2025 09:19:15 +0000 Subject: [PATCH 2/2] updated submodule --- cpp/RAT | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/RAT b/cpp/RAT index a623fd32..af251ab2 160000 --- a/cpp/RAT +++ b/cpp/RAT @@ -1 +1 @@ -Subproject commit a623fd32ce0cceefa839f704bf6c51f519493145 +Subproject commit af251ab27ebce5ab58ba27004eea541dae438785