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

Remove using namespace cudf; from libcudf gtests source #13089

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
14 changes: 7 additions & 7 deletions cpp/tests/io/orc_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -613,13 +613,13 @@ TEST_F(OrcWriterTest, negTimestampsNano)
// seconds from UNIX epoch is read as that timestamp + 1 second. We mimic that behavior and so
// this test has to hardcode test values which are < -1 second.
// Details: https://github.com/rapidsai/cudf/pull/5529#issuecomment-648768925
using namespace cudf::test;
auto timestamps_ns = fixed_width_column_wrapper<cudf::timestamp_ns, cudf::timestamp_ns::rep>{
-131968727238000000,
-1530705634500000000,
-1674638741932929000,
};
table_view expected({timestamps_ns});
auto timestamps_ns =
cudf::test::fixed_width_column_wrapper<cudf::timestamp_ns, cudf::timestamp_ns::rep>{
-131968727238000000,
-1530705634500000000,
-1674638741932929000,
};
cudf::table_view expected({timestamps_ns});

auto filepath = temp_env->get_temp_filepath("OrcNegTimestamp.orc");
cudf::io::orc_writer_options out_opts =
Expand Down
128 changes: 63 additions & 65 deletions cpp/tests/lists/extract_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,162 +271,160 @@ TYPED_TEST_SUITE(ListsExtractColumnIndicesTypedTest, cudf::test::FixedWidthTypes

TYPED_TEST(ListsExtractColumnIndicesTypedTest, ExtractElement)
{
using namespace cudf;
using namespace cudf::lists;
using namespace cudf::test;
using namespace cudf::test::iterators;
using LCW = lists_column_wrapper<TypeParam, int32_t>;
using FWCW = fixed_width_column_wrapper<TypeParam, int32_t>;
using indices = fixed_width_column_wrapper<offset_type>;
using LCW = cudf::test::lists_column_wrapper<TypeParam, int32_t>;
using FWCW = cudf::test::fixed_width_column_wrapper<TypeParam, int32_t>;
using indices = cudf::test::fixed_width_column_wrapper<cudf::offset_type>;

auto input_column =
LCW({LCW{3, 2, 1}, LCW{}, LCW{30, 20, 10, 50}, LCW{100, 120}, LCW{0}, LCW{}}, null_at(1));
auto input = lists_column_view(input_column);
auto input_column = LCW({LCW{3, 2, 1}, LCW{}, LCW{30, 20, 10, 50}, LCW{100, 120}, LCW{0}, LCW{}},
cudf::test::iterators::null_at(1));
auto input = cudf::lists_column_view(input_column);

{
// Test fetching first element.
auto result = extract_list_element(input, indices{0, 0, 0, 0, 0, 0});
auto expected = FWCW({3, 0, 30, 100, 0, 0}, nulls_at({1, 5}));
auto result = cudf::lists::extract_list_element(input, indices{0, 0, 0, 0, 0, 0});
auto expected = FWCW({3, 0, 30, 100, 0, 0}, cudf::test::iterators::nulls_at({1, 5}));
CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *result);
}
{
// Test fetching last element.
auto result = extract_list_element(input, indices{2, 0, 3, 1, 0, 0});
auto expected = FWCW({1, 0, 50, 120, 0, 0}, nulls_at({1, 5}));
auto result = cudf::lists::extract_list_element(input, indices{2, 0, 3, 1, 0, 0});
auto expected = FWCW({1, 0, 50, 120, 0, 0}, cudf::test::iterators::nulls_at({1, 5}));
CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *result);
}
{
// Test fetching *all* out of bounds.
auto result = extract_list_element(input, indices{9, 9, 9, 9, 9, 9});
auto expected = FWCW({0, 0, 0, 0, 0, 0}, all_nulls());
auto result = cudf::lists::extract_list_element(input, indices{9, 9, 9, 9, 9, 9});
auto expected = FWCW({0, 0, 0, 0, 0, 0}, cudf::test::iterators::all_nulls());
CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *result);
}
{
// Test fetching first from the end.
auto result = extract_list_element(input, indices{-1, -1, -1, -1, -1, -1});
auto expected = FWCW({1, 0, 50, 120, 0, 0}, nulls_at({1, 5}));
auto result = cudf::lists::extract_list_element(input, indices{-1, -1, -1, -1, -1, -1});
auto expected = FWCW({1, 0, 50, 120, 0, 0}, cudf::test::iterators::nulls_at({1, 5}));
CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *result);
}
{
// Test fetching last from the end.
auto result = extract_list_element(input, indices{-3, 0, -4, -2, -1, 0});
auto expected = FWCW({3, 0, 30, 100, 0, 0}, nulls_at({1, 5}));
auto result = cudf::lists::extract_list_element(input, indices{-3, 0, -4, -2, -1, 0});
auto expected = FWCW({3, 0, 30, 100, 0, 0}, cudf::test::iterators::nulls_at({1, 5}));
CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *result);
}
{
// Test fetching *all* negative out of bounds.
auto result = extract_list_element(input, indices{-9, -9, -9, -9, -9, -9});
auto expected = FWCW({0, 0, 0, 0, 0, 0}, all_nulls());
auto result = cudf::lists::extract_list_element(input, indices{-9, -9, -9, -9, -9, -9});
auto expected = FWCW({0, 0, 0, 0, 0, 0}, cudf::test::iterators::all_nulls());
CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *result);
}
{
// Test mixed indices.
auto result = extract_list_element(input, indices{-2, 0, 3, -1, 0, 0});
auto expected = FWCW({2, 0, 50, 120, 0, 0}, nulls_at({1, 5}));
auto result = cudf::lists::extract_list_element(input, indices{-2, 0, 3, -1, 0, 0});
auto expected = FWCW({2, 0, 50, 120, 0, 0}, cudf::test::iterators::nulls_at({1, 5}));
CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *result);
}
{
// Test possibly null indices.
auto result = extract_list_element(input, indices{{-2, 0, 3, -1, 0, 0}, nulls_at({2, 4})});
auto expected = FWCW({2, 0, 50, 120, 0, 0}, nulls_at({1, 2, 4, 5}));
auto result = cudf::lists::extract_list_element(
input, indices{{-2, 0, 3, -1, 0, 0}, cudf::test::iterators::nulls_at({2, 4})});
auto expected = FWCW({2, 0, 50, 120, 0, 0}, cudf::test::iterators::nulls_at({1, 2, 4, 5}));
CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *result);
}
}

TYPED_TEST(ListsExtractColumnIndicesTypedTest, FailureCases)
{
using namespace cudf;
using namespace cudf::lists;
using namespace cudf::test;
using namespace cudf::test::iterators;
using LCW = lists_column_wrapper<TypeParam, int32_t>;
using indices = fixed_width_column_wrapper<offset_type>;
using LCW = cudf::test::lists_column_wrapper<TypeParam, int32_t>;
using indices = cudf::test::fixed_width_column_wrapper<cudf::offset_type>;

{
// Non-empty input, with mismatched size of indices.
auto input_column =
LCW({LCW{3, 2, 1}, LCW{}, LCW{30, 20, 10, 50}, LCW{100, 120}, LCW{0}, LCW{}}, null_at(1));
auto input = lists_column_view(input_column);
LCW({LCW{3, 2, 1}, LCW{}, LCW{30, 20, 10, 50}, LCW{100, 120}, LCW{0}, LCW{}},
cudf::test::iterators::null_at(1));
auto input = cudf::lists_column_view(input_column);

EXPECT_THROW(extract_list_element(input, indices{0, 1, 2}), cudf::logic_error);
EXPECT_THROW(cudf::lists::extract_list_element(input, indices{0, 1, 2}), cudf::logic_error);
}
{
// Non-empty input, with empty indices.
auto input_column =
LCW({LCW{3, 2, 1}, LCW{}, LCW{30, 20, 10, 50}, LCW{100, 120}, LCW{0}, LCW{}}, null_at(1));
auto input = lists_column_view(input_column);
LCW({LCW{3, 2, 1}, LCW{}, LCW{30, 20, 10, 50}, LCW{100, 120}, LCW{0}, LCW{}},
cudf::test::iterators::null_at(1));
auto input = cudf::lists_column_view(input_column);

EXPECT_THROW(extract_list_element(input, indices{}), cudf::logic_error);
EXPECT_THROW(cudf::lists::extract_list_element(input, indices{}), cudf::logic_error);
}
{
// Empty input, with mismatched size of indices.
auto input_column = LCW{};
auto input = lists_column_view(input_column);
EXPECT_THROW(extract_list_element(input, indices{0, 1, 2}), cudf::logic_error);
auto input = cudf::lists_column_view(input_column);
EXPECT_THROW(cudf::lists::extract_list_element(input, indices{0, 1, 2}), cudf::logic_error);
}
}

TEST_F(ListsExtractColumnIndicesTest, ExtractStrings)
{
using namespace cudf;
using namespace cudf::lists;
using namespace cudf::test;
using namespace cudf::test::iterators;
using LCW = lists_column_wrapper<string_view>;
using strings = strings_column_wrapper;
using indices = fixed_width_column_wrapper<offset_type>;
using LCW = cudf::test::lists_column_wrapper<cudf::string_view>;
using strings = cudf::test::strings_column_wrapper;
using indices = cudf::test::fixed_width_column_wrapper<cudf::offset_type>;

auto input_column = LCW(
{LCW{"3", "2", "1"}, LCW{}, LCW{"30", "20", "10", "50"}, LCW{"100", "120"}, LCW{"0"}, LCW{}},
null_at(1));
auto input = lists_column_view(input_column);
cudf::test::iterators::null_at(1));
auto input = cudf::lists_column_view(input_column);

{
// Test fetching first element.
auto result = extract_list_element(input, indices{0, 0, 0, 0, 0, 0});
auto expected = strings({"3", "", "30", "100", "0", ""}, nulls_at({1, 5}));
auto result = cudf::lists::extract_list_element(input, indices{0, 0, 0, 0, 0, 0});
auto expected =
strings({"3", "", "30", "100", "0", ""}, cudf::test::iterators::nulls_at({1, 5}));
CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *result);
}
{
// Test fetching last element.
auto result = extract_list_element(input, indices{2, 0, 3, 1, 0, 0});
auto expected = strings({"1", "", "50", "120", "0", ""}, nulls_at({1, 5}));
auto result = cudf::lists::extract_list_element(input, indices{2, 0, 3, 1, 0, 0});
auto expected =
strings({"1", "", "50", "120", "0", ""}, cudf::test::iterators::nulls_at({1, 5}));
CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *result);
}
{
// Test fetching *all* out of bounds.
auto result = extract_list_element(input, indices{9, 9, 9, 9, 9, 9});
auto expected = strings({"", "", "", "", "", ""}, all_nulls());
auto result = cudf::lists::extract_list_element(input, indices{9, 9, 9, 9, 9, 9});
auto expected = strings({"", "", "", "", "", ""}, cudf::test::iterators::all_nulls());
CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *result);
}
{
// Test fetching first from the end.
auto result = extract_list_element(input, indices{-1, -1, -1, -1, -1, -1});
auto expected = strings({"1", "", "50", "120", "0", ""}, nulls_at({1, 5}));
auto result = cudf::lists::extract_list_element(input, indices{-1, -1, -1, -1, -1, -1});
auto expected =
strings({"1", "", "50", "120", "0", ""}, cudf::test::iterators::nulls_at({1, 5}));
CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *result);
}
{
// Test fetching last from the end.
auto result = extract_list_element(input, indices{-3, 0, -4, -2, -1, 0});
auto expected = strings({"3", "", "30", "100", "0", ""}, nulls_at({1, 5}));
auto result = cudf::lists::extract_list_element(input, indices{-3, 0, -4, -2, -1, 0});
auto expected =
strings({"3", "", "30", "100", "0", ""}, cudf::test::iterators::nulls_at({1, 5}));
CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *result);
}
{
// Test fetching *all* negative out of bounds.
auto result = extract_list_element(input, indices{-9, -9, -9, -9, -9, -9});
auto expected = strings({"", "", "", "", "", ""}, all_nulls());
auto result = cudf::lists::extract_list_element(input, indices{-9, -9, -9, -9, -9, -9});
auto expected = strings({"", "", "", "", "", ""}, cudf::test::iterators::all_nulls());
CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *result);
}
{
// Test mixed indices.
auto result = extract_list_element(input, indices{-2, 0, 3, -1, 0, 0});
auto expected = strings({"2", "", "50", "120", "0", ""}, nulls_at({1, 5}));
auto result = cudf::lists::extract_list_element(input, indices{-2, 0, 3, -1, 0, 0});
auto expected =
strings({"2", "", "50", "120", "0", ""}, cudf::test::iterators::nulls_at({1, 5}));
CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *result);
}
{
// Test possibly null indices.
auto result = extract_list_element(input, indices{{-2, 0, 3, -1, 0, 0}, nulls_at({2, 4})});
auto expected = strings({"2", "", "50", "120", "", ""}, nulls_at({1, 2, 4, 5}));
auto result = cudf::lists::extract_list_element(
input, indices{{-2, 0, 3, -1, 0, 0}, cudf::test::iterators::nulls_at({2, 4})});
auto expected =
strings({"2", "", "50", "120", "", ""}, cudf::test::iterators::nulls_at({1, 2, 4, 5}));
CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *result);
}
}
Expand Down
15 changes: 8 additions & 7 deletions cpp/tests/transform/row_bit_count_test.cu
Original file line number Diff line number Diff line change
Expand Up @@ -236,37 +236,38 @@ TEST_F(RowBitCount, StructsWithLists_RowsExceedingASingleBlock)
// column size. For what it's worth, it looks as follows:
// [ struct({0,1}), struct({2,3}), struct({4,5}), ... ]

using namespace cudf;
auto constexpr num_rows = 1024 * 2; // Exceeding a block size.

// List child column = {0, 1, 2, 3, 4, ..., 2*num_rows};
auto ints = make_numeric_column(cudf::data_type{cudf::type_id::INT32}, num_rows * 2);
auto ints = cudf::make_numeric_column(cudf::data_type{cudf::type_id::INT32}, num_rows * 2);
auto ints_view = ints->mutable_view();
thrust::tabulate(rmm::exec_policy(cudf::get_default_stream()),
ints_view.begin<int32_t>(),
ints_view.end<int32_t>(),
thrust::identity{});

// List offsets = {0, 2, 4, 6, 8, ..., num_rows*2};
auto list_offsets = make_numeric_column(cudf::data_type{cudf::type_id::INT32}, num_rows + 1);
auto list_offsets =
cudf::make_numeric_column(cudf::data_type{cudf::type_id::INT32}, num_rows + 1);
auto list_offsets_view = list_offsets->mutable_view();
thrust::tabulate(rmm::exec_policy(cudf::get_default_stream()),
list_offsets_view.begin<cudf::offset_type>(),
list_offsets_view.end<cudf::offset_type>(),
times_2{});

// List<int32_t> = {{0,1}, {2,3}, {4,5}, ..., {2*(num_rows-1), 2*num_rows-1}};
auto lists_column = make_lists_column(num_rows, std::move(list_offsets), std::move(ints), 0, {});
auto lists_column =
cudf::make_lists_column(num_rows, std::move(list_offsets), std::move(ints), 0, {});

// Struct<List<int32_t>.
auto struct_members = std::vector<std::unique_ptr<cudf::column>>{};
struct_members.emplace_back(std::move(lists_column));
auto structs_column = make_structs_column(num_rows, std::move(struct_members), 0, {});
auto structs_column = cudf::make_structs_column(num_rows, std::move(struct_members), 0, {});

// Compute row_bit_count, and compare.
auto row_bit_counts = row_bit_count(cudf::table_view{{structs_column->view()}});
auto row_bit_counts = cudf::row_bit_count(cudf::table_view{{structs_column->view()}});
auto expected_row_bit_counts =
make_numeric_column(cudf::data_type{cudf::type_id::INT32}, num_rows);
cudf::make_numeric_column(cudf::data_type{cudf::type_id::INT32}, num_rows);
thrust::fill_n(rmm::exec_policy(cudf::get_default_stream()),
expected_row_bit_counts->mutable_view().begin<int32_t>(),
num_rows,
Expand Down
41 changes: 14 additions & 27 deletions cpp/tests/types/traits_test.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019-2020, NVIDIA CORPORATION.
* Copyright (c) 2019-2023, 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 Expand Up @@ -47,47 +47,34 @@ TYPED_TEST_SUITE(TypedTraitsTest, cudf::test::AllTypes);

TEST_F(TraitsTest, NumericDataTypesAreNumeric)
{
using namespace cudf::test;
EXPECT_TRUE(std::all_of(numeric_type_ids.begin(), numeric_type_ids.end(), [](cudf::type_id type) {
return cudf::is_numeric(cudf::data_type{type});
}));
EXPECT_TRUE(
std::all_of(cudf::test::numeric_type_ids.begin(),
cudf::test::numeric_type_ids.end(),
[](cudf::type_id type) { return cudf::is_numeric(cudf::data_type{type}); }));
}

TEST_F(TraitsTest, TimestampDataTypesAreNotNumeric)
{
using namespace cudf::test;
EXPECT_TRUE(
std::none_of(timestamp_type_ids.begin(), timestamp_type_ids.end(), [](cudf::type_id type) {
return cudf::is_numeric(cudf::data_type{type});
}));
}

/*
These types are not yet supported by the type dispatcher
TEST_F(TraitsTest, NonNumericDataTypesAreNotNumeric) {
using namespace cudf::test;
EXPECT_TRUE(std::none_of(
non_numeric_type_ids.begin(), non_numeric_type_ids.end(),
[](cudf::type_id type) { return cudf::is_numeric(cudf::data_type{type}); }));
std::none_of(cudf::test::timestamp_type_ids.begin(),
cudf::test::timestamp_type_ids.end(),
[](cudf::type_id type) { return cudf::is_numeric(cudf::data_type{type}); }));
}
*/

TEST_F(TraitsTest, NumericDataTypesAreNotTimestamps)
{
using namespace cudf::test;
EXPECT_TRUE(
std::none_of(numeric_type_ids.begin(), numeric_type_ids.end(), [](cudf::type_id type) {
return cudf::is_timestamp(cudf::data_type{type});
}));
std::none_of(cudf::test::numeric_type_ids.begin(),
cudf::test::numeric_type_ids.end(),
[](cudf::type_id type) { return cudf::is_timestamp(cudf::data_type{type}); }));
}

TEST_F(TraitsTest, TimestampDataTypesAreTimestamps)
{
using namespace cudf::test;
EXPECT_TRUE(
std::all_of(timestamp_type_ids.begin(), timestamp_type_ids.end(), [](cudf::type_id type) {
return cudf::is_timestamp(cudf::data_type{type});
}));
std::all_of(cudf::test::timestamp_type_ids.begin(),
cudf::test::timestamp_type_ids.end(),
[](cudf::type_id type) { return cudf::is_timestamp(cudf::data_type{type}); }));
}

TYPED_TEST(TypedTraitsTest, RelationallyComparable)
Expand Down
Loading