From ed847e9b04018809c07d7d50ed7a3219b4bc586b Mon Sep 17 00:00:00 2001 From: kleeman Date: Wed, 2 Aug 2023 08:56:38 -0700 Subject: [PATCH 1/2] Allow single dimension constructor for Marginals --- include/albatross/src/core/distribution.hpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/albatross/src/core/distribution.hpp b/include/albatross/src/core/distribution.hpp index 587c1110..9a921ecb 100644 --- a/include/albatross/src/core/distribution.hpp +++ b/include/albatross/src/core/distribution.hpp @@ -91,6 +91,10 @@ struct MarginalDistribution : public DistributionBase { assert_valid(); }; + MarginalDistribution(double mean_, double variance_) + : MarginalDistribution(Eigen::VectorXd::Constant(1, mean_), + Eigen::VectorXd::Constant(1, variance_)) {} + void assert_valid() const { ALBATROSS_ASSERT(mean.size() == covariance.rows()); ALBATROSS_ASSERT(mean.size() == covariance.cols()); From c534c0c22857aa7e14e68fe8f77aff504a9b7325 Mon Sep 17 00:00:00 2001 From: kleeman Date: Wed, 2 Aug 2023 10:33:34 -0700 Subject: [PATCH 2/2] unit test --- tests/test_core_distribution.cc | 12 ++++++++++++ third_party/gzip-hpp | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/test_core_distribution.cc b/tests/test_core_distribution.cc index 1d50428a..5bf4e5ee 100644 --- a/tests/test_core_distribution.cc +++ b/tests/test_core_distribution.cc @@ -18,6 +18,18 @@ namespace albatross { +TEST(test_core_distribution, create_one_dim) { + + const double mean = M_PI; + const double var = std::log(2); + const MarginalDistribution one_dim(mean, var); + const Eigen::VectorXd mean_vec = Eigen::VectorXd::Constant(1, mean); + const Eigen::VectorXd var_vec = Eigen::VectorXd::Constant(1, var); + + const MarginalDistribution from_vectors(mean_vec, var_vec); + EXPECT_EQ(one_dim, from_vectors); +} + TYPED_TEST_P(DistributionTest, test_subset) { TypeParam test_case; diff --git a/third_party/gzip-hpp b/third_party/gzip-hpp index bbe86c94..832d6262 160000 --- a/third_party/gzip-hpp +++ b/third_party/gzip-hpp @@ -1 +1 @@ -Subproject commit bbe86c94e22e976f187c203438da27d8a61ccf9e +Subproject commit 832d6262cecaa3b85c3c242e3617b4cfdbf3de23