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

Fix tests #348

Merged
merged 1 commit into from
Dec 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions fuse_constraints/test/cost_function_gtest.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
* @param[in] tolerance The tolerance to use when comparing the cost functions are equal. Defaults to 1e-18
*/
static void ExpectCostFunctionsAreEqual(const ceres::CostFunction& cost_function,
const ceres::CostFunction& actual_cost_function, double tolerance = 1e-18)
const ceres::CostFunction& actual_cost_function)
{
EXPECT_EQ(cost_function.num_residuals(), actual_cost_function.num_residuals());
const size_t num_residuals = cost_function.num_residuals();
Expand Down Expand Up @@ -95,20 +95,20 @@ static void ExpectCostFunctionsAreEqual(const ceres::CostFunction& cost_function
EXPECT_TRUE(actual_cost_function.Evaluate(parameter_blocks.get(), actual_residuals.get(), nullptr));
for (size_t i = 0; i < num_residuals; ++i)
{
EXPECT_NEAR(residuals[i], actual_residuals[i], tolerance) << "residual id: " << i;
EXPECT_DOUBLE_EQ(residuals[i], actual_residuals[i]) << "residual id: " << i;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is EXPECT_DOUBLE_EQ more tolerant than 1e-18?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep - it knows what the underlying buckets of precision are for doubles

}

EXPECT_TRUE(cost_function.Evaluate(parameter_blocks.get(), residuals.get(), jacobian_blocks.get()));
EXPECT_TRUE(
actual_cost_function.Evaluate(parameter_blocks.get(), actual_residuals.get(), actual_jacobian_blocks.get()));
for (size_t i = 0; i < num_residuals; ++i)
{
EXPECT_NEAR(residuals[i], actual_residuals[i], tolerance) << "residual : " << i;
EXPECT_DOUBLE_EQ(residuals[i], actual_residuals[i]) << "residual : " << i;
}

for (size_t i = 0; i < num_residuals * num_parameters; ++i)
{
EXPECT_NEAR(jacobians[i], actual_jacobians[i], tolerance)
EXPECT_DOUBLE_EQ(jacobians[i], actual_jacobians[i])
<< "jacobian : " << i << " " << jacobians[i] << " " << actual_jacobians[i];
}
}
Expand Down