Skip to content

Commit

Permalink
more tests cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
karthikeyann committed Mar 22, 2021
1 parent bb5dfd7 commit c8e4b99
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 69 deletions.
2 changes: 1 addition & 1 deletion cpp/src/groupby/sort/group_argmax.cu
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2021, NVIDIA CORPORATION.
* Copyright (c) 2020, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/groupby/sort/group_argmin.cu
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2021, NVIDIA CORPORATION.
* Copyright (c) 2020, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/groupby/sort/group_collect.cu
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2021, NVIDIA CORPORATION.
* Copyright (c) 2020, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/groupby/sort/group_nth_element.cu
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2020, NVIDIA CORPORATION.
* Copyright (c) 2020, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/groupby/sort/group_nunique.cu
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2020, NVIDIA CORPORATION.
* Copyright (c) 2020, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 0 additions & 2 deletions cpp/src/groupby/sort/scan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
#include <rmm/cuda_stream_view.hpp>

#include <memory>
#include <unordered_map>
#include <utility>

namespace cudf {
namespace groupby {
Expand Down
124 changes: 62 additions & 62 deletions cpp/tests/groupby/group_count_scan_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,30 @@

namespace cudf {
namespace test {
template <typename V>
using K = int32_t;
using key_wrapper = fixed_width_column_wrapper<K>;

template <typename T>
struct groupby_count_scan_test : public cudf::test::BaseFixture {
using V = T;
using R = cudf::detail::target_type_t<V, aggregation::COUNT_ALL>;
using value_wrapper = fixed_width_column_wrapper<V, int32_t>;
using result_wrapper = fixed_width_column_wrapper<R, int32_t>;
};

TYPED_TEST_CASE(groupby_count_scan_test, cudf::test::AllTypes);

TYPED_TEST(groupby_count_scan_test, basic)
{
using K = int32_t;
using V = TypeParam;
using R = cudf::detail::target_type_t<V, aggregation::COUNT_ALL>;
using value_wrapper = typename TestFixture::value_wrapper;
using result_wrapper = typename TestFixture::result_wrapper;

// clang-format off
fixed_width_column_wrapper<K> keys { 1, 2, 3, 1, 2, 2, 1, 3, 3, 2};
fixed_width_column_wrapper<V, int> vals { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
key_wrapper keys {1, 2, 3, 1, 2, 2, 1, 3, 3, 2};
value_wrapper vals{0, 1, 2, 3, 4, 5, 6, 7, 8, 9};

fixed_width_column_wrapper<K> expect_keys {1, 1, 1, 2, 2, 2, 2, 3, 3, 3};
fixed_width_column_wrapper<R, int> expect_vals {0, 1, 2, 0, 1, 2, 3, 0, 1, 2};
key_wrapper expect_keys {1, 1, 1, 2, 2, 2, 2, 3, 3, 3};
result_wrapper expect_vals{0, 1, 2, 0, 1, 2, 3, 0, 1, 2};
// clang-format on

auto agg1 = cudf::make_count_aggregation();
Expand All @@ -54,16 +60,15 @@ TYPED_TEST(groupby_count_scan_test, basic)

TYPED_TEST(groupby_count_scan_test, empty_cols)
{
using K = int32_t;
using V = TypeParam;
using R = cudf::detail::target_type_t<V, aggregation::COUNT_ALL>;
using value_wrapper = typename TestFixture::value_wrapper;
using result_wrapper = typename TestFixture::result_wrapper;

// clang-format off
fixed_width_column_wrapper<K> keys;
fixed_width_column_wrapper<V> vals;
key_wrapper keys;
value_wrapper vals;

fixed_width_column_wrapper<K> expect_keys;
fixed_width_column_wrapper<R> expect_vals;
key_wrapper expect_keys;
result_wrapper expect_vals;
// clang-format on

auto agg1 = cudf::make_count_aggregation();
Expand All @@ -75,16 +80,15 @@ TYPED_TEST(groupby_count_scan_test, empty_cols)

TYPED_TEST(groupby_count_scan_test, zero_valid_keys)
{
using K = int32_t;
using V = TypeParam;
using R = cudf::detail::target_type_t<V, aggregation::COUNT_ALL>;
using value_wrapper = typename TestFixture::value_wrapper;
using result_wrapper = typename TestFixture::result_wrapper;

// clang-format off
fixed_width_column_wrapper<K> keys( { 1, 2, 3}, all_null() );
fixed_width_column_wrapper<V, int> vals { 3, 4, 5};
key_wrapper keys( {1, 2, 3}, all_null());
value_wrapper vals{3, 4, 5};

fixed_width_column_wrapper<K> expect_keys {};
fixed_width_column_wrapper<R, int> expect_vals{};
key_wrapper expect_keys{};
result_wrapper expect_vals{};
// clang-format on

auto agg2 = cudf::make_count_aggregation(null_policy::INCLUDE);
Expand All @@ -93,16 +97,15 @@ TYPED_TEST(groupby_count_scan_test, zero_valid_keys)

TYPED_TEST(groupby_count_scan_test, zero_valid_values)
{
using K = int32_t;
using V = TypeParam;
using R = cudf::detail::target_type_t<V, aggregation::COUNT_ALL>;
using value_wrapper = typename TestFixture::value_wrapper;
using result_wrapper = typename TestFixture::result_wrapper;

// clang-format off
fixed_width_column_wrapper<K> keys {1, 1, 1};
fixed_width_column_wrapper<V, int> vals ( {3, 4, 5}, all_null());
key_wrapper keys {1, 1, 1};
value_wrapper vals({3, 4, 5}, all_null());

fixed_width_column_wrapper<K> expect_keys {1, 1, 1};
fixed_width_column_wrapper<R, int> expect_vals{0, 1, 2};
key_wrapper expect_keys{1, 1, 1};
result_wrapper expect_vals{0, 1, 2};
// clang-format on

auto agg2 = cudf::make_count_aggregation(null_policy::INCLUDE);
Expand All @@ -111,20 +114,17 @@ TYPED_TEST(groupby_count_scan_test, zero_valid_values)

TYPED_TEST(groupby_count_scan_test, null_keys_and_values)
{
using K = int32_t;
using V = TypeParam;
using R = cudf::detail::target_type_t<V, aggregation::COUNT_ALL>;
using value_wrapper = typename TestFixture::value_wrapper;
using result_wrapper = typename TestFixture::result_wrapper;

// clang-format off
fixed_width_column_wrapper<K> keys( { 1, 2, 3, 1, 2, 2, 1, 3, 3, 2, 4},
{ 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1});
fixed_width_column_wrapper<V, int> vals({ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 4},
{ 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0});

// {1, 1, 1, 2, 2, 2, 2, 3, _, 3, 4}
fixed_width_column_wrapper<K> expect_keys({1, 1, 1, 2, 2, 2, 2, 3, 3, 4}, all_valid());
// {0, 3, 6, 1, 4, _, 9, 2, 7, 8, -}
fixed_width_column_wrapper<R, int> expect_vals {0, 1, 2, 0, 1, 2, 3, 0, 1, 0};
key_wrapper keys( {1, 2, 3, 1, 2, 2, 1, 3, 3, 2, 4}, {1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1});
value_wrapper vals({0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 4}, {0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0});

// {1, 1, 1, 2, 2, 2, 2, 3, _, 3, 4}
key_wrapper expect_keys( {1, 1, 1, 2, 2, 2, 2, 3, 3, 4}, all_valid());
// {0, 3, 6, 1, 4, _, 9, 2, 7, 8, -}
result_wrapper expect_vals{0, 1, 2, 0, 1, 2, 3, 0, 1, 0};
// clang-format on

auto agg2 = cudf::make_count_aggregation(null_policy::INCLUDE);
Expand All @@ -136,16 +136,16 @@ struct groupby_count_scan_string_test : public cudf::test::BaseFixture {

TEST_F(groupby_count_scan_string_test, basic)
{
using K = int32_t;
using V = cudf::string_view;
using R = cudf::detail::target_type_t<V, aggregation::COUNT_ALL>;
using V = cudf::string_view;
using R = cudf::detail::target_type_t<V, aggregation::COUNT_ALL>;
using result_wrapper = fixed_width_column_wrapper<R, int32_t>;

// clang-format off
fixed_width_column_wrapper<K> keys { 1, 3, 3, 5, 5, 0};
strings_column_wrapper vals { "1", "1", "1", "1", "1", "1"};
key_wrapper keys { 1, 3, 3, 5, 5, 0};
strings_column_wrapper vals{"1", "1", "1", "1", "1", "1"};

fixed_width_column_wrapper<K> expect_keys {0, 1, 3, 3, 5, 5};
fixed_width_column_wrapper<R, int> expect_vals{0, 0, 0, 1, 0, 1};
key_wrapper expect_keys {0, 1, 3, 3, 5, 5};
result_wrapper expect_vals{0, 0, 0, 1, 0, 1};
// clang-format on

auto agg2 = cudf::make_count_aggregation(null_policy::INCLUDE);
Expand All @@ -165,17 +165,17 @@ TYPED_TEST(FixedPointTestBothReps, GroupByCountScan)
using RepType = cudf::device_storage_type_t<decimalXX>;
using fp_wrapper = fixed_point_column_wrapper<RepType>;

using K = int32_t;
using V = decimalXX;
using R = cudf::detail::target_type_t<V, aggregation::COUNT_ALL>;
using V = decimalXX;
using R = cudf::detail::target_type_t<V, aggregation::COUNT_ALL>;
using result_wrapper = fixed_width_column_wrapper<R, int32_t>;

auto const scale = scale_type{-1};
// clang-format off
auto const keys = fixed_width_column_wrapper<K>{1, 2, 3, 1, 2, 2, 1, 3, 3, 2};
auto const vals = fp_wrapper{ {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, scale};
auto const keys = key_wrapper{1, 2, 3, 1, 2, 2, 1, 3, 3, 2};
auto const vals = fp_wrapper{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, scale};

auto const expect_keys = fixed_width_column_wrapper<K>{1, 1, 1, 2, 2, 2, 2, 3, 3, 3};
auto const expect_vals = fixed_width_column_wrapper<R, int>{0, 1, 2, 0, 1, 2, 3, 0, 1, 2};
auto const expect_keys = key_wrapper{1, 1, 1, 2, 2, 2, 2, 3, 3, 3};
auto const expect_vals = result_wrapper{0, 1, 2, 0, 1, 2, 3, 0, 1, 2};
// clang-format on

CUDF_EXPECT_THROW_MESSAGE(
Expand All @@ -191,15 +191,15 @@ struct groupby_dictionary_count_scan_test : public cudf::test::BaseFixture {

TEST_F(groupby_dictionary_count_scan_test, basic)
{
using K = int32_t;
using V = std::string;
using R = cudf::detail::target_type_t<V, aggregation::COUNT_ALL>;
using V = std::string;
using R = cudf::detail::target_type_t<V, aggregation::COUNT_ALL>;
using result_wrapper = fixed_width_column_wrapper<R, int32_t>;

// clang-format off
strings_column_wrapper keys{"1", "3", "3", "5", "5", "0"};
dictionary_column_wrapper<K> vals{ 1, 1, 1, 1, 1, 1};
strings_column_wrapper expect_keys{"0", "1", "3", "3", "5", "5"};
fixed_width_column_wrapper<R, int> expect_vals{ 0, 0, 0, 1, 0, 1};
strings_column_wrapper keys{"1", "3", "3", "5", "5", "0"};
dictionary_column_wrapper<K> vals{1, 1, 1, 1, 1, 1};
strings_column_wrapper expect_keys{"0", "1", "3", "3", "5", "5"};
result_wrapper expect_vals{0, 0, 0, 1, 0, 1};
// clang-format on

auto agg1 = cudf::make_count_aggregation();
Expand Down

0 comments on commit c8e4b99

Please sign in to comment.