fix TableDistribution constructors in tests

release/4.3a0
Varun Agrawal 2025-01-04 06:14:00 -05:00
parent 9a40be6f32
commit 7cb818136f
2 changed files with 9 additions and 10 deletions

View File

@ -700,8 +700,7 @@ TEST(HybridGaussianFactorGraph, EliminateTiny1Swapped) {
m1, std::vector{conditional0, conditional1}); m1, std::vector{conditional0, conditional1});
// Add prior on m1. // Add prior on m1.
expectedBayesNet.emplace_shared<TableDistribution>( expectedBayesNet.emplace_shared<TableDistribution>(m1, "0.188638 0.811362");
m1, "0.188638/0.811362");
// Test elimination // Test elimination
const auto posterior = fg.eliminateSequential(); const auto posterior = fg.eliminateSequential();
@ -739,7 +738,7 @@ TEST(HybridGaussianFactorGraph, EliminateTiny2) {
// Add prior on mode. // Add prior on mode.
// Since this is the only discrete conditional, it is added as a // Since this is the only discrete conditional, it is added as a
// TableDistribution. // TableDistribution.
expectedBayesNet.emplace_shared<TableDistribution>(mode, "23/77"); expectedBayesNet.emplace_shared<TableDistribution>(mode, "23 77");
// Test elimination // Test elimination
const auto posterior = fg.eliminateSequential(); const auto posterior = fg.eliminateSequential();

View File

@ -144,7 +144,7 @@ TEST(HybridGaussianFactorGraph, TwoStateModel) {
// Since no measurement on x1, we hedge our bets // Since no measurement on x1, we hedge our bets
// Importance sampling run with 100k samples gives 50.051/49.949 // Importance sampling run with 100k samples gives 50.051/49.949
// approximateDiscreteMarginal(hbn, hybridMotionModel, given); // approximateDiscreteMarginal(hbn, hybridMotionModel, given);
TableDistribution expected(m1, "50/50"); TableDistribution expected(m1, "50 50");
EXPECT(assert_equal(expected, EXPECT(assert_equal(expected,
*(bn->at(2)->asDiscrete<TableDistribution>()))); *(bn->at(2)->asDiscrete<TableDistribution>())));
} }
@ -162,7 +162,7 @@ TEST(HybridGaussianFactorGraph, TwoStateModel) {
// Since we have a measurement on x1, we get a definite result // Since we have a measurement on x1, we get a definite result
// Values taken from an importance sampling run with 100k samples: // Values taken from an importance sampling run with 100k samples:
// approximateDiscreteMarginal(hbn, hybridMotionModel, given); // approximateDiscreteMarginal(hbn, hybridMotionModel, given);
TableDistribution expected(m1, "44.3854/55.6146"); TableDistribution expected(m1, "44.3854 55.6146");
EXPECT(assert_equal( EXPECT(assert_equal(
expected, *(bn->at(2)->asDiscrete<TableDistribution>()), 0.02)); expected, *(bn->at(2)->asDiscrete<TableDistribution>()), 0.02));
} }
@ -251,7 +251,7 @@ TEST(HybridGaussianFactorGraph, TwoStateModel2) {
// Values taken from an importance sampling run with 100k samples: // Values taken from an importance sampling run with 100k samples:
// approximateDiscreteMarginal(hbn, hybridMotionModel, given); // approximateDiscreteMarginal(hbn, hybridMotionModel, given);
TableDistribution expected(m1, "48.3158/51.6842"); TableDistribution expected(m1, "48.3158 51.6842");
EXPECT(assert_equal( EXPECT(assert_equal(
expected, *(eliminated->at(2)->asDiscrete<TableDistribution>()), expected, *(eliminated->at(2)->asDiscrete<TableDistribution>()),
0.02)); 0.02));
@ -268,7 +268,7 @@ TEST(HybridGaussianFactorGraph, TwoStateModel2) {
// Values taken from an importance sampling run with 100k samples: // Values taken from an importance sampling run with 100k samples:
// approximateDiscreteMarginal(hbn, hybridMotionModel, given); // approximateDiscreteMarginal(hbn, hybridMotionModel, given);
TableDistribution expected(m1, "55.396/44.604"); TableDistribution expected(m1, "55.396 44.604");
EXPECT(assert_equal( EXPECT(assert_equal(
expected, *(bn->at(2)->asDiscrete<TableDistribution>()), 0.02)); expected, *(bn->at(2)->asDiscrete<TableDistribution>()), 0.02));
} }
@ -346,7 +346,7 @@ TEST(HybridGaussianFactorGraph, TwoStateModel3) {
// Values taken from an importance sampling run with 100k samples: // Values taken from an importance sampling run with 100k samples:
// approximateDiscreteMarginal(hbn, hybridMotionModel, given); // approximateDiscreteMarginal(hbn, hybridMotionModel, given);
TableDistribution expected(m1, "51.7762/48.2238"); TableDistribution expected(m1, "51.7762 48.2238");
EXPECT(assert_equal( EXPECT(assert_equal(
expected, *(bn->at(2)->asDiscrete<TableDistribution>()), 0.02)); expected, *(bn->at(2)->asDiscrete<TableDistribution>()), 0.02));
} }
@ -362,7 +362,7 @@ TEST(HybridGaussianFactorGraph, TwoStateModel3) {
// Values taken from an importance sampling run with 100k samples: // Values taken from an importance sampling run with 100k samples:
// approximateDiscreteMarginal(hbn, hybridMotionModel, given); // approximateDiscreteMarginal(hbn, hybridMotionModel, given);
TableDistribution expected(m1, "49.0762/50.9238"); TableDistribution expected(m1, "49.0762 50.9238");
EXPECT(assert_equal( EXPECT(assert_equal(
expected, *(bn->at(2)->asDiscrete<TableDistribution>()), 0.05)); expected, *(bn->at(2)->asDiscrete<TableDistribution>()), 0.05));
} }
@ -389,7 +389,7 @@ TEST(HybridGaussianFactorGraph, TwoStateModel4) {
// Values taken from an importance sampling run with 100k samples: // Values taken from an importance sampling run with 100k samples:
// approximateDiscreteMarginal(hbn, hybridMotionModel, given); // approximateDiscreteMarginal(hbn, hybridMotionModel, given);
TableDistribution expected(m1, "8.91527/91.0847"); TableDistribution expected(m1, "8.91527 91.0847");
EXPECT(assert_equal( EXPECT(assert_equal(
expected, *(bn->at(2)->asDiscrete<TableDistribution>()), 0.01)); expected, *(bn->at(2)->asDiscrete<TableDistribution>()), 0.01));
} }