From 75ad60b993c944a24f1c5f1e1cf310b899b20660 Mon Sep 17 00:00:00 2001 From: David Wendt Date: Wed, 2 Nov 2022 16:48:38 -0400 Subject: [PATCH 1/4] Fix quantile gtests coded in namespace cudf::test --- cpp/CMakeLists.txt | 2 +- .../cudf/tdigest/tdigest_column_view.cuh | 36 ++- cpp/include/cudf_test/tdigest_utilities.cuh | 58 ++++- .../quantiles/tdigest/tdigest_column_view.cpp | 2 - cpp/tests/CMakeLists.txt | 2 +- cpp/tests/groupby/groupby_test_util.hpp | 52 ----- ...rox_test.cu => percentile_approx_test.cpp} | 207 +++++++++--------- cpp/tests/quantiles/quantile_test.cpp | 177 +++++++-------- cpp/tests/quantiles/quantiles_test.cpp | 127 +++++------ .../tdigest_utilities.cu | 0 10 files changed, 322 insertions(+), 341 deletions(-) rename cpp/tests/quantiles/{percentile_approx_test.cu => percentile_approx_test.cpp} (69%) rename cpp/tests/{quantiles => utilities}/tdigest_utilities.cu (100%) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 289c432dea5..08d6abfda56 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -689,7 +689,7 @@ add_library(cudf::cudf ALIAS cudf) add_library( cudftestutil STATIC tests/io/metadata_utilities.cpp - tests/quantiles/tdigest_utilities.cu + tests/utilities/tdigest_utilities.cu tests/utilities/base_fixture.cpp tests/utilities/column_utilities.cu tests/utilities/table_utilities.cu diff --git a/cpp/include/cudf/tdigest/tdigest_column_view.cuh b/cpp/include/cudf/tdigest/tdigest_column_view.cuh index 64371fd5c45..0ffd9578126 100644 --- a/cpp/include/cudf/tdigest/tdigest_column_view.cuh +++ b/cpp/include/cudf/tdigest/tdigest_column_view.cuh @@ -22,24 +22,6 @@ namespace cudf { namespace tdigest { -/** - * @brief Functor to compute the size of each tdigest of a column. - * - */ -struct tdigest_size { - size_type const* offsets; ///< Offsets of the t-digest column - /** - * @brief Returns size of the each tdigest in the column - * - * @param tdigest_index Index of the tdigest in the column - * @return Size of the tdigest - */ - __device__ size_type operator()(size_type tdigest_index) - { - return offsets[tdigest_index + 1] - offsets[tdigest_index]; - } -}; - /** * @brief Given a column_view containing tdigest data, an instance of this class * provides a wrapper on the compound column for tdigest operations. @@ -127,6 +109,22 @@ class tdigest_column_view : private column_view { */ [[nodiscard]] column_view weights() const; + /** + * @brief Functor to compute the size of each tdigest of a column. + */ + struct tdigest_size_fn { + size_type const* offsets; ///< Offsets of the t-digest column + /** + * @brief Returns size of the each tdigest in the column + * + * @param tdigest_index Index of the tdigest in the column + * @return Size of the tdigest + */ + __device__ size_type operator()(size_type tdigest_index) + { + return offsets[tdigest_index + 1] - offsets[tdigest_index]; + } + }; /** * @brief Returns an iterator that returns the size of each tdigest * in the column (each row is 1 digest) @@ -136,7 +134,7 @@ class tdigest_column_view : private column_view { [[nodiscard]] auto size_begin() const { return cudf::detail::make_counting_transform_iterator( - 0, tdigest_size{centroids().offsets_begin()}); + 0, tdigest_size_fn{centroids().offsets_begin()}); } /** diff --git a/cpp/include/cudf_test/tdigest_utilities.cuh b/cpp/include/cudf_test/tdigest_utilities.cuh index 250f8ea8580..11a8d8715a0 100644 --- a/cpp/include/cudf_test/tdigest_utilities.cuh +++ b/cpp/include/cudf_test/tdigest_utilities.cuh @@ -16,16 +16,14 @@ #pragma once +#include + #include #include #include #include #include -#include - -#include - #include #include #include @@ -102,6 +100,58 @@ struct tdigest_gen { // @endcond }; +template +inline T frand() +{ + return static_cast(rand()) / static_cast(RAND_MAX); +} + +template +inline T rand_range(T min, T max) +{ + return min + static_cast(frand() * (max - min)); +} + +inline std::unique_ptr generate_typed_percentile_distribution( + std::vector const& buckets, + std::vector const& sizes, + data_type t, + bool sorted = false) +{ + srand(0); + + std::vector values; + size_t total_size = std::reduce(sizes.begin(), sizes.end(), 0); + values.reserve(total_size); + for (size_t idx = 0; idx < sizes.size(); idx++) { + double min = idx == 0 ? 0.0f : buckets[idx - 1]; + double max = buckets[idx]; + + for (int v_idx = 0; v_idx < sizes[idx]; v_idx++) { + values.push_back(rand_range(min, max)); + } + } + + if (sorted) { std::sort(values.begin(), values.end()); } + + cudf::test::fixed_width_column_wrapper src(values.begin(), values.end()); + return cudf::cast(src, t); +} + +// "standardized" means the parameters sent into generate_typed_percentile_distribution. the intent +// is to provide a standardized set of inputs for use with tdigest generation tests and +// percentile_approx tests. std::vector +// buckets{10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0}; std::vector +// sizes{50000, 50000, 50000, 50000, 50000, 100000, 100000, 100000, 100000, 100000}; +inline std::unique_ptr generate_standardized_percentile_distribution( + data_type t = data_type{type_id::FLOAT64}, bool sorted = false) +{ + std::vector buckets{10.0f, 20.0f, 30.0f, 40.0f, 50.0f, 60.0f, 70.0f, 80.0, 90.0f, 100.0f}; + std::vector b_sizes{ + 50000, 50000, 50000, 50000, 50000, 100000, 100000, 100000, 100000, 100000}; + return generate_typed_percentile_distribution(buckets, b_sizes, t, sorted); +} + /** * @brief Compare a tdigest column against a sampling of expected values. */ diff --git a/cpp/src/quantiles/tdigest/tdigest_column_view.cpp b/cpp/src/quantiles/tdigest/tdigest_column_view.cpp index a86b40fd64a..ee4d0304117 100644 --- a/cpp/src/quantiles/tdigest/tdigest_column_view.cpp +++ b/cpp/src/quantiles/tdigest/tdigest_column_view.cpp @@ -22,8 +22,6 @@ namespace cudf { namespace tdigest { -using namespace cudf; - tdigest_column_view::tdigest_column_view(column_view const& col) : column_view(col) { // sanity check that this is actually tdigest data diff --git a/cpp/tests/CMakeLists.txt b/cpp/tests/CMakeLists.txt index 8675dc891c1..5ff2e9bf6d6 100644 --- a/cpp/tests/CMakeLists.txt +++ b/cpp/tests/CMakeLists.txt @@ -146,7 +146,7 @@ ConfigureTest(HASH_MAP_TEST hash_map/map_test.cu) # ################################################################################################## # * quantiles tests ------------------------------------------------------------------------------- ConfigureTest( - QUANTILES_TEST quantiles/percentile_approx_test.cu quantiles/quantile_test.cpp + QUANTILES_TEST quantiles/percentile_approx_test.cpp quantiles/quantile_test.cpp quantiles/quantiles_test.cpp ) diff --git a/cpp/tests/groupby/groupby_test_util.hpp b/cpp/tests/groupby/groupby_test_util.hpp index b333d9dacba..17d69b3a464 100644 --- a/cpp/tests/groupby/groupby_test_util.hpp +++ b/cpp/tests/groupby/groupby_test_util.hpp @@ -131,57 +131,5 @@ inline void test_single_scan(column_view const& keys, expect_vals, *result.second[0].results[0], debug_output_level::ALL_ERRORS); } -template -inline T frand() -{ - return static_cast(rand()) / static_cast(RAND_MAX); -} - -template -inline T rand_range(T min, T max) -{ - return min + static_cast(frand() * (max - min)); -} - -inline std::unique_ptr generate_typed_percentile_distribution( - std::vector const& buckets, - std::vector const& sizes, - data_type t, - bool sorted = false) -{ - srand(0); - - std::vector values; - size_t total_size = std::reduce(sizes.begin(), sizes.end(), 0); - values.reserve(total_size); - for (size_t idx = 0; idx < sizes.size(); idx++) { - double min = idx == 0 ? 0.0f : buckets[idx - 1]; - double max = buckets[idx]; - - for (int v_idx = 0; v_idx < sizes[idx]; v_idx++) { - values.push_back(rand_range(min, max)); - } - } - - if (sorted) { std::sort(values.begin(), values.end()); } - - cudf::test::fixed_width_column_wrapper src(values.begin(), values.end()); - return cudf::cast(src, t); -} - -// "standardized" means the parameters sent into generate_typed_percentile_distribution. the intent -// is to provide a standardized set of inputs for use with tdigest generation tests and -// percentile_approx tests. std::vector -// buckets{10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0}; std::vector -// sizes{50000, 50000, 50000, 50000, 50000, 100000, 100000, 100000, 100000, 100000}; -inline std::unique_ptr generate_standardized_percentile_distribution( - data_type t = data_type{type_id::FLOAT64}, bool sorted = false) -{ - std::vector buckets{10.0f, 20.0f, 30.0f, 40.0f, 50.0f, 60.0f, 70.0f, 80.0, 90.0f, 100.0f}; - std::vector b_sizes{ - 50000, 50000, 50000, 50000, 50000, 100000, 100000, 100000, 100000, 100000}; - return generate_typed_percentile_distribution(buckets, b_sizes, t, sorted); -} - } // namespace test } // namespace cudf diff --git a/cpp/tests/quantiles/percentile_approx_test.cu b/cpp/tests/quantiles/percentile_approx_test.cpp similarity index 69% rename from cpp/tests/quantiles/percentile_approx_test.cu rename to cpp/tests/quantiles/percentile_approx_test.cpp index b02b7d6c336..c7db8894a23 100644 --- a/cpp/tests/quantiles/percentile_approx_test.cu +++ b/cpp/tests/quantiles/percentile_approx_test.cpp @@ -13,56 +13,47 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include + +#include +#include +#include +#include +#include #include -#include #include #include #include +#include #include #include -#include #include +#include -#include -#include -#include -#include - -#include - -#include - -#include -#include -#include - -using namespace cudf; -using namespace cudf::tdigest; +#include -std::unique_ptr arrow_percentile_approx(column_view const& _values, - int delta, - std::vector const& percentages) +std::unique_ptr arrow_percentile_approx(cudf::column_view const& _values, + int delta, + std::vector const& percentages) { // sort the incoming values using the same settings that groupby does. // this is a little weak because null_order::AFTER is hardcoded internally to groupby. - table_view t({_values}); - auto sorted_t = cudf::sort(t, {}, {null_order::AFTER}); + cudf::table_view t({_values}); + auto sorted_t = cudf::sort(t, {}, {cudf::null_order::AFTER}); auto sorted_values = sorted_t->get_column(0).view(); std::vector h_values(sorted_values.size()); - cudaMemcpy(h_values.data(), - sorted_values.data(), - sizeof(double) * sorted_values.size(), - cudaMemcpyDeviceToHost); + CUDF_CUDA_TRY(cudaMemcpy(h_values.data(), + sorted_values.data(), + sizeof(double) * sorted_values.size(), + cudaMemcpyDeviceToHost)); std::vector h_validity(sorted_values.size()); if (sorted_values.null_mask() != nullptr) { auto validity = cudf::mask_to_bools(sorted_values.null_mask(), 0, sorted_values.size()); - cudaMemcpy(h_validity.data(), - (validity->view().data()), - sizeof(char) * sorted_values.size(), - cudaMemcpyDeviceToHost); + CUDF_CUDA_TRY(cudaMemcpy(h_validity.data(), + (validity->view().data()), + sizeof(char) * sorted_values.size(), + cudaMemcpyDeviceToHost)); } // generate the tdigest @@ -79,8 +70,8 @@ std::unique_ptr arrow_percentile_approx(column_view const& _values, return atd.Quantile(p); }); cudf::test::fixed_width_column_wrapper result(h_result.begin(), h_result.end()); - cudf::test::fixed_width_column_wrapper offsets{ - 0, static_cast(percentages.size())}; + cudf::test::fixed_width_column_wrapper offsets{ + 0, static_cast(percentages.size())}; return cudf::make_lists_column(1, offsets.release(), result.release(), 0, {}); } @@ -89,18 +80,18 @@ struct percentile_approx_dispatch { typename T, typename Func, typename std::enable_if_t() || cudf::is_fixed_point()>* = nullptr> - std::unique_ptr operator()(Func op, - column_view const& values, - int delta, - std::vector const& percentages, - size_type ulps) + std::unique_ptr operator()(Func op, + cudf::column_view const& values, + int delta, + std::vector const& percentages, + cudf::size_type ulps) { // arrow implementation. auto expected = [&]() { // we're explicitly casting back to doubles here but this is ok because that is // exactly what happens inside of the cudf implementation as values are processed as well. so // this should not affect results. - auto as_doubles = cudf::cast(values, data_type{type_id::FLOAT64}); + auto as_doubles = cudf::cast(values, cudf::data_type{cudf::type_id::FLOAT64}); return arrow_percentile_approx(*as_doubles, delta, percentages); }(); @@ -109,7 +100,7 @@ struct percentile_approx_dispatch { cudf::test::fixed_width_column_wrapper g_percentages(percentages.begin(), percentages.end()); - tdigest_column_view tdv(*agg_result); + cudf::tdigest::tdigest_column_view tdv(*agg_result); auto result = cudf::percentile_approx(tdv, g_percentages); cudf::test::expect_columns_equivalent( @@ -122,21 +113,21 @@ struct percentile_approx_dispatch { typename T, typename Func, typename std::enable_if_t() && !cudf::is_fixed_point()>* = nullptr> - std::unique_ptr operator()(Func op, - column_view const& values, - int delta, - std::vector const& percentages, - size_type ulps) + std::unique_ptr operator()(Func op, + cudf::column_view const& values, + int delta, + std::vector const& percentages, + cudf::size_type ulps) { CUDF_FAIL("Invalid input type for percentile_approx test"); } }; -void percentile_approx_test(column_view const& _keys, - column_view const& _values, +void percentile_approx_test(cudf::column_view const& _keys, + cudf::column_view const& _values, int delta, std::vector const& percentages, - size_type ulps) + cudf::size_type ulps) { // first pass: validate the actual percentages we get per group. @@ -146,8 +137,8 @@ void percentile_approx_test(column_view const& _keys, cudf::table_view v({_values}); auto groups = pass1_gb.get_groups(v); // slice it all up so we have keys/columns for everything. - std::vector keys; - std::vector values; + std::vector keys; + std::vector values; for (size_t idx = 0; idx < groups.offsets.size() - 1; idx++) { auto k = cudf::slice(groups.keys->get_column(0), {groups.offsets[idx], groups.offsets[idx + 1]}); @@ -158,11 +149,11 @@ void percentile_approx_test(column_view const& _keys, values.push_back(v[0]); } - std::vector> groupby_parts; - std::vector> reduce_parts; + std::vector> groupby_parts; + std::vector> reduce_parts; for (size_t idx = 0; idx < values.size(); idx++) { // via groupby - auto groupby = [&](column_view const& values, int delta) { + auto groupby = [&](cudf::column_view const& values, int delta) { cudf::table_view t({keys[idx]}); cudf::groupby::groupby gb(t); std::vector requests; @@ -180,12 +171,12 @@ void percentile_approx_test(column_view const& _keys, ulps)); // via reduce - auto reduce = [](column_view const& values, int delta) { + auto reduce = [](cudf::column_view const& values, int delta) { // result is a scalar, but we want to extract out the underlying column auto scalar_result = cudf::reduce(values, *cudf::make_tdigest_aggregation(delta), - data_type{type_id::STRUCT}); + cudf::data_type{cudf::type_id::STRUCT}); auto tbl = static_cast(scalar_result.get())->view(); std::vector> cols; std::transform( @@ -206,11 +197,11 @@ void percentile_approx_test(column_view const& _keys, // second pass. run the percentile_approx with all the keys in one pass and make sure we get the // same results as the concatenated by-key results. - std::vector part_views; + std::vector part_views; std::transform(groupby_parts.begin(), groupby_parts.end(), std::back_inserter(part_views), - [](std::unique_ptr const& c) { return c->view(); }); + [](std::unique_ptr const& c) { return c->view(); }); auto expected = cudf::concatenate(part_views); cudf::groupby::groupby gb(k); @@ -222,22 +213,20 @@ void percentile_approx_test(column_view const& _keys, cudf::test::fixed_width_column_wrapper g_percentages(percentages.begin(), percentages.end()); - tdigest_column_view tdv(*(gb_result.second[0].results[0])); + cudf::tdigest::tdigest_column_view tdv(*(gb_result.second[0].results[0])); auto result = cudf::percentile_approx(tdv, g_percentages); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*expected, *result); } -void simple_test(data_type input_type, std::vector> params) +void simple_test(cudf::data_type input_type, std::vector> params) { auto values = cudf::test::generate_standardized_percentile_distribution(input_type); // all in the same group auto keys = cudf::make_fixed_width_column( - data_type{type_id::INT32}, values->size(), mask_state::UNALLOCATED); - thrust::fill(rmm::exec_policy(cudf::get_default_stream()), - keys->mutable_view().template begin(), - keys->mutable_view().template end(), - 0); + cudf::data_type{cudf::type_id::INT32}, values->size(), cudf::mask_state::UNALLOCATED); + CUDF_CUDA_TRY( + cudaMemset(keys->mutable_view().data(), 0, values->size() * sizeof(int32_t))); // runs both groupby and reduce paths std::for_each(params.begin(), params.end(), [&](std::pair const& params) { @@ -247,21 +236,22 @@ void simple_test(data_type input_type, std::vector> params) } struct group_index { - __device__ int operator()(int i) { return i / 150000; } + int32_t operator()(int32_t i) { return i / 150000; } }; -void grouped_test(data_type input_type, std::vector> params) +void grouped_test(cudf::data_type input_type, std::vector> params) { auto values = cudf::test::generate_standardized_percentile_distribution(input_type); // all in the same group auto keys = cudf::make_fixed_width_column( - data_type{type_id::INT32}, values->size(), mask_state::UNALLOCATED); - auto i = thrust::make_counting_iterator(0); - thrust::transform(rmm::exec_policy(cudf::get_default_stream()), - i, - i + values->size(), - keys->mutable_view().template begin(), - group_index{}); + cudf::data_type{cudf::type_id::INT32}, values->size(), cudf::mask_state::UNALLOCATED); + auto i = thrust::make_counting_iterator(0); + auto h_keys = std::vector(values->size()); + std::transform(i, i + values->size(), h_keys.begin(), group_index{}); + CUDF_CUDA_TRY(cudaMemcpy(keys->mutable_view().data(), + h_keys.data(), + h_keys.size() * sizeof(int32_t), + cudaMemcpyHostToDevice)); std::for_each(params.begin(), params.end(), [&](std::pair const& params) { percentile_approx_test( @@ -269,25 +259,21 @@ void grouped_test(data_type input_type, std::vector> params) }); } -std::pair make_null_mask(column_view const& col) +std::pair make_null_mask(cudf::column_view const& col) { - return cudf::detail::valid_if( - thrust::make_counting_iterator(0), - thrust::make_counting_iterator(col.size()), - [] __device__(size_type i) { return i % 2 == 0; }, - cudf::get_default_stream()); + auto itr = cudf::detail::make_counting_transform_iterator(0, [](auto i) { return i % 2 == 0; }); + auto mask = cudf::test::detail::make_null_mask(itr, itr + col.size()); + return std::make_pair(std::move(mask), col.size() / 2); } -void simple_with_nulls_test(data_type input_type, std::vector> params) +void simple_with_nulls_test(cudf::data_type input_type, std::vector> params) { auto values = cudf::test::generate_standardized_percentile_distribution(input_type); // all in the same group auto keys = cudf::make_fixed_width_column( - data_type{type_id::INT32}, values->size(), mask_state::UNALLOCATED); - thrust::fill(rmm::exec_policy(cudf::get_default_stream()), - keys->mutable_view().template begin(), - keys->mutable_view().template end(), - 0); + cudf::data_type{cudf::type_id::INT32}, values->size(), cudf::mask_state::UNALLOCATED); + CUDF_CUDA_TRY( + cudaMemset(keys->mutable_view().data(), 0, values->size() * sizeof(int32_t))); // add a null mask auto mask = make_null_mask(*values); @@ -299,18 +285,19 @@ void simple_with_nulls_test(data_type input_type, std::vector> params) +void grouped_with_nulls_test(cudf::data_type input_type, std::vector> params) { auto values = cudf::test::generate_standardized_percentile_distribution(input_type); // all in the same group auto keys = cudf::make_fixed_width_column( - data_type{type_id::INT32}, values->size(), mask_state::UNALLOCATED); - auto i = thrust::make_counting_iterator(0); - thrust::transform(rmm::exec_policy(cudf::get_default_stream()), - i, - i + values->size(), - keys->mutable_view().template begin(), - group_index{}); + cudf::data_type{cudf::type_id::INT32}, values->size(), cudf::mask_state::UNALLOCATED); + auto i = thrust::make_counting_iterator(0); + auto h_keys = std::vector(values->size()); + std::transform(i, i + values->size(), h_keys.begin(), group_index{}); + CUDF_CUDA_TRY(cudaMemcpy(keys->mutable_view().data(), + h_keys.data(), + h_keys.size() * sizeof(int32_t), + cudaMemcpyHostToDevice)); // add a null mask auto mask = make_null_mask(*values); @@ -323,10 +310,10 @@ void grouped_with_nulls_test(data_type input_type, std::vector -data_type get_appropriate_type() +cudf::data_type get_appropriate_type() { - if constexpr (cudf::is_fixed_point()) { return data_type{cudf::type_to_id(), -7}; } - return data_type{cudf::type_to_id()}; + if constexpr (cudf::is_fixed_point()) { return cudf::data_type{cudf::type_to_id(), -7}; } + return cudf::data_type{cudf::type_to_id()}; } using PercentileApproxTypes = @@ -389,21 +376,21 @@ TEST_F(PercentileApproxTest, EmptyInput) auto empty_ = cudf::detail::tdigest::make_empty_tdigest_column(cudf::get_default_stream()); cudf::test::fixed_width_column_wrapper percentiles{0.0, 0.25, 0.3}; - std::vector input; + std::vector input; input.push_back(*empty_); input.push_back(*empty_); input.push_back(*empty_); auto empty = cudf::concatenate(input); - tdigest_column_view tdv(*empty); + cudf::tdigest::tdigest_column_view tdv(*empty); auto result = cudf::percentile_approx(tdv, percentiles); - cudf::test::fixed_width_column_wrapper offsets{0, 0, 0, 0}; + cudf::test::fixed_width_column_wrapper offsets{0, 0, 0, 0}; std::vector nulls{0, 0, 0}; auto expected = cudf::make_lists_column(3, offsets.release(), - cudf::make_empty_column(type_id::FLOAT64), + cudf::make_empty_column(cudf::type_id::FLOAT64), 3, cudf::test::detail::make_null_mask(nulls.begin(), nulls.end())); @@ -426,16 +413,18 @@ TEST_F(PercentileApproxTest, EmptyPercentiles) cudf::test::fixed_width_column_wrapper percentiles{}; - tdigest_column_view tdv(*tdigest_column.second[0].results[0]); + cudf::tdigest::tdigest_column_view tdv(*tdigest_column.second[0].results[0]); auto result = cudf::percentile_approx(tdv, percentiles); - cudf::test::fixed_width_column_wrapper offsets{0, 0, 0}; - auto expected = cudf::make_lists_column( - 2, - offsets.release(), - cudf::make_empty_column(type_id::FLOAT64), - 2, - cudf::detail::create_null_mask(2, mask_state::ALL_NULL, cudf::get_default_stream())); + cudf::test::fixed_width_column_wrapper offsets{0, 0, 0}; + std::vector nulls{0, 0}; + auto expected = + cudf::make_lists_column(2, + offsets.release(), + cudf::make_empty_column(cudf::type_id::FLOAT64), + 2, + cudf::test::detail::make_null_mask(nulls.begin(), nulls.end())); + // cudf::detail::create_null_mask(2, cudf::mask_state::ALL_NULL, cudf::get_default_stream())); CUDF_TEST_EXPECT_COLUMNS_EQUAL(*result, *expected); } @@ -454,7 +443,7 @@ TEST_F(PercentileApproxTest, NullPercentiles) requests.push_back({values, std::move(aggregations)}); auto tdigest_column = gb.aggregate(requests); - tdigest_column_view tdv(*tdigest_column.second[0].results[0]); + cudf::tdigest::tdigest_column_view tdv(*tdigest_column.second[0].results[0]); cudf::test::fixed_width_column_wrapper npercentiles{{0.5, 0.5, 1.0, 1.0}, {0, 0, 1, 1}}; auto result = cudf::percentile_approx(tdv, npercentiles); diff --git a/cpp/tests/quantiles/quantile_test.cpp b/cpp/tests/quantiles/quantile_test.cpp index 20acdd02a93..d95ee992510 100644 --- a/cpp/tests/quantiles/quantile_test.cpp +++ b/cpp/tests/quantiles/quantile_test.cpp @@ -14,26 +14,22 @@ * limitations under the License. */ -#include -#include -#include -#include #include #include #include #include #include + +#include +//#include +#include +#include + #include #include #include #include -using namespace cudf::test; - -using cudf::null_order; -using cudf::order; -using std::vector; - namespace { struct q_res { q_res(double value, bool is_valid = true) : is_valid(is_valid), value(value) {} @@ -77,9 +73,9 @@ struct q_expect { template struct test_case { - fixed_width_column_wrapper column; - vector expectations; - fixed_width_column_wrapper ordered_indices; + cudf::test::fixed_width_column_wrapper column; + std::vector expectations; + cudf::test::fixed_width_column_wrapper ordered_indices; }; // interpolate_center @@ -104,7 +100,7 @@ test_case interpolate_center() }(); auto max_d = static_cast(max); auto low_d = static_cast(low); - return test_case{fixed_width_column_wrapper({low, max}), + return test_case{cudf::test::fixed_width_column_wrapper({low, max}), {q_expect{0.50, max_d, low_d, lin_d, mid_d, low_d}}}; } @@ -116,7 +112,7 @@ test_case interpolate_center() auto mid_d = 0.5; auto low_d = static_cast(low); auto max_d = static_cast(max); - return test_case{fixed_width_column_wrapper({low, max}), + return test_case{cudf::test::fixed_width_column_wrapper({low, max}), {q_expect{0.5, max_d, low_d, mid_d, mid_d, low_d}}}; } @@ -130,7 +126,7 @@ test_case interpolate_extrema_high() auto low_d = static_cast(low); auto max_d = static_cast(max); auto exact_d = static_cast(max - 1); - return test_case{fixed_width_column_wrapper({low, max}), + return test_case{cudf::test::fixed_width_column_wrapper({low, max}), {q_expect{0.50, max_d, low_d, exact_d, exact_d, low_d}}}; } @@ -151,7 +147,7 @@ test_case interpolate_extrema_low() auto a_d = static_cast(a); auto b_d = static_cast(b); auto exact_d = static_cast(a + 1); - return test_case{fixed_width_column_wrapper({a, b}), + return test_case{cudf::test::fixed_width_column_wrapper({a, b}), {q_expect{0.50, b_d, a_d, exact_d, exact_d, a_d}}}; } @@ -166,7 +162,7 @@ test_case interpolate_extrema_low() template std::enable_if_t, test_case> single() { - return test_case{fixed_width_column_wrapper({7.309999942779541}), + return test_case{cudf::test::fixed_width_column_wrapper({7.309999942779541}), { q_expect{ -1.0, @@ -198,13 +194,15 @@ std::enable_if_t, test_case> single() template std::enable_if_t and not cudf::is_boolean(), test_case> single() { - return test_case{fixed_width_column_wrapper({1}), {q_expect{0.7, 1, 1, 1, 1, 1}}}; + return test_case{cudf::test::fixed_width_column_wrapper({1}), + {q_expect{0.7, 1, 1, 1, 1, 1}}}; } template std::enable_if_t(), test_case> single() { - return test_case{fixed_width_column_wrapper({1}), {q_expect{0.7, 1.0, 1.0, 1.0, 1.0, 1.0}}}; + return test_case{cudf::test::fixed_width_column_wrapper({1}), + {q_expect{0.7, 1.0, 1.0, 1.0, 1.0, 1.0}}}; } // all_invalid @@ -213,25 +211,25 @@ template std::enable_if_t, test_case> all_invalid() { return test_case{ - fixed_width_column_wrapper({6.8, 0.15, 3.4, 4.17, 2.13, 1.11, -1.01, 0.8, 5.7}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}), + cudf::test::fixed_width_column_wrapper({6.8, 0.15, 3.4, 4.17, 2.13, 1.11, -1.01, 0.8, 5.7}, + {0, 0, 0, 0, 0, 0, 0, 0, 0}), {q_expect{-1.0}, q_expect{0.0}, q_expect{0.5}, q_expect{1.0}, q_expect{2.0}}}; } template std::enable_if_t and not cudf::is_boolean(), test_case> all_invalid() { - return test_case{ - fixed_width_column_wrapper({6, 0, 3, 4, 2, 1, -1, 1, 6}, {0, 0, 0, 0, 0, 0, 0, 0, 0}), - {q_expect{0.7}}}; + return test_case{cudf::test::fixed_width_column_wrapper({6, 0, 3, 4, 2, 1, -1, 1, 6}, + {0, 0, 0, 0, 0, 0, 0, 0, 0}), + {q_expect{0.7}}}; } template std::enable_if_t(), test_case> all_invalid() { - return test_case{ - fixed_width_column_wrapper({1, 0, 1, 1, 0, 1, 0, 1, 1}, {0, 0, 0, 0, 0, 0, 0, 0, 0}), - {q_expect{0.7}}}; + return test_case{cudf::test::fixed_width_column_wrapper({1, 0, 1, 1, 0, 1, 0, 1, 1}, + {0, 0, 0, 0, 0, 0, 0, 0, 0}), + {q_expect{0.7}}}; } // some invalid @@ -244,14 +242,14 @@ std::enable_if_t, test_case> some_invalid() T mid = -0.432; T lin = -0.432; return test_case{ - fixed_width_column_wrapper({6.8, high, 3.4, 4.17, 2.13, 1.11, low, 0.8, 5.7}, - {0, 1, 0, 0, 0, 0, 1, 0, 0}), + cudf::test::fixed_width_column_wrapper({6.8, high, 3.4, 4.17, 2.13, 1.11, low, 0.8, 5.7}, + {0, 1, 0, 0, 0, 0, 1, 0, 0}), {q_expect{-1.0, low, low, low, low, low}, q_expect{0.0, low, low, low, low, low}, q_expect{0.5, high, low, lin, mid, low}, q_expect{1.0, high, high, high, high, high}, q_expect{2.0, high, high, high, high, high}}, - fixed_width_column_wrapper({6, 1})}; + cudf::test::fixed_width_column_wrapper({6, 1})}; } template @@ -261,7 +259,7 @@ std::enable_if_t, test_case> some_invalid() T low = -1.024; double mid = -0.43200002610683441; double lin = -0.43200002610683441; - return test_case{fixed_width_column_wrapper( + return test_case{cudf::test::fixed_width_column_wrapper( {T(6.8), high, T(3.4), T(4.17), T(2.13), T(1.11), low, T(0.8), T(5.7)}, {0, 1, 0, 0, 0, 0, 1, 0, 0}), {q_expect{-1.0, low, low, low, low, low}, @@ -269,29 +267,29 @@ std::enable_if_t, test_case> some_invalid() q_expect{0.5, high, low, lin, mid, low}, q_expect{1.0, high, high, high, high, high}, q_expect{2.0, high, high, high, high, high}}, - fixed_width_column_wrapper({6, 1})}; + cudf::test::fixed_width_column_wrapper({6, 1})}; } template std::enable_if_t and not cudf::is_boolean(), test_case> some_invalid() { - return test_case{ - fixed_width_column_wrapper({6, 0, 3, 4, 2, 1, -1, 1, 6}, {0, 0, 1, 0, 0, 0, 0, 0, 1}), - {q_expect{0.0, 3.0, 3.0, 3.0, 3.0, 3.0}, - q_expect{0.5, 6.0, 3.0, 4.5, 4.5, 3.0}, - q_expect{1.0, 6.0, 6.0, 6.0, 6.0, 6.0}}, - fixed_width_column_wrapper({2, 8})}; + return test_case{cudf::test::fixed_width_column_wrapper({6, 0, 3, 4, 2, 1, -1, 1, 6}, + {0, 0, 1, 0, 0, 0, 0, 0, 1}), + {q_expect{0.0, 3.0, 3.0, 3.0, 3.0, 3.0}, + q_expect{0.5, 6.0, 3.0, 4.5, 4.5, 3.0}, + q_expect{1.0, 6.0, 6.0, 6.0, 6.0, 6.0}}, + cudf::test::fixed_width_column_wrapper({2, 8})}; } template std::enable_if_t(), test_case> some_invalid() { - return test_case{ - fixed_width_column_wrapper({1, 0, 1, 1, 0, 1, 0, 1, 1}, {0, 0, 1, 0, 1, 0, 0, 0, 0}), - {q_expect{0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, - q_expect{0.5, 1.0, 0.0, 0.5, 0.5, 0.0}, - q_expect{1.0, 1.0, 1.0, 1.0, 1.0, 1.0}}, - fixed_width_column_wrapper({4, 2})}; + return test_case{cudf::test::fixed_width_column_wrapper({1, 0, 1, 1, 0, 1, 0, 1, 1}, + {0, 0, 1, 0, 1, 0, 0, 0, 0}), + {q_expect{0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, + q_expect{0.5, 1.0, 0.0, 0.5, 0.5, 0.0}, + q_expect{1.0, 1.0, 1.0, 1.0, 1.0, 1.0}}, + cudf::test::fixed_width_column_wrapper({4, 2})}; } // unsorted @@ -300,38 +298,41 @@ template std::enable_if_t, test_case> unsorted() { return test_case{ - fixed_width_column_wrapper({6.8, 0.15, 3.4, 4.17, 2.13, 1.11, -1.00, 0.8, 5.7}), + cudf::test::fixed_width_column_wrapper({6.8, 0.15, 3.4, 4.17, 2.13, 1.11, -1.00, 0.8, 5.7}), { q_expect{0.0, -1.00, -1.00, -1.00, -1.00, -1.00}, }, - fixed_width_column_wrapper({6, 1, 7, 5, 4, 2, 3, 8, 0})}; + cudf::test::fixed_width_column_wrapper({6, 1, 7, 5, 4, 2, 3, 8, 0})}; } template std::enable_if_t and not cudf::is_boolean(), test_case> unsorted() { return std::is_signed() - ? test_case{fixed_width_column_wrapper({6, 0, 3, 4, 2, 1, -1, 1, 6}), + ? test_case{cudf::test::fixed_width_column_wrapper({6, 0, 3, 4, 2, 1, -1, 1, 6}), {q_expect{0.0, -1, -1, -1, -1, -1}}, - fixed_width_column_wrapper({6, 1, 7, 5, 4, 2, 3, 8, 0})} - : test_case{fixed_width_column_wrapper({6, 0, 3, 4, 2, 1, 1, 1, 6}), + cudf::test::fixed_width_column_wrapper( + {6, 1, 7, 5, 4, 2, 3, 8, 0})} + : test_case{cudf::test::fixed_width_column_wrapper({6, 0, 3, 4, 2, 1, 1, 1, 6}), {q_expect{0.0, 1, 1, 1, 1, 1}}, - fixed_width_column_wrapper({6, 1, 7, 5, 4, 2, 3, 8, 0})}; + cudf::test::fixed_width_column_wrapper( + {6, 1, 7, 5, 4, 2, 3, 8, 0})}; } template std::enable_if_t(), test_case> unsorted() { - return test_case{fixed_width_column_wrapper({0, 0, 1, 1, 0, 1, 1, 0, 1}), - {q_expect{ - 0.0, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0, - }}, - fixed_width_column_wrapper({0, 1, 4, 7, 2, 3, 5, 6, 9})}; + return test_case{ + cudf::test::fixed_width_column_wrapper({0, 0, 1, 1, 0, 1, 1, 0, 1}), + {q_expect{ + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + }}, + cudf::test::fixed_width_column_wrapper({0, 1, 4, 7, 2, 3, 5, 6, 9})}; } } // namespace testdata @@ -342,40 +343,39 @@ std::enable_if_t(), test_case> unsorted() template void test(testdata::test_case test_case) { - using namespace cudf; - for (auto& expected : test_case.expectations) { auto q = std::vector{expected.quantile}; auto nullable = static_cast(test_case.column).nullable(); auto make_expected_column = [nullable](q_res expected) { - return nullable ? fixed_width_column_wrapper({expected.value}, {expected.is_valid}) - : fixed_width_column_wrapper({expected.value}); + return nullable ? cudf::test::fixed_width_column_wrapper({expected.value}, + {expected.is_valid}) + : cudf::test::fixed_width_column_wrapper({expected.value}); }; auto actual_higher = - quantile(test_case.column, q, interpolation::HIGHER, test_case.ordered_indices); + cudf::quantile(test_case.column, q, cudf::interpolation::HIGHER, test_case.ordered_indices); auto expected_higher_col = make_expected_column(expected.higher); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_higher_col, actual_higher->view()); auto actual_lower = - quantile(test_case.column, q, interpolation::LOWER, test_case.ordered_indices); + cudf::quantile(test_case.column, q, cudf::interpolation::LOWER, test_case.ordered_indices); auto expected_lower_col = make_expected_column(expected.lower); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_lower_col, actual_lower->view()); auto actual_linear = - quantile(test_case.column, q, interpolation::LINEAR, test_case.ordered_indices); + cudf::quantile(test_case.column, q, cudf::interpolation::LINEAR, test_case.ordered_indices); auto expected_linear_col = make_expected_column(expected.linear); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_linear_col, actual_linear->view()); auto actual_midpoint = - quantile(test_case.column, q, interpolation::MIDPOINT, test_case.ordered_indices); + cudf::quantile(test_case.column, q, cudf::interpolation::MIDPOINT, test_case.ordered_indices); auto expected_midpoint_col = make_expected_column(expected.midpoint); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_midpoint_col, actual_midpoint->view()); auto actual_nearest = - quantile(test_case.column, q, interpolation::NEAREST, test_case.ordered_indices); + cudf::quantile(test_case.column, q, cudf::interpolation::NEAREST, test_case.ordered_indices); auto expected_nearest_col = make_expected_column(expected.nearest); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_nearest_col, actual_nearest->view()); } @@ -385,10 +385,10 @@ void test(testdata::test_case test_case) // ----- tests ----------------------------------------------------------------- template -struct QuantileTest : public BaseFixture { +struct QuantileTest : public cudf::test::BaseFixture { }; -using TestTypes = NumericTypes; +using TestTypes = cudf::test::NumericTypes; TYPED_TEST_SUITE(QuantileTest, TestTypes); TYPED_TEST(QuantileTest, TestSingle) { test(testdata::single()); } @@ -413,60 +413,65 @@ TYPED_TEST(QuantileTest, TestInterpolateExtremaLow) TYPED_TEST(QuantileTest, TestEmpty) { - auto input = fixed_width_column_wrapper({}); + auto input = cudf::test::fixed_width_column_wrapper({}); auto expected = cudf::test::fixed_width_column_wrapper({0, 0}, {0, 0}); auto actual = cudf::quantile(input, {0.5, 0.25}); } template -struct QuantileUnsupportedTypesTest : public BaseFixture { +struct QuantileUnsupportedTypesTest : public cudf::test::BaseFixture { }; // TODO add tests for FixedPointTypes -using UnsupportedTestTypes = RemoveIf>, AllTypes>; +using UnsupportedTestTypes = cudf::test::RemoveIf< + cudf::test::ContainedIn>, + cudf::test::AllTypes>; TYPED_TEST_SUITE(QuantileUnsupportedTypesTest, UnsupportedTestTypes); TYPED_TEST(QuantileUnsupportedTypesTest, TestZeroElements) { - fixed_width_column_wrapper input({}); + cudf::test::fixed_width_column_wrapper input({}); EXPECT_THROW(cudf::quantile(input, {0}), cudf::logic_error); } TYPED_TEST(QuantileUnsupportedTypesTest, TestOneElements) { - fixed_width_column_wrapper input({0}); + cudf::test::fixed_width_column_wrapper input({0}); EXPECT_THROW(cudf::quantile(input, {0}), cudf::logic_error); } TYPED_TEST(QuantileUnsupportedTypesTest, TestMultipleElements) { - fixed_width_column_wrapper input({0, 1, 2}); + cudf::test::fixed_width_column_wrapper input({0, 1, 2}); EXPECT_THROW(cudf::quantile(input, {0}), cudf::logic_error); } -struct QuantileDictionaryTest : public BaseFixture { +struct QuantileDictionaryTest : public cudf::test::BaseFixture { }; TEST_F(QuantileDictionaryTest, TestValid) { - dictionary_column_wrapper col{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; - fixed_width_column_wrapper indices{0, 2, 4, 6, 8, 1, 3, 5, 7, 9}; + cudf::test::dictionary_column_wrapper col{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; + cudf::test::fixed_width_column_wrapper indices{0, 2, 4, 6, 8, 1, 3, 5, 7, 9}; auto result = cudf::quantile(col, {0.5}, cudf::interpolation::LINEAR); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(result->view(), fixed_width_column_wrapper{5.5}); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(result->view(), + cudf::test::fixed_width_column_wrapper{5.5}); result = cudf::quantile(col, {0.5}, cudf::interpolation::LINEAR, indices); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(result->view(), fixed_width_column_wrapper{5.5}); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(result->view(), + cudf::test::fixed_width_column_wrapper{5.5}); result = cudf::quantile(col, {0.1, 0.2}, cudf::interpolation::HIGHER); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(result->view(), fixed_width_column_wrapper{2.0, 3.0}); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(result->view(), + cudf::test::fixed_width_column_wrapper{2.0, 3.0}); result = cudf::quantile(col, {0.25, 0.5, 0.75}, cudf::interpolation::MIDPOINT); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(result->view(), - fixed_width_column_wrapper{3.5, 5.5, 7.5}); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT( + result->view(), cudf::test::fixed_width_column_wrapper{3.5, 5.5, 7.5}); }; } // anonymous namespace diff --git a/cpp/tests/quantiles/quantiles_test.cpp b/cpp/tests/quantiles/quantiles_test.cpp index b4d1b9984ab..f532e93c6c2 100644 --- a/cpp/tests/quantiles/quantiles_test.cpp +++ b/cpp/tests/quantiles/quantiles_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, NVIDIA CORPORATION. + * Copyright (c) 2020-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,52 +20,45 @@ #include #include -#include -#include -#include - #include -#include #include -#include - -using namespace cudf; -using namespace test; +#include +#include template -struct QuantilesTest : public BaseFixture { +struct QuantilesTest : public cudf::test::BaseFixture { }; -using TestTypes = AllTypes; +using TestTypes = cudf::test::AllTypes; TYPED_TEST_SUITE(QuantilesTest, TestTypes); TYPED_TEST(QuantilesTest, TestZeroColumns) { - auto input = table_view(std::vector{}); + auto input = cudf::table_view(std::vector{}); - EXPECT_THROW(quantiles(input, {0.0f}), logic_error); + EXPECT_THROW(cudf::quantiles(input, {0.0f}), cudf::logic_error); } TYPED_TEST(QuantilesTest, TestMultiColumnZeroRows) { using T = TypeParam; - fixed_width_column_wrapper input_a({}); - auto input = table_view({input_a}); + cudf::test::fixed_width_column_wrapper input_a({}); + auto input = cudf::table_view({input_a}); - EXPECT_THROW(quantiles(input, {0.0f}), logic_error); + EXPECT_THROW(cudf::quantiles(input, {0.0f}), cudf::logic_error); } TYPED_TEST(QuantilesTest, TestZeroRequestedQuantiles) { using T = TypeParam; - fixed_width_column_wrapper input_a({1}, {1}); - auto input = table_view(std::vector{input_a}); + cudf::test::fixed_width_column_wrapper input_a({1}, {1}); + auto input = cudf::table_view(std::vector{input_a}); - auto actual = quantiles(input, {}); - auto expected = empty_like(input); + auto actual = cudf::quantiles(input, {}); + auto expected = cudf::empty_like(input); CUDF_TEST_EXPECT_TABLES_EQUAL(expected->view(), actual->view()); } @@ -74,75 +67,75 @@ TYPED_TEST(QuantilesTest, TestMultiColumnOrderCountMismatch) { using T = TypeParam; - fixed_width_column_wrapper input_a({}); - fixed_width_column_wrapper input_b({}); - auto input = table_view({input_a}); - - EXPECT_THROW(quantiles(input, - {0.0f}, - interpolation::NEAREST, - sorted::NO, - {order::ASCENDING}, - {null_order::AFTER, null_order::AFTER}), - logic_error); + cudf::test::fixed_width_column_wrapper input_a({}); + cudf::test::fixed_width_column_wrapper input_b({}); + auto input = cudf::table_view({input_a}); + + EXPECT_THROW(cudf::quantiles(input, + {0.0f}, + cudf::interpolation::NEAREST, + cudf::sorted::NO, + {cudf::order::ASCENDING}, + {cudf::null_order::AFTER, cudf::null_order::AFTER}), + cudf::logic_error); } TYPED_TEST(QuantilesTest, TestMultiColumnNullOrderCountMismatch) { using T = TypeParam; - fixed_width_column_wrapper input_a({}); - fixed_width_column_wrapper input_b({}); - auto input = table_view({input_a}); - - EXPECT_THROW(quantiles(input, - {0.0f}, - interpolation::NEAREST, - sorted::NO, - {order::ASCENDING, order::ASCENDING}, - {null_order::AFTER}), - logic_error); + cudf::test::fixed_width_column_wrapper input_a({}); + cudf::test::fixed_width_column_wrapper input_b({}); + auto input = cudf::table_view({input_a}); + + EXPECT_THROW(cudf::quantiles(input, + {0.0f}, + cudf::interpolation::NEAREST, + cudf::sorted::NO, + {cudf::order::ASCENDING, cudf::order::ASCENDING}, + {cudf::null_order::AFTER}), + cudf::logic_error); } TYPED_TEST(QuantilesTest, TestMultiColumnArithmeticInterpolation) { using T = TypeParam; - fixed_width_column_wrapper input_a({}); - fixed_width_column_wrapper input_b({}); - auto input = table_view({input_a}); + cudf::test::fixed_width_column_wrapper input_a({}); + cudf::test::fixed_width_column_wrapper input_b({}); + auto input = cudf::table_view({input_a}); - EXPECT_THROW(quantiles(input, {0.0f}, interpolation::LINEAR), logic_error); + EXPECT_THROW(cudf::quantiles(input, {0.0f}, cudf::interpolation::LINEAR), cudf::logic_error); - EXPECT_THROW(quantiles(input, {0.0f}, interpolation::MIDPOINT), logic_error); + EXPECT_THROW(cudf::quantiles(input, {0.0f}, cudf::interpolation::MIDPOINT), cudf::logic_error); } TYPED_TEST(QuantilesTest, TestMultiColumnUnsorted) { using T = TypeParam; - auto input_a = strings_column_wrapper( + auto input_a = cudf::test::strings_column_wrapper( {"C", "B", "A", "A", "D", "B", "D", "B", "D", "C", "C", "C", "D", "B", "D", "B", "C", "C", "A", "D", "B", "A", "A", "A"}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}); - fixed_width_column_wrapper input_b( + cudf::test::fixed_width_column_wrapper input_b( {4, 3, 5, 0, 1, 0, 4, 1, 5, 3, 0, 5, 2, 4, 3, 2, 1, 2, 3, 0, 5, 1, 4, 2}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}); - auto input = table_view({input_a, input_b}); + auto input = cudf::table_view({input_a, input_b}); - auto actual = quantiles(input, - {0.0f, 0.5f, 0.7f, 0.25f, 1.0f}, - interpolation::NEAREST, - sorted::NO, - {order::ASCENDING, order::DESCENDING}); + auto actual = cudf::quantiles(input, + {0.0f, 0.5f, 0.7f, 0.25f, 1.0f}, + cudf::interpolation::NEAREST, + cudf::sorted::NO, + {cudf::order::ASCENDING, cudf::order::DESCENDING}); - auto expected_a = strings_column_wrapper({"A", "C", "C", "B", "D"}, {1, 1, 1, 1, 1}); + auto expected_a = cudf::test::strings_column_wrapper({"A", "C", "C", "B", "D"}, {1, 1, 1, 1, 1}); - fixed_width_column_wrapper expected_b({5, 5, 1, 5, 0}, {1, 1, 1, 1, 1}); + cudf::test::fixed_width_column_wrapper expected_b({5, 5, 1, 5, 0}, {1, 1, 1, 1, 1}); - auto expected = table_view({expected_a, expected_b}); + auto expected = cudf::table_view({expected_a, expected_b}); CUDF_TEST_EXPECT_TABLES_EQUAL(expected, actual->view()); } @@ -151,25 +144,25 @@ TYPED_TEST(QuantilesTest, TestMultiColumnAssumedSorted) { using T = TypeParam; - auto input_a = strings_column_wrapper( + auto input_a = cudf::test::strings_column_wrapper( {"C", "B", "A", "A", "D", "B", "D", "B", "D", "C", "C", "C", "D", "B", "D", "B", "C", "C", "A", "D", "B", "A", "A", "A"}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}); - fixed_width_column_wrapper input_b( + cudf::test::fixed_width_column_wrapper input_b( {4, 3, 5, 0, 1, 0, 4, 1, 5, 3, 0, 5, 2, 4, 3, 2, 1, 2, 3, 0, 5, 1, 4, 2}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}); - auto input = table_view({input_a, input_b}); + auto input = cudf::table_view({input_a, input_b}); - auto actual = - quantiles(input, {0.0f, 0.5f, 0.7f, 0.25f, 1.0f}, interpolation::NEAREST, sorted::YES); + auto actual = cudf::quantiles( + input, {0.0f, 0.5f, 0.7f, 0.25f, 1.0f}, cudf::interpolation::NEAREST, cudf::sorted::YES); - auto expected_a = strings_column_wrapper({"C", "D", "C", "D", "A"}, {1, 1, 1, 1, 1}); + auto expected_a = cudf::test::strings_column_wrapper({"C", "D", "C", "D", "A"}, {1, 1, 1, 1, 1}); - fixed_width_column_wrapper expected_b({4, 2, 1, 4, 2}, {1, 1, 1, 1, 1}); + cudf::test::fixed_width_column_wrapper expected_b({4, 2, 1, 4, 2}, {1, 1, 1, 1, 1}); - auto expected = table_view({expected_a, expected_b}); + auto expected = cudf::table_view({expected_a, expected_b}); CUDF_TEST_EXPECT_TABLES_EQUAL(expected, actual->view()); } diff --git a/cpp/tests/quantiles/tdigest_utilities.cu b/cpp/tests/utilities/tdigest_utilities.cu similarity index 100% rename from cpp/tests/quantiles/tdigest_utilities.cu rename to cpp/tests/utilities/tdigest_utilities.cu From 8eb7fc7e2c771003d33afdad43fe93513e7b5938 Mon Sep 17 00:00:00 2001 From: David Wendt Date: Wed, 2 Nov 2022 19:06:08 -0400 Subject: [PATCH 2/4] fix copyright years --- cpp/src/quantiles/tdigest/tdigest_column_view.cpp | 2 +- cpp/tests/groupby/groupby_test_util.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cpp/src/quantiles/tdigest/tdigest_column_view.cpp b/cpp/src/quantiles/tdigest/tdigest_column_view.cpp index ee4d0304117..df95c1d9da8 100644 --- a/cpp/src/quantiles/tdigest/tdigest_column_view.cpp +++ b/cpp/src/quantiles/tdigest/tdigest_column_view.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, NVIDIA CORPORATION. + * Copyright (c) 2021-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/cpp/tests/groupby/groupby_test_util.hpp b/cpp/tests/groupby/groupby_test_util.hpp index 17d69b3a464..83f522ed913 100644 --- a/cpp/tests/groupby/groupby_test_util.hpp +++ b/cpp/tests/groupby/groupby_test_util.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. From d58813ccc533fffd254a8406bc9c78ef7a9da3b4 Mon Sep 17 00:00:00 2001 From: David Wendt Date: Mon, 7 Nov 2022 09:32:26 -0500 Subject: [PATCH 3/4] alphabetize source file list in CMakeLists.txt --- cpp/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index a1ff781cd10..75de15bdf22 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -690,10 +690,10 @@ add_library(cudf::cudf ALIAS cudf) add_library( cudftestutil STATIC tests/io/metadata_utilities.cpp - tests/utilities/tdigest_utilities.cu tests/utilities/base_fixture.cpp tests/utilities/column_utilities.cu tests/utilities/table_utilities.cu + tests/utilities/tdigest_utilities.cu ) set_target_properties( From 19ecb3cf1729956ce5c148dc06d98d1c2c6bf136 Mon Sep 17 00:00:00 2001 From: David Wendt Date: Mon, 7 Nov 2022 09:32:37 -0500 Subject: [PATCH 4/4] remove commented out include --- cpp/tests/quantiles/quantile_test.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/cpp/tests/quantiles/quantile_test.cpp b/cpp/tests/quantiles/quantile_test.cpp index d95ee992510..6dfe4f5169b 100644 --- a/cpp/tests/quantiles/quantile_test.cpp +++ b/cpp/tests/quantiles/quantile_test.cpp @@ -21,7 +21,6 @@ #include #include -//#include #include #include