Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Platform specific #ifs #1966

Merged
merged 11 commits into from
Jan 10, 2025
Next Next commit
platform specific #ifs
varunagrawal committed Jan 8, 2025
commit 72da68ebf30bdadc1a340c9a6220745d3a32e611
32 changes: 19 additions & 13 deletions gtsam/hybrid/tests/testHybridBayesNet.cpp
Original file line number Diff line number Diff line change
@@ -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__
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don’t see differences between these different paths??

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am using the CI to understand the differences in the results since I can avoid instrumenting individual platform runs manually. I'll request a review when this is ready.

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
}

/* ****************************************************************************/