Skip to content

Commit

Permalink
regression cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Cleveland committed Aug 26, 2021
1 parent 35c3ff9 commit e06a99d
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 28 deletions.
30 changes: 14 additions & 16 deletions src/kde/quick_index.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ namespace rtt_kde {
* \param[in] max_window_size_ maximum supported window size
* \param[in] bins_per_dimension_ number of bins in each dimension
* \param[in] domain_decomposed_
* \param[in] spherical_ bool operator to enable spherical transform
* \param[in] sphere_center_ origin of spherical transform
*/
quick_index::quick_index(const size_t dim_, const std::vector<std::array<double, 3>> &locations_,
const double max_window_size_, const size_t bins_per_dimension_,
Expand Down Expand Up @@ -563,8 +565,7 @@ auto get_window_bin = [](auto spherical, const auto dim, const auto &grid_bins,
//------------------------------------------------------------------------------------------------//
// Lambda for mapping the data
auto map_data = [](auto &bias_cell_count, auto &data_count, auto &grid_data, auto &min_distance,
const auto &dim, const auto &map_type, const auto &data,
const auto &distance_to_bin_center, const auto &location,
const auto &map_type, const auto &data, const auto &distance_to_bin_center,
const auto &local_window_bin, const auto &data_bin) {
// regardless of map type if it is the first value to enter the bin it
// gets set to that value
Expand Down Expand Up @@ -704,8 +705,8 @@ void quick_index::map_data_to_grid_window(
continue;

// lambda for mapping the data
map_data(bias_cell_count, data_count, grid_data, min_distance, dim, map_type, local_data,
distance_to_bin_center, locations[l], local_window_bin, l);
map_data(bias_cell_count, data_count, grid_data, min_distance, map_type, local_data,
distance_to_bin_center, local_window_bin, l);

} // end local point loop
} // if valid local bin loop
Expand All @@ -727,8 +728,8 @@ void quick_index::map_data_to_grid_window(
continue;

// lambda for mapping the data
map_data(bias_cell_count, data_count, grid_data, min_distance, dim, map_type, ghost_data,
distance_to_bin_center, local_ghost_locations[g], local_window_bin, g);
map_data(bias_cell_count, data_count, grid_data, min_distance, map_type, ghost_data,
distance_to_bin_center, local_window_bin, g);
} // end ghost point loop
} // if valid ghost bin
} // if dd
Expand Down Expand Up @@ -784,10 +785,9 @@ void quick_index::map_data_to_grid_window(
//------------------------------------------------------------------------------------------------//
// Lambda for mapping the vector data
auto map_vector_data = [](auto &bias_cell_count, auto &data_count, auto &grid_data,
auto &min_distance, const auto &dim, const auto &map_type,
const auto &data, const auto &distance_to_bin_center,
const auto &location, const auto &local_window_bin, const auto &data_bin,
const auto &vsize) {
auto &min_distance, const auto &map_type, const auto &data,
const auto &distance_to_bin_center, const auto &local_window_bin,
const auto &data_bin, const auto &vsize) {
// regardless of map type if it is the first value to enter the bin it gets set to that value
if (data_count[local_window_bin] == 0) {
bias_cell_count += 1.0;
Expand Down Expand Up @@ -938,9 +938,8 @@ void quick_index::map_data_to_grid_window(const std::vector<std::vector<double>>
if (!valid)
continue;
Check(local_window_bin < n_map_bins);
map_vector_data(bias_cell_count, data_count, grid_data, min_distance, dim, map_type,
local_data, distance_to_bin_center, locations[l], local_window_bin, l,
vsize);
map_vector_data(bias_cell_count, data_count, grid_data, min_distance, map_type, local_data,
distance_to_bin_center, local_window_bin, l, vsize);
} // end local point loop
} // if valid local bin loop
if (domain_decomposed) {
Expand All @@ -959,9 +958,8 @@ void quick_index::map_data_to_grid_window(const std::vector<std::vector<double>>
// If the bin is outside the window continue to the next poin
if (!valid)
continue;
map_vector_data(bias_cell_count, data_count, grid_data, min_distance, dim, map_type,
ghost_data, distance_to_bin_center, local_ghost_locations[g],
local_window_bin, g, vsize);
map_vector_data(bias_cell_count, data_count, grid_data, min_distance, map_type,
ghost_data, distance_to_bin_center, local_window_bin, g, vsize);
} // end ghost point loop
} // if valid ghost bin
} // if dd
Expand Down
3 changes: 2 additions & 1 deletion src/kde/quick_index.hh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ namespace rtt_kde {
* Calculate a relative r theta and phi coordinate relative to a sphere center location from a
* standard (x,y,z) or (r,z) coordinates
*
* \param[in] dim used to ensure it is only used in valid dimension ranges
* \param[in] sphere_center center of sphere in (x,y,z) or (r,z) coordinates
* \param[in] locations (x,y,z) or (r,z) locations to transform to relative (r, theta, phi) space.
*
Expand Down Expand Up @@ -110,7 +111,7 @@ public:
// Quick index initialization data
const size_t dim;
const bool domain_decomposed;
const double spherical;
const bool spherical;
const std::array<double, 3> sphere_center;
const size_t coarse_bin_resolution;
const double max_window_size;
Expand Down
5 changes: 0 additions & 5 deletions src/kde/test/tstkde.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ void test_replication(ParallelUnitTest &ut) {
{
const bool spherical = true;
const std::array<double, 3> sphere_center{0.0, -1.0, 0.0};
const double max_radius = 1.0;
const double min_radius = 0.0;
kde sphere_kde;
// reflect on the theta boundary
kde theta_reflected_sphere_kde({false, false, true, true, false, false});
Expand Down Expand Up @@ -1046,9 +1044,6 @@ void test_decomposition(ParallelUnitTest &ut) {
const bool spherical = true;
const size_t local_size = 24;
const std::array<double, 3> sphere_center{0.0, -1.0, 0.0};
const double max_radius = 1.0;
const double min_radius = 0.0;
const double shell_min_radius = 0.5;
kde sphere_kde;
// reflect on the theta boundary
kde theta_reflected_sphere_kde({false, false, true, true, false, false});
Expand Down
16 changes: 10 additions & 6 deletions src/kde/test/tstquick_index.cc
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ void test_replication(ParallelUnitTest &ut) {
for (size_t i = 0; i < map.second.size(); i++)
if (gold_map[map.first][i] != map.second[i])
ITFAILS;

// Check non-spherical orthogonal distance calculation
auto distance = qindex.calc_orthogonal_distance({-1, -1, -1}, {1, 1, 1}, 10.0);
for (auto &val : distance)
FAIL_IF_NOT(rtt_dsxx::soft_equiv(val, 2.0));
}

if (ut.numFails == 0) {
Expand Down Expand Up @@ -142,6 +147,11 @@ void test_replication_sphere(ParallelUnitTest &ut) {
for (size_t i = 0; i < map.second.size(); i++)
if (gold_map[map.first][i] != map.second[i])
ITFAILS;

// Check non-spherical orthogonal distance calculation
auto distance = qindex.calc_orthogonal_distance({-1, 0.5, -1}, {1, 1, 1}, 4.0);
for (auto &val : distance)
FAIL_IF_NOT(rtt_dsxx::soft_equiv(val, 2.0));
}

if (ut.numFails == 0) {
Expand Down Expand Up @@ -1501,9 +1511,6 @@ void test_decomposition_sphere(ParallelUnitTest &ut) {

const size_t local_size = 4;
const std::array<double, 3> sphere_center{0.0, 0.0, 0.0};
const double max_radius = 1.0;
const double min_radius = 0.0;
const double shell_min_radius = 0.5;
const std::array<double, 2> radial_edges{0.5, 1.0};
const std::array<double, 6> cosine_edges{-.99, 0, .99, -.99, 0, .99};
const size_t data_size = radial_edges.size() * cosine_edges.size();
Expand Down Expand Up @@ -1721,9 +1728,6 @@ void test_decomposition_sphere(ParallelUnitTest &ut) {

const size_t local_size = 24;
const std::array<double, 3> sphere_center{0.0, -1.0, 0.0};
const double max_radius = 1.0;
const double min_radius = 0.0;
const double shell_min_radius = 0.5;
const std::array<double, 8> radial_edges{0.025, 0.05, 0.075, 0.1, 0.25, 0.5, 0.75, 1.0};
const std::array<double, 9> cosine_edges{-1.0, -0.75, -0.5, -0.25, 0.0, 0.25, 0.5, 0.75, 1.0};
const size_t data_size = radial_edges.size() * cosine_edges.size();
Expand Down

0 comments on commit e06a99d

Please sign in to comment.