Fix some comments

release/4.3a0
Frank Dellaert 2023-01-04 21:41:22 -08:00
parent c24e975729
commit 5d0bc3191a
1 changed files with 6 additions and 12 deletions

View File

@ -764,13 +764,10 @@ TEST(HybridGaussianFactorGraph, EliminateTiny22) {
// regression // regression
EXPECT_DOUBLES_EQUAL(0.018253037966018862, expected_ratio, 1e-6); EXPECT_DOUBLES_EQUAL(0.018253037966018862, expected_ratio, 1e-6);
// 3. Do sampling // Test ratios for a number of independent samples:
constexpr int num_samples = 100; constexpr int num_samples = 100;
for (size_t i = 0; i < num_samples; i++) { for (size_t i = 0; i < num_samples; i++) {
// Sample from the bayes net
HybridValues sample = bn.sample(&rng); HybridValues sample = bn.sample(&rng);
// Check that the ratio is constant.
EXPECT_DOUBLES_EQUAL(expected_ratio, compute_ratio(&sample), 1e-6); EXPECT_DOUBLES_EQUAL(expected_ratio, compute_ratio(&sample), 1e-6);
} }
} }
@ -822,7 +819,7 @@ TEST(HybridGaussianFactorGraph, EliminateSwitchingNetwork) {
// Create measurements consistent with moving right every time: // Create measurements consistent with moving right every time:
const VectorValues measurements{ const VectorValues measurements{
{Z(0), Vector1(0.0)}, {Z(1), Vector1(1.0)}, {Z(2), Vector1(2.0)}}; {Z(0), Vector1(0.0)}, {Z(1), Vector1(1.0)}, {Z(2), Vector1(2.0)}};
const auto fg = bn.toFactorGraph(measurements); const HybridGaussianFactorGraph fg = bn.toFactorGraph(measurements);
// Create ordering that eliminates in time order, then discrete modes: // Create ordering that eliminates in time order, then discrete modes:
Ordering ordering; Ordering ordering;
@ -835,11 +832,11 @@ TEST(HybridGaussianFactorGraph, EliminateSwitchingNetwork) {
ordering.push_back(M(1)); ordering.push_back(M(1));
ordering.push_back(M(2)); ordering.push_back(M(2));
// Test elimination result has correct size: // Do elimination:
const auto posterior = fg.eliminateSequential(ordering); const HybridBayesNet::shared_ptr posterior = fg.eliminateSequential(ordering);
// GTSAM_PRINT(*posterior); // GTSAM_PRINT(*posterior);
// Test elimination result has correct size: // Test resulting posterior Bayes net has correct size:
EXPECT_LONGS_EQUAL(8, posterior->size()); EXPECT_LONGS_EQUAL(8, posterior->size());
// TODO(dellaert): below is copy/pasta from above, refactor // TODO(dellaert): below is copy/pasta from above, refactor
@ -861,13 +858,10 @@ TEST(HybridGaussianFactorGraph, EliminateSwitchingNetwork) {
// regression // regression
EXPECT_DOUBLES_EQUAL(0.0094526745785019472, expected_ratio, 1e-6); EXPECT_DOUBLES_EQUAL(0.0094526745785019472, expected_ratio, 1e-6);
// 3. Do sampling // Test ratios for a number of independent samples:
constexpr int num_samples = 100; constexpr int num_samples = 100;
for (size_t i = 0; i < num_samples; i++) { for (size_t i = 0; i < num_samples; i++) {
// Sample from the bayes net
HybridValues sample = bn.sample(&rng); HybridValues sample = bn.sample(&rng);
// Check that the ratio is constant.
EXPECT_DOUBLES_EQUAL(expected_ratio, compute_ratio(&sample), 1e-6); EXPECT_DOUBLES_EQUAL(expected_ratio, compute_ratio(&sample), 1e-6);
} }
} }