Skip to content

Commit

Permalink
platform specific #ifs
Browse files Browse the repository at this point in the history
  • Loading branch information
varunagrawal committed Jan 8, 2025
1 parent 8cf2123 commit 72da68e
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions gtsam/hybrid/tests/testHybridBayesNet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -552,19 +552,25 @@ TEST(HybridBayesNet, Sampling) {
EXPECT_LONGS_EQUAL(2, average_continuous.size());
EXPECT_LONGS_EQUAL(num_samples, discrete_samples.size());

// Regressions don't work across platforms :-(
// // regression for specific RNG seed
// double discrete_sum =
// std::accumulate(discrete_samples.begin(), discrete_samples.end(),
// decltype(discrete_samples)::value_type(0));
// EXPECT_DOUBLES_EQUAL(0.477, discrete_sum / num_samples, 1e-9);

// VectorValues expected;
// expected.insert({X(0), Vector1(-0.0131207162712)});
// expected.insert({X(1), Vector1(-0.499026377568)});
// // regression for specific RNG seed
// EXPECT(assert_equal(expected, average_continuous.scale(1.0 /
// num_samples)));
// regression for specific RNG seed
double discrete_sum =
std::accumulate(discrete_samples.begin(), discrete_samples.end(),
decltype(discrete_samples)::value_type(0));
#if __APPLE__
EXPECT_DOUBLES_EQUAL(0.477, discrete_sum / num_samples, 1e-9);
#elif __linux__
EXPECT_DOUBLES_EQUAL(0.477, discrete_sum / num_samples, 1e-9);
#endif

VectorValues expected;
expected.insert({X(0), Vector1(-0.0131207162712)});
expected.insert({X(1), Vector1(-0.499026377568)});
// regression for specific RNG seed
#if __APPLE__
EXPECT(assert_equal(expected, average_continuous.scale(1.0 / num_samples)));
#elif __linux__
EXPECT(assert_equal(expected, average_continuous.scale(1.0 / num_samples)));
#endif
}

/* ****************************************************************************/
Expand Down

0 comments on commit 72da68e

Please sign in to comment.