Skip to content

Commit

Permalink
CovarianceSampling Test: Considerably relax test requirements.
Browse files Browse the repository at this point in the history
- In general one is only concerned with the order of magnitude
of the condition number.
- It doesn't make sense to guarantee that specific indexes are
present after the sampling procedure.
  • Loading branch information
SergioRAgostinho committed Oct 9, 2018
1 parent 8d78697 commit 6c9ad44
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions test/filters/test_sampling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,39 +66,40 @@ TEST (CovarianceSampling, Filters)
covariance_sampling.setNormals (cloud_walls_normals);
covariance_sampling.setNumberOfSamples (static_cast<unsigned int> (cloud_walls_normals->size ()) / 4);
double cond_num_walls = covariance_sampling.computeConditionNumber ();
EXPECT_NEAR (113.29773, cond_num_walls, 1e-1);

// Conditioning number should be loosely close to the expected number. Adopting 10% of the reference value
EXPECT_NEAR (113.29773, cond_num_walls, 10.);

IndicesPtr walls_indices (new std::vector<int> ());
covariance_sampling.filter (*walls_indices);

covariance_sampling.setIndices (walls_indices);
double cond_num_walls_sampled = covariance_sampling.computeConditionNumber ();
EXPECT_NEAR (22.11506, cond_num_walls_sampled, 1e-1);

EXPECT_EQ (686, (*walls_indices)[0]);
EXPECT_EQ (1900, (*walls_indices)[walls_indices->size () / 4]);
EXPECT_EQ (1278, (*walls_indices)[walls_indices->size () / 2]);
EXPECT_EQ (2960, (*walls_indices)[walls_indices->size () * 3 / 4]);
EXPECT_EQ (2060, (*walls_indices)[walls_indices->size () - 1]);
// Conditioning number should be loosely close to the expected number. Adopting 10% of the reference value
EXPECT_NEAR (22.11506, cond_num_walls_sampled, 2.);

// Ensure it respects the requested sampling size
EXPECT_EQ (static_cast<unsigned int> (cloud_walls_normals->size ()) / 4, walls_indices->size ());

covariance_sampling.setInputCloud (cloud_turtle_normals);
covariance_sampling.setNormals (cloud_turtle_normals);
covariance_sampling.setIndices (IndicesPtr ());
covariance_sampling.setNumberOfSamples (static_cast<unsigned int> (cloud_turtle_normals->size ()) / 8);
double cond_num_turtle = covariance_sampling.computeConditionNumber ();
EXPECT_NEAR (cond_num_turtle, 20661.7663, 0.5);

// Conditioning number should be loosely close to the expected number. Adopting 10% of the reference value
EXPECT_NEAR (cond_num_turtle, 20661.7663, 2e4);

IndicesPtr turtle_indices (new std::vector<int> ());
covariance_sampling.filter (*turtle_indices);
covariance_sampling.setIndices (turtle_indices);
double cond_num_turtle_sampled = covariance_sampling.computeConditionNumber ();
EXPECT_NEAR (cond_num_turtle_sampled, 5795.5057, 0.5);

EXPECT_EQ ((*turtle_indices)[0], 80344);
EXPECT_EQ ((*turtle_indices)[turtle_indices->size () / 4], 145982);
EXPECT_EQ ((*turtle_indices)[turtle_indices->size () / 2], 104557);
EXPECT_EQ ((*turtle_indices)[turtle_indices->size () * 3 / 4], 41512);
EXPECT_EQ ((*turtle_indices)[turtle_indices->size () - 1], 136885);
// Conditioning number should be loosely close to the expected number. Adopting 10% of the reference value
EXPECT_NEAR (cond_num_turtle_sampled, 5795.5057, 5e3);

// Ensure it respects the requested sampling size
EXPECT_EQ (static_cast<unsigned int> (cloud_turtle_normals->size ()) / 8, turtle_indices->size ());
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down

0 comments on commit 6c9ad44

Please sign in to comment.