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

address issue with vector equivalent utility #777

Merged
merged 4 commits into from
Nov 8, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <gmock/gmock.h>
#include <gtest/gtest.h>

#include <limits>
#include <type_traits>

namespace cuspatial {
Expand Down Expand Up @@ -57,7 +58,7 @@ auto floating_eq_by_abs_error(T val, T abs_error)
if constexpr (std::is_same_v<T, float>) {
return ::testing::FloatNear(val, abs_error);
} else {
return ::testing::FloatNear(val, abs_error);
return ::testing::DoubleNear(val, abs_error);
}
}

Expand Down Expand Up @@ -99,7 +100,8 @@ MATCHER(float_matcher, std::string(negation ? "are not" : "are") + " approximate

if (::testing::Matches(floating_eq_by_ulp(rhs))(lhs)) return true;

*result_listener << std::setprecision(18) << lhs << " != " << rhs;
*result_listener << std::setprecision(std::numeric_limits<decltype(lhs)>::max_digits10) << lhs
<< " != " << rhs;

return false;
}
Expand All @@ -113,7 +115,8 @@ MATCHER_P(float_near_matcher,

if (::testing::Matches(floating_eq_by_abs_error(rhs, abs_error))(lhs)) return true;

*result_listener << std::setprecision(18) << lhs << " != " << rhs;
*result_listener << std::setprecision(std::numeric_limits<decltype(lhs)>::max_digits10) << lhs
<< " != " << rhs;

return false;
}
Expand Down Expand Up @@ -169,10 +172,10 @@ inline void expect_vector_equivalent(Vector1 const& lhs, Vector2 const& rhs, T a
}
}

#define CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(lhs, rhs, ...) \
do { \
SCOPED_TRACE(" <-- line of failure\n"); \
expect_vector_equivalent(lhs, rhs, ##__VA_ARGS__); \
#define CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(lhs, rhs, ...) \
do { \
SCOPED_TRACE(" <-- line of failure\n"); \
cuspatial::test::expect_vector_equivalent(lhs, rhs, ##__VA_ARGS__); \
} while (0)

} // namespace test
Expand Down
2 changes: 1 addition & 1 deletion cpp/tests/experimental/indexing/point_quadtree_test.cu
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

#include "tests/utility/vector_equality.hpp"
#include <cuspatial_test/vector_equality.hpp>

#include <cuspatial/experimental/point_quadtree.cuh>
#include <cuspatial/vec_2d.hpp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
* limitations under the License.
*/

#include "tests/utility/vector_equality.hpp"
#include <cuspatial/constants.hpp>
#include <cuspatial/error.hpp>
#include <cuspatial/experimental/coordinate_transform.cuh>
#include <cuspatial_test/vector_equality.hpp>

#include <rmm/device_vector.hpp>

Expand Down
2 changes: 1 addition & 1 deletion cpp/tests/experimental/spatial/hausdorff_test.cu
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

#include "tests/utility/vector_equality.hpp"
#include <cuspatial_test/vector_equality.hpp>

#include <cuspatial/error.hpp>
#include <cuspatial/experimental/hausdorff.cuh>
Expand Down
2 changes: 1 addition & 1 deletion cpp/tests/experimental/spatial/haversine_test.cu
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

#include <tests/utility/vector_equality.hpp>
#include <cuspatial_test/vector_equality.hpp>

#include <cuspatial/error.hpp>
#include <cuspatial/experimental/haversine.cuh>
Expand Down
11 changes: 3 additions & 8 deletions cpp/tests/experimental/spatial/linestring_distance_test.cu
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

#include "tests/utility/vector_equality.hpp"
#include <cuspatial_test/vector_equality.hpp>

#include <cuspatial/error.hpp>
#include <cuspatial/experimental/iterator_factory.cuh>
Expand All @@ -27,10 +27,8 @@
#include <thrust/iterator/constant_iterator.h>
#include <thrust/iterator/counting_iterator.h>

namespace cuspatial {
namespace test {

using namespace cudf;
using namespace cuspatial;
using namespace cuspatial::test;

template <typename T>
struct PairwiseLinestringDistanceTest : public ::testing::Test {
Expand Down Expand Up @@ -195,6 +193,3 @@ TYPED_TEST(PairwiseLinestringDistanceTest, FromLongInputs)
test::expect_vector_equivalent(expected, distance);
EXPECT_EQ(offset.size() - 1, std::distance(distance.begin(), ret));
}

} // namespace test
} // namespace cuspatial
2 changes: 1 addition & 1 deletion cpp/tests/experimental/spatial/point_distance_test.cu
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

#include "../../utility/vector_equality.hpp"
#include <cuspatial_test/vector_equality.hpp>

#include <cuspatial_test/random.cuh>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

#include "tests/utility/vector_equality.hpp"
#include <cuspatial_test/vector_equality.hpp>

#include <cuspatial/detail/iterator.hpp>
#include <cuspatial/error.hpp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
* limitations under the License.
*/

#include "../../utility/vector_equality.hpp"
#include "cuspatial/experimental/point_distance.cuh"
#include <cuspatial_test/vector_equality.hpp>

#include <cuspatial/detail/iterator.hpp>
#include <cuspatial/error.hpp>
Expand All @@ -32,8 +31,8 @@

#include <type_traits>

namespace cuspatial {
namespace test {
using namespace cuspatial;
using namespace cuspatial::test;

template <typename T>
struct PairwisePointLinestringNearestPointsTest : public ::testing::Test {
Expand Down Expand Up @@ -421,6 +420,3 @@ TYPED_TEST(PairwisePointLinestringNearestPointsTest, ThreePairMultiComponent)
CartVec{{3.545131432802666, 2.30503517215846}, {9.9, 9.4}, {0.0, -8.7}});
EXPECT_EQ(std::distance(output_it, ret), num_pairs);
}

} // namespace test
} // namespace cuspatial
2 changes: 1 addition & 1 deletion cpp/tests/experimental/spatial/points_in_range_test.cu
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

#include "tests/utility/vector_equality.hpp"
#include <cuspatial_test/vector_equality.hpp>

#include <cuspatial/error.hpp>
#include <cuspatial/experimental/points_in_range.cuh>
Expand Down
12 changes: 4 additions & 8 deletions cpp/tests/spatial/linestring_distance_test_medium.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
#include <cudf_test/column_wrapper.hpp>
#include <cudf_test/type_lists.hpp>

namespace cuspatial {
namespace test {
using namespace cuspatial;

using namespace cudf;
using namespace cudf::test;
Expand All @@ -32,16 +31,16 @@ template <typename T>
using wrapper = fixed_width_column_wrapper<T>;

template <typename T>
struct PairwiseLinestringDistanceTest : public BaseFixture {
struct PairwiseLinestringDistanceTestMedium : public BaseFixture {
};

// float and double are logically the same but would require separate tests due to precision.
using TestTypes = FloatingPointTypes;
TYPED_TEST_CASE(PairwiseLinestringDistanceTest, TestTypes);
TYPED_TEST_CASE(PairwiseLinestringDistanceTestMedium, TestTypes);

constexpr cudf::test::debug_output_level verbosity{cudf::test::debug_output_level::ALL_ERRORS};

TYPED_TEST(PairwiseLinestringDistanceTest, RandomDataset100)
TYPED_TEST(PairwiseLinestringDistanceTestMedium, RandomDataset100)
{
using T = TypeParam;
wrapper<cudf::size_type> linestring1_offsets{
Expand Down Expand Up @@ -1051,6 +1050,3 @@ TYPED_TEST(PairwiseLinestringDistanceTest, RandomDataset100)
linestring2_points_y);
expect_columns_equivalent(expected, *got, verbosity);
}

} // namespace test
} // namespace cuspatial