From 66ad749e0f59203ca60a90c4094faaed0455e562 Mon Sep 17 00:00:00 2001 From: Dave Baranec Date: Tue, 6 Jul 2021 17:46:43 -0500 Subject: [PATCH 1/6] Rework column equivalency checks to handle list columns that have arbitrarily different data (offsets, values) in null rows. --- cpp/tests/utilities/column_utilities.cu | 429 +++++++++++++++++++----- 1 file changed, 347 insertions(+), 82 deletions(-) diff --git a/cpp/tests/utilities/column_utilities.cu b/cpp/tests/utilities/column_utilities.cu index 2ff06436853..033ef863dee 100644 --- a/cpp/tests/utilities/column_utilities.cu +++ b/cpp/tests/utilities/column_utilities.cu @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -46,10 +47,135 @@ #include "rmm/cuda_stream_view.hpp" namespace cudf { + namespace test { namespace { +// expand all non-null rows in a list column into a column of child row indices. +std::unique_ptr generate_child_row_indices(lists_column_view const& c, + column_view const& row_indices) +{ + // Example input + // List: + // Length : 7 + // Offsets : 0, 3, 6, 8, 11, 14, 16, 19 + // | | <-- non-null input rows + // Null count: 7 + // 0010100 + // 1, 1, 1, 2, 2, 2, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 7, 7, 7 + // | | | | | <-- child rows of non-null rows + // + // Desired output: [6, 7, 11, 12, 13] + + // compute total # of child row indices we will be emitting. + auto row_size_iter = cudf::detail::make_counting_transform_iterator( + 0, + [row_indices = row_indices.begin(), + validity = c.null_mask(), + offsets = c.offsets().begin(), + offset = c.offset()] __device__(int index) { + // both null mask and offsets data are not pre-sliced. so we need to add the column offset to + // every incoming index. + auto const true_index = row_indices[index] + offset; + return !validity || cudf::bit_is_set(validity, true_index) + ? (offsets[true_index + 1] - offsets[true_index]) + : 0; + }); + auto const output_size = + thrust::reduce(rmm::exec_policy(), row_size_iter, row_size_iter + row_indices.size()); + // no output. done. + auto result = + cudf::make_fixed_width_column(data_type{type_id::INT32}, output_size, mask_state::UNALLOCATED); + if (output_size == 0) { return result; } + + // for all input rows, what position in the output column they will start at. + // + // output_row_start = [0, 0, 0, 2, 2, 5, 5] + // | | <-- non-null input rows + // + auto output_row_start = cudf::make_fixed_width_column( + data_type{type_id::INT32}, row_indices.size(), mask_state::UNALLOCATED); + thrust::exclusive_scan(rmm::exec_policy(), + row_size_iter, + row_size_iter + row_indices.size(), + output_row_start->mutable_view().begin()); + + // fill result column with 1s + // + // result = [1, 1, 1, 1, 1] + // + thrust::generate(rmm::exec_policy(), + result->mutable_view().begin(), + result->mutable_view().end(), + [] __device__() { return 1; }); + + // scatter the output row positions into result buffer + // + // result = [6, 1, 11, 1, 1] + // + auto validity_iter = cudf::detail::make_counting_transform_iterator( + 0, + [row_indices = row_indices.begin(), + validity = c.null_mask(), + offset = c.offset()] __device__(int index) { + auto const true_index = row_indices[index] + offset; + return !validity || cudf::bit_is_set(validity, true_index) ? 1 : 0; + }); + auto output_row_iter = cudf::detail::make_counting_transform_iterator( + 0, + [row_indices = row_indices.begin(), + offsets = c.offsets().begin(), + offset = c.offset(), + first_offset = cudf::detail::get_value( + c.offsets(), c.offset(), rmm::cuda_stream_default)] __device__(int index) { + auto const true_index = row_indices[index] + offset; + return offsets[true_index] - first_offset; + }); + thrust::scatter_if(rmm::exec_policy(), + output_row_iter, + output_row_iter + row_indices.size(), + output_row_start->view().begin(), + validity_iter, + result->mutable_view().begin()); + + // generate keys for each output row + // + // result = [1, 1, 2, 2, 2] + // + auto keys = + cudf::make_fixed_width_column(data_type{type_id::INT32}, output_size, mask_state::UNALLOCATED); + thrust::generate(rmm::exec_policy(), + keys->mutable_view().begin(), + keys->mutable_view().end(), + [] __device__() { return 0; }); + thrust::scatter_if(rmm::exec_policy(), + validity_iter, + validity_iter + row_indices.size(), + output_row_start->view().begin(), + validity_iter, + keys->mutable_view().begin()); + thrust::inclusive_scan(rmm::exec_policy(), + keys->view().begin(), + keys->view().end(), + keys->mutable_view().begin()); + + // scan by key to generate final child row indices. + // input + // result = [6, 1, 11, 1, 1] + // keys = [1, 1, 2, 2, 2] + // + // output + // result = [6, 7, 11, 12, 13] + // + thrust::inclusive_scan_by_key(rmm::exec_policy(), + keys->view().begin(), + keys->view().end(), + result->view().begin(), + result->mutable_view().begin()); + return result; +} + template struct column_property_comparator { bool types_equivalent(cudf::data_type const& lhs, cudf::data_type const& rhs) @@ -57,7 +183,25 @@ struct column_property_comparator { return is_fixed_point(lhs) ? lhs.id() == rhs.id() : lhs == rhs; } - void compare_common(cudf::column_view const& lhs, cudf::column_view const& rhs) + size_type count_nulls(cudf::column_view const& c, cudf::column_view const& row_indices) + { + auto validity_iter = cudf::detail::make_counting_transform_iterator( + 0, + [row_indices = row_indices.begin(), + validity = c.null_mask(), + offset = c.offset()] __device__(int index) { + // both null mask and offsets data are not pre-sliced. so we need to add the column offset + // to every incoming index. + auto const true_index = row_indices[index] + offset; + return !validity || cudf::bit_is_set(validity, true_index) ? 0 : 1; + }); + return thrust::reduce(rmm::exec_policy(), validity_iter, validity_iter + row_indices.size()); + } + + void compare_common(cudf::column_view const& lhs, + cudf::column_view const& rhs, + cudf::column_view const& lhs_row_indices, + cudf::column_view const& rhs_row_indices) { if (check_exact_equality) { EXPECT_EQ(lhs.type(), rhs.type()); @@ -65,11 +209,19 @@ struct column_property_comparator { EXPECT_TRUE(types_equivalent(lhs.type(), rhs.type())); } - EXPECT_EQ(lhs.size(), rhs.size()); + // DISCUSSION: does this make sense, semantically? + auto const lhs_size = check_exact_equality ? lhs.size() : lhs_row_indices.size(); + auto const rhs_size = check_exact_equality ? rhs.size() : rhs_row_indices.size(); + EXPECT_EQ(lhs_size, rhs_size); - if (lhs.size() > 0 && check_exact_equality) { EXPECT_EQ(lhs.nullable(), rhs.nullable()); } + if (lhs_size > 0 && check_exact_equality) { EXPECT_EQ(lhs.nullable(), rhs.nullable()); } - EXPECT_EQ(lhs.null_count(), rhs.null_count()); + // DISCUSSION: does this make sense, semantically? + auto const lhs_null_count = + check_exact_equality ? lhs.null_count() : count_nulls(lhs, lhs_row_indices); + auto const rhs_null_count = + check_exact_equality ? rhs.null_count() : count_nulls(rhs, rhs_row_indices); + EXPECT_EQ(lhs_null_count, rhs_null_count); // equivalent, but not exactly equal columns can have a different number of children if their // sizes are both 0. Specifically, empty string columns may or may not have children. @@ -79,45 +231,82 @@ struct column_property_comparator { } template ::value>* = nullptr> - void operator()(cudf::column_view const& lhs, cudf::column_view const& rhs) + void operator()(cudf::column_view const& lhs, + cudf::column_view const& rhs, + cudf::column_view const& lhs_row_indices, + cudf::column_view const& rhs_row_indices) { - compare_common(lhs, rhs); + compare_common(lhs, rhs, lhs_row_indices, rhs_row_indices); } template ::value>* = nullptr> - void operator()(cudf::column_view const& lhs, cudf::column_view const& rhs) + void operator()(cudf::column_view const& lhs, + cudf::column_view const& rhs, + cudf::column_view const& lhs_row_indices, + cudf::column_view const& rhs_row_indices) { - compare_common(lhs, rhs); + compare_common(lhs, rhs, lhs_row_indices, rhs_row_indices); cudf::lists_column_view lhs_l(lhs); cudf::lists_column_view rhs_l(rhs); // recurse - cudf::type_dispatcher(lhs_l.child().type(), - column_property_comparator{}, - lhs_l.get_sliced_child(rmm::cuda_stream_default), - rhs_l.get_sliced_child(rmm::cuda_stream_default)); + auto lhs_child = lhs_l.get_sliced_child(rmm::cuda_stream_default); + // note: if a column is all nulls or otherwise empty, no indices are generated and no recursion + // happens + auto lhs_child_indices = generate_child_row_indices(lhs_l, lhs_row_indices); + if (lhs_child_indices->size() > 0) { + auto rhs_child = rhs_l.get_sliced_child(rmm::cuda_stream_default); + auto rhs_child_indices = generate_child_row_indices(rhs_l, rhs_row_indices); + cudf::type_dispatcher(lhs_child.type(), + column_property_comparator{}, + lhs_child, + rhs_child, + *lhs_child_indices, + *rhs_child_indices); + } } }; class corresponding_rows_unequal { public: - corresponding_rows_unequal(table_device_view d_lhs, table_device_view d_rhs) : comp(d_lhs, d_rhs) + corresponding_rows_unequal(table_device_view d_lhs, + table_device_view d_rhs, + column_device_view lhs_row_indices_, + column_device_view rhs_row_indices_) + : comp(d_lhs, d_rhs), lhs_row_indices(lhs_row_indices_), rhs_row_indices(rhs_row_indices_) { } cudf::row_equality_comparator comp; - __device__ bool operator()(size_type index) { return !comp(index, index); } + __device__ bool operator()(size_type index) + { + return !comp(lhs_row_indices.element(index), + rhs_row_indices.element(index)); + } + + column_device_view lhs_row_indices; + column_device_view rhs_row_indices; }; class corresponding_rows_not_equivalent { table_device_view d_lhs; table_device_view d_rhs; + column_device_view lhs_row_indices; + column_device_view rhs_row_indices; + public: - corresponding_rows_not_equivalent(table_device_view d_lhs, table_device_view d_rhs) - : d_lhs(d_lhs), d_rhs(d_rhs), comp(d_lhs, d_rhs) + corresponding_rows_not_equivalent(table_device_view d_lhs, + table_device_view d_rhs, + column_device_view lhs_row_indices_, + column_device_view rhs_row_indices_) + : d_lhs(d_lhs), + d_rhs(d_rhs), + comp(d_lhs, d_rhs), + lhs_row_indices(lhs_row_indices_), + rhs_row_indices(rhs_row_indices_) { CUDF_EXPECTS(d_lhs.num_columns() == 1 and d_rhs.num_columns() == 1, "Unsupported number of columns"); @@ -126,11 +315,14 @@ class corresponding_rows_not_equivalent { struct typed_element_not_equivalent { template __device__ std::enable_if_t::value, bool> operator()( - column_device_view const& lhs, column_device_view const& rhs, size_type index) + column_device_view const& lhs, + column_device_view const& rhs, + size_type lhs_index, + size_type rhs_index) { - if (lhs.is_valid(index) and rhs.is_valid(index)) { - T const x = lhs.element(index); - T const y = rhs.element(index); + if (lhs.is_valid(lhs_index) and rhs.is_valid(rhs_index)) { + T const x = lhs.element(lhs_index); + T const y = rhs.element(rhs_index); // Must handle inf and nan separately if (std::isinf(x) || std::isinf(y)) { @@ -161,11 +353,14 @@ class corresponding_rows_not_equivalent { __device__ bool operator()(size_type index) { - if (not comp(index, index)) { + auto const lhs_index = lhs_row_indices.element(index); + auto const rhs_index = rhs_row_indices.element(index); + + if (not comp(lhs_index, rhs_index)) { auto lhs_col = this->d_lhs.column(0); auto rhs_col = this->d_rhs.column(0); return type_dispatcher( - lhs_col.type(), typed_element_not_equivalent{}, lhs_col, rhs_col, index); + lhs_col.type(), typed_element_not_equivalent{}, lhs_col, rhs_col, lhs_index, rhs_index); } return false; } @@ -175,6 +370,8 @@ class corresponding_rows_not_equivalent { std::string stringify_column_differences(cudf::device_span differences, column_view const& lhs, column_view const& rhs, + column_view const& lhs_row_indices, + column_view const& rhs_row_indices, bool print_all_differences, int depth) { @@ -199,9 +396,12 @@ std::string stringify_column_differences(cudf::device_span difference << h_differences[i] << "] = " << h_right_strings[i] << std::endl; return buffer.str(); } else { - int index = h_differences[0]; // only stringify first difference - auto diff_lhs = cudf::detail::slice(lhs, index, index + 1); - auto diff_rhs = cudf::detail::slice(rhs, index, index + 1); + int index = h_differences[0]; // only stringify first difference + + int lhs_index = cudf::detail::get_value(lhs_row_indices, index, rmm::cuda_stream_default); + int rhs_index = cudf::detail::get_value(rhs_row_indices, index, rmm::cuda_stream_default); + auto diff_lhs = cudf::detail::slice(lhs, lhs_index, lhs_index + 1); + auto diff_rhs = cudf::detail::slice(rhs, rhs_index, rhs_index + 1); return depth_str + "first difference: " + "lhs[" + std::to_string(index) + "] = " + to_string(diff_lhs, "") + ", rhs[" + std::to_string(index) + "] = " + to_string(diff_rhs, ""); @@ -213,30 +413,37 @@ template struct column_comparator_impl { void operator()(column_view const& lhs, column_view const& rhs, + column_view const& lhs_row_indices, + column_view const& rhs_row_indices, bool print_all_differences, int depth) { auto d_lhs = cudf::table_device_view::create(table_view{{lhs}}); auto d_rhs = cudf::table_device_view::create(table_view{{rhs}}); + auto d_lhs_row_indices = cudf::column_device_view::create(lhs_row_indices); + auto d_rhs_row_indices = cudf::column_device_view::create(rhs_row_indices); + using ComparatorType = std::conditional_t; auto differences = rmm::device_uvector( lhs.size(), rmm::cuda_stream_default); // worst case: everything different - auto diff_iter = thrust::copy_if(rmm::exec_policy(), - thrust::make_counting_iterator(0), - thrust::make_counting_iterator(lhs.size()), - differences.begin(), - ComparatorType(*d_lhs, *d_rhs)); + auto input_iter = thrust::make_counting_iterator(0); + auto diff_iter = + thrust::copy_if(rmm::exec_policy(), + input_iter, + input_iter + lhs_row_indices.size(), + differences.begin(), + ComparatorType(*d_lhs, *d_rhs, *d_lhs_row_indices, *d_rhs_row_indices)); differences.resize(thrust::distance(differences.begin(), diff_iter), rmm::cuda_stream_default); // shrink back down if (not differences.is_empty()) GTEST_FAIL() << stringify_column_differences( - differences, lhs, rhs, print_all_differences, depth); + differences, lhs, rhs, lhs_row_indices, rhs_row_indices, print_all_differences, depth); } }; @@ -249,6 +456,8 @@ template struct column_comparator_impl { void operator()(column_view const& lhs, column_view const& rhs, + column_view const& lhs_row_indices, + column_view const& rhs_row_indices, bool print_all_differences, int depth) { @@ -261,28 +470,6 @@ struct column_comparator_impl { // worst case - everything is different rmm::device_uvector differences(lhs.size(), rmm::cuda_stream_default); - // TODO : determine how equals/equivalency should work for columns with divergent underlying - // data, but equivalent null masks. Example: - // - // List: - // Length : 3 - // Offsets : 0, 3, 5, 5 - // Nulls: 011 - // Children : - // 1, 2, 3, 4, 5 - // - // List: - // Length : 3 - // Offsets : 0, 3, 5, 7 - // Nulls: 011 - // Children : - // 1, 2, 3, 4, 5, 7, 8 - // - // These two columns are seemingly equivalent, since their top level rows are the same, with - // just the last element being null. However, pyArrow will say these are -not- equal and - // does not appear to have an equivalent() check. So the question is : should we be handling - // this case when someone calls expect_columns_equivalent()? - // compare offsets, taking slicing into account // left side @@ -309,21 +496,58 @@ struct column_comparator_impl { return mask == nullptr ? true : cudf::bit_is_set(mask, index + offset); }); - auto diff_iter = thrust::copy_if( + // when checking for equivalency, we can't compare offset values directly, we can only + // compare lengths of the rows, and only if valid. as a concrete example, you could have two + // equivalent columns with the following data: + // + // column A + // offsets = [0, 3, 5, 7] + // validity = [0, 1, 1, 1] + // + // column B + // offsets = [0, 0, 2, 4] + // validity = [0, 1, 1, 1] + // + // Row 0 in column A happens to have a positive length, even though the row is null, but column + // B does not. So the offsets for the remaining valid rows are fundamentally different even + // though the row lengths are the same. + // + auto input_iter = thrust::make_counting_iterator(0); + auto diff_iter = thrust::copy_if( rmm::exec_policy(), - thrust::make_counting_iterator(0), - thrust::make_counting_iterator(lhs_l.size() + 1), + input_iter, + input_iter + lhs_row_indices.size(), differences.begin(), - [lhs_offsets, rhs_offsets, lhs_valids, rhs_valids, num_rows = lhs_l.size()] __device__( - size_type index) { - // last offset has no validity associated with it - if (index < num_rows - 1) { - if (lhs_valids[index] != rhs_valids[index]) { return true; } - // if validity matches -and- is false, we can ignore the actual values. this - // is technically not checking "equal()", but it's how the non-list code path handles it - if (!lhs_valids[index]) { return false; } + [lhs_offsets, + rhs_offsets, + lhs_valids, + rhs_valids, + num_rows = lhs_l.size(), + lhs_indices = lhs_row_indices.begin(), + rhs_indices = rhs_row_indices.begin()] __device__(size_type index) { + size_type lhs_index = lhs_indices[index]; + size_type rhs_index = rhs_indices[index]; + + // check for validity match + if (lhs_valids[lhs_index] != rhs_valids[rhs_index]) { return true; } + + // if the row is valid, check that the length of the list is the same. do this + // for both the equivalency and exact equality checks. + if (lhs_valids[lhs_index] && ((lhs_offsets[lhs_index + 1] - lhs_offsets[lhs_index]) != + (rhs_offsets[rhs_index + 1] - rhs_offsets[rhs_index]))) { + return true; + } + + // if validity matches -and- is false, we can ignore the actual offset values. this + // is technically not checking "equal()", but it's how the non-list code path handles it + if (!lhs_valids[lhs_index]) { return false; } + + // if checking exact equality, compare the actual offset values + if (check_exact_equality && lhs_offsets[lhs_index] != rhs_offsets[rhs_index]) { + return true; } - return lhs_offsets[index] == rhs_offsets[index] ? false : true; + + return false; }); differences.resize(thrust::distance(differences.begin(), diff_iter), @@ -331,17 +555,25 @@ struct column_comparator_impl { if (not differences.is_empty()) GTEST_FAIL() << stringify_column_differences( - differences, lhs, rhs, print_all_differences, depth); + differences, lhs, rhs, lhs_row_indices, rhs_row_indices, print_all_differences, depth); - // recurse + // recurse. auto lhs_child = lhs_l.get_sliced_child(rmm::cuda_stream_default); - auto rhs_child = rhs_l.get_sliced_child(rmm::cuda_stream_default); - cudf::type_dispatcher(lhs_child.type(), - column_comparator{}, - lhs_child, - rhs_child, - print_all_differences, - depth + 1); + // note: if a column is all nulls or otherwise empty, no indices are generated and no recursion + // happens + auto lhs_child_indices = generate_child_row_indices(lhs_l, lhs_row_indices); + if (lhs_child_indices->size() > 0) { + auto rhs_child = rhs_l.get_sliced_child(rmm::cuda_stream_default); + auto rhs_child_indices = generate_child_row_indices(rhs_l, rhs_row_indices); + cudf::type_dispatcher(lhs_child.type(), + column_comparator{}, + lhs_child, + rhs_child, + *lhs_child_indices, + *rhs_child_indices, + print_all_differences, + depth + 1); + } } }; @@ -349,6 +581,8 @@ template struct column_comparator_impl { void operator()(column_view const& lhs, column_view const& rhs, + column_view const& lhs_row_indices, + column_view const& rhs_row_indices, bool print_all_differences, int depth) { @@ -364,6 +598,8 @@ struct column_comparator_impl { column_comparator{}, lhs_child, rhs_child, + lhs_row_indices, + rhs_row_indices, print_all_differences, depth + 1); }); @@ -375,18 +611,39 @@ struct column_comparator { template void operator()(column_view const& lhs, column_view const& rhs, - bool print_all_differences, - int depth = 0) + column_view const& lhs_row_indices, + column_view const& rhs_row_indices, + bool print_all_differences = false, + int depth = 0) { + CUDF_EXPECTS(lhs_row_indices.size() == rhs_row_indices.size(), + "Mismatch in row counts to compare"); + // compare properties - cudf::type_dispatcher(lhs.type(), column_property_comparator{}, lhs, rhs); + cudf::type_dispatcher(lhs.type(), + column_property_comparator{}, + lhs, + rhs, + lhs_row_indices, + rhs_row_indices); // compare values column_comparator_impl comparator{}; - comparator(lhs, rhs, print_all_differences, depth); + comparator(lhs, rhs, lhs_row_indices, rhs_row_indices, print_all_differences, depth); } }; +std::unique_ptr generate_all_row_indices(size_type num_rows) +{ + auto indices = + cudf::make_fixed_width_column(data_type{type_id::INT32}, num_rows, mask_state::UNALLOCATED); + thrust::tabulate(rmm::exec_policy(), + indices->mutable_view().begin(), + indices->mutable_view().end(), + thrust::identity()); + return indices; +} + } // namespace /** @@ -394,7 +651,9 @@ struct column_comparator { */ void expect_column_properties_equal(column_view const& lhs, column_view const& rhs) { - cudf::type_dispatcher(lhs.type(), column_property_comparator{}, lhs, rhs); + auto indices = generate_all_row_indices(lhs.size()); + cudf::type_dispatcher( + lhs.type(), column_property_comparator{}, lhs, rhs, *indices, *indices); } /** @@ -402,7 +661,9 @@ void expect_column_properties_equal(column_view const& lhs, column_view const& r */ void expect_column_properties_equivalent(column_view const& lhs, column_view const& rhs) { - cudf::type_dispatcher(lhs.type(), column_property_comparator{}, lhs, rhs); + auto indices = generate_all_row_indices(lhs.size()); + cudf::type_dispatcher( + lhs.type(), column_property_comparator{}, lhs, rhs, *indices, *indices); } /** @@ -412,7 +673,9 @@ void expect_columns_equal(cudf::column_view const& lhs, cudf::column_view const& rhs, bool print_all_differences) { - cudf::type_dispatcher(lhs.type(), column_comparator{}, lhs, rhs, print_all_differences); + auto indices = generate_all_row_indices(lhs.size()); + cudf::type_dispatcher( + lhs.type(), column_comparator{}, lhs, rhs, *indices, *indices, print_all_differences); } /** @@ -422,7 +685,9 @@ void expect_columns_equivalent(cudf::column_view const& lhs, cudf::column_view const& rhs, bool print_all_differences) { - cudf::type_dispatcher(lhs.type(), column_comparator{}, lhs, rhs, print_all_differences); + auto indices = generate_all_row_indices(lhs.size()); + cudf::type_dispatcher( + lhs.type(), column_comparator{}, lhs, rhs, *indices, *indices, print_all_differences); } /** From affc15eabe6db14ffdb80de550b067d5cd55b578 Mon Sep 17 00:00:00 2001 From: Dave Baranec Date: Thu, 8 Jul 2021 14:49:20 -0500 Subject: [PATCH 2/6] Add recursive property checking for struct columns. Add the ability to have the various expect_columns_* functions throw instead of print upon failure, allowing for use of EXPECT_THROW(...). Add tests. Couple of small fixes. --- cpp/include/cudf_test/column_utilities.hpp | 16 +- cpp/tests/utilities/column_utilities.cu | 149 ++++++++++---- .../column_utilities_tests.cpp | 185 +++++++++++++++++- 3 files changed, 310 insertions(+), 40 deletions(-) diff --git a/cpp/include/cudf_test/column_utilities.hpp b/cpp/include/cudf_test/column_utilities.hpp index b8b63b3be81..1fb72c4a28c 100644 --- a/cpp/include/cudf_test/column_utilities.hpp +++ b/cpp/include/cudf_test/column_utilities.hpp @@ -32,8 +32,11 @@ namespace test { * * @param lhs The first column * @param rhs The second column + * @param throw_on_fail If true, throw a cudf::logic error on failure instead of printing */ -void expect_column_properties_equal(cudf::column_view const& lhs, cudf::column_view const& rhs); +void expect_column_properties_equal(cudf::column_view const& lhs, + cudf::column_view const& rhs, + bool throw_on_fail = false); /** * @brief Verifies the property equivalence of two columns. @@ -46,7 +49,8 @@ void expect_column_properties_equal(cudf::column_view const& lhs, cudf::column_v * @param rhs The second column */ void expect_column_properties_equivalent(cudf::column_view const& lhs, - cudf::column_view const& rhs); + cudf::column_view const& rhs, + bool throw_on_fail = false); /** * @brief Verifies the element-wise equality of two columns. @@ -56,10 +60,12 @@ void expect_column_properties_equivalent(cudf::column_view const& lhs, * @param lhs The first column * @param rhs The second column * @param print_all_differences If true display all differences + * @param throw_on_fail If true, throw a cudf::logic error on failure instead of printing */ void expect_columns_equal(cudf::column_view const& lhs, cudf::column_view const& rhs, - bool print_all_differences = false); + bool print_all_differences = false, + bool throw_on_fail = false); /** * @brief Verifies the element-wise equivalence of two columns. @@ -70,10 +76,12 @@ void expect_columns_equal(cudf::column_view const& lhs, * @param lhs The first column * @param rhs The second column * @param print_all_differences If true display all differences + * @param throw_on_fail If true, throw a cudf::logic error on failure instead of printing */ void expect_columns_equivalent(cudf::column_view const& lhs, cudf::column_view const& rhs, - bool print_all_differences = false); + bool print_all_differences = false, + bool throw_on_fail = false); /** * @brief Verifies the bitwise equality of two device memory buffers. diff --git a/cpp/tests/utilities/column_utilities.cu b/cpp/tests/utilities/column_utilities.cu index 033ef863dee..3b1dfe8d8ab 100644 --- a/cpp/tests/utilities/column_utilities.cu +++ b/cpp/tests/utilities/column_utilities.cu @@ -176,6 +176,15 @@ std::unique_ptr generate_child_row_indices(lists_column_view const& c, return result; } +#define PROP_EXPECT_EQ(a, b, _msg) \ + do { \ + if (throw_on_fail) { \ + CUDF_EXPECTS(a == b, _msg); \ + } else { \ + EXPECT_EQ(a, b); \ + } \ + } while (0) + template struct column_property_comparator { bool types_equivalent(cudf::data_type const& lhs, cudf::data_type const& rhs) @@ -201,51 +210,58 @@ struct column_property_comparator { void compare_common(cudf::column_view const& lhs, cudf::column_view const& rhs, cudf::column_view const& lhs_row_indices, - cudf::column_view const& rhs_row_indices) + cudf::column_view const& rhs_row_indices, + bool throw_on_fail) { if (check_exact_equality) { - EXPECT_EQ(lhs.type(), rhs.type()); + PROP_EXPECT_EQ(lhs.type(), rhs.type(), "Type mismatch"); } else { - EXPECT_TRUE(types_equivalent(lhs.type(), rhs.type())); + PROP_EXPECT_EQ(types_equivalent(lhs.type(), rhs.type()), true, "Type mismatch"); } // DISCUSSION: does this make sense, semantically? auto const lhs_size = check_exact_equality ? lhs.size() : lhs_row_indices.size(); auto const rhs_size = check_exact_equality ? rhs.size() : rhs_row_indices.size(); - EXPECT_EQ(lhs_size, rhs_size); + PROP_EXPECT_EQ(lhs_size, rhs_size, "Column size mismatch"); - if (lhs_size > 0 && check_exact_equality) { EXPECT_EQ(lhs.nullable(), rhs.nullable()); } + if (lhs_size > 0 && check_exact_equality) { + PROP_EXPECT_EQ(lhs.nullable(), rhs.nullable(), "Column nullability mismatch"); + } // DISCUSSION: does this make sense, semantically? auto const lhs_null_count = check_exact_equality ? lhs.null_count() : count_nulls(lhs, lhs_row_indices); auto const rhs_null_count = check_exact_equality ? rhs.null_count() : count_nulls(rhs, rhs_row_indices); - EXPECT_EQ(lhs_null_count, rhs_null_count); + PROP_EXPECT_EQ(lhs_null_count, rhs_null_count, "Null count mismatch"); // equivalent, but not exactly equal columns can have a different number of children if their // sizes are both 0. Specifically, empty string columns may or may not have children. if (check_exact_equality || (lhs.size() > 0 && lhs.null_count() < lhs.size())) { - EXPECT_EQ(lhs.num_children(), rhs.num_children()); + PROP_EXPECT_EQ(lhs.num_children(), rhs.num_children(), "Child count mismatch"); } } - template ::value>* = nullptr> + template ::value && + !std::is_same::value>* = nullptr> void operator()(cudf::column_view const& lhs, cudf::column_view const& rhs, cudf::column_view const& lhs_row_indices, - cudf::column_view const& rhs_row_indices) + cudf::column_view const& rhs_row_indices, + bool throw_on_fail) { - compare_common(lhs, rhs, lhs_row_indices, rhs_row_indices); + compare_common(lhs, rhs, lhs_row_indices, rhs_row_indices, throw_on_fail); } template ::value>* = nullptr> void operator()(cudf::column_view const& lhs, cudf::column_view const& rhs, cudf::column_view const& lhs_row_indices, - cudf::column_view const& rhs_row_indices) + cudf::column_view const& rhs_row_indices, + bool throw_on_fail) { - compare_common(lhs, rhs, lhs_row_indices, rhs_row_indices); + compare_common(lhs, rhs, lhs_row_indices, rhs_row_indices, throw_on_fail); cudf::lists_column_view lhs_l(lhs); cudf::lists_column_view rhs_l(rhs); @@ -263,9 +279,37 @@ struct column_property_comparator { lhs_child, rhs_child, *lhs_child_indices, - *rhs_child_indices); + *rhs_child_indices, + throw_on_fail); } } + + template ::value>* = nullptr> + void operator()(cudf::column_view const& lhs, + cudf::column_view const& rhs, + cudf::column_view const& lhs_row_indices, + cudf::column_view const& rhs_row_indices, + bool throw_on_fail) + { + compare_common(lhs, rhs, lhs_row_indices, rhs_row_indices, throw_on_fail); + + structs_column_view l_scv(lhs); + structs_column_view r_scv(rhs); + + std::for_each(thrust::make_counting_iterator(0), + thrust::make_counting_iterator(0) + lhs.num_children(), + [&](auto i) { + column_view lhs_child = l_scv.get_sliced_child(i); + column_view rhs_child = r_scv.get_sliced_child(i); + cudf::type_dispatcher(lhs_child.type(), + column_property_comparator{}, + lhs_child, + rhs_child, + lhs_row_indices, + rhs_row_indices, + throw_on_fail); + }); + } }; class corresponding_rows_unequal { @@ -416,6 +460,7 @@ struct column_comparator_impl { column_view const& lhs_row_indices, column_view const& rhs_row_indices, bool print_all_differences, + bool throw_on_fail, int depth) { auto d_lhs = cudf::table_device_view::create(table_view{{lhs}}); @@ -441,9 +486,14 @@ struct column_comparator_impl { differences.resize(thrust::distance(differences.begin(), diff_iter), rmm::cuda_stream_default); // shrink back down - if (not differences.is_empty()) - GTEST_FAIL() << stringify_column_differences( - differences, lhs, rhs, lhs_row_indices, rhs_row_indices, print_all_differences, depth); + if (not differences.is_empty()) { + if (throw_on_fail) { + CUDF_FAIL("Column differences detected"); + } else { + GTEST_FAIL() << stringify_column_differences( + differences, lhs, rhs, lhs_row_indices, rhs_row_indices, print_all_differences, depth); + } + } } }; @@ -459,16 +509,17 @@ struct column_comparator_impl { column_view const& lhs_row_indices, column_view const& rhs_row_indices, bool print_all_differences, + bool throw_on_fail, int depth) { lists_column_view lhs_l(lhs); lists_column_view rhs_l(rhs); - CUDF_EXPECTS(lhs_l.size() == rhs_l.size(), "List column size mismatch"); - if (lhs_l.is_empty()) { return; } + CUDF_EXPECTS(lhs_row_indices.size() == rhs_row_indices.size(), "List column size mismatch"); + if (lhs_row_indices.is_empty()) { return; } // worst case - everything is different - rmm::device_uvector differences(lhs.size(), rmm::cuda_stream_default); + rmm::device_uvector differences(lhs_row_indices.size(), rmm::cuda_stream_default); // compare offsets, taking slicing into account @@ -522,7 +573,6 @@ struct column_comparator_impl { rhs_offsets, lhs_valids, rhs_valids, - num_rows = lhs_l.size(), lhs_indices = lhs_row_indices.begin(), rhs_indices = rhs_row_indices.begin()] __device__(size_type index) { size_type lhs_index = lhs_indices[index]; @@ -553,9 +603,14 @@ struct column_comparator_impl { differences.resize(thrust::distance(differences.begin(), diff_iter), rmm::cuda_stream_default); // shrink back down - if (not differences.is_empty()) - GTEST_FAIL() << stringify_column_differences( - differences, lhs, rhs, lhs_row_indices, rhs_row_indices, print_all_differences, depth); + if (not differences.is_empty()) { + if (throw_on_fail) { + CUDF_FAIL("Column differences detected"); + } else { + GTEST_FAIL() << stringify_column_differences( + differences, lhs, rhs, lhs_row_indices, rhs_row_indices, print_all_differences, depth); + } + } // recurse. auto lhs_child = lhs_l.get_sliced_child(rmm::cuda_stream_default); @@ -572,6 +627,7 @@ struct column_comparator_impl { *lhs_child_indices, *rhs_child_indices, print_all_differences, + throw_on_fail, depth + 1); } } @@ -584,6 +640,7 @@ struct column_comparator_impl { column_view const& lhs_row_indices, column_view const& rhs_row_indices, bool print_all_differences, + bool throw_on_fail, int depth) { structs_column_view l_scv(lhs); @@ -601,6 +658,7 @@ struct column_comparator_impl { lhs_row_indices, rhs_row_indices, print_all_differences, + throw_on_fail, depth + 1); }); } @@ -614,6 +672,7 @@ struct column_comparator { column_view const& lhs_row_indices, column_view const& rhs_row_indices, bool print_all_differences = false, + bool throw_on_fail = false, int depth = 0) { CUDF_EXPECTS(lhs_row_indices.size() == rhs_row_indices.size(), @@ -625,11 +684,13 @@ struct column_comparator { lhs, rhs, lhs_row_indices, - rhs_row_indices); + rhs_row_indices, + throw_on_fail); // compare values column_comparator_impl comparator{}; - comparator(lhs, rhs, lhs_row_indices, rhs_row_indices, print_all_differences, depth); + comparator( + lhs, rhs, lhs_row_indices, rhs_row_indices, print_all_differences, throw_on_fail, depth); } }; @@ -649,21 +710,25 @@ std::unique_ptr generate_all_row_indices(size_type num_rows) /** * @copydoc cudf::test::expect_column_properties_equal */ -void expect_column_properties_equal(column_view const& lhs, column_view const& rhs) +void expect_column_properties_equal(column_view const& lhs, + column_view const& rhs, + bool throw_on_fail) { auto indices = generate_all_row_indices(lhs.size()); cudf::type_dispatcher( - lhs.type(), column_property_comparator{}, lhs, rhs, *indices, *indices); + lhs.type(), column_property_comparator{}, lhs, rhs, *indices, *indices, throw_on_fail); } /** * @copydoc cudf::test::expect_column_properties_equivalent */ -void expect_column_properties_equivalent(column_view const& lhs, column_view const& rhs) +void expect_column_properties_equivalent(column_view const& lhs, + column_view const& rhs, + bool throw_on_fail) { auto indices = generate_all_row_indices(lhs.size()); cudf::type_dispatcher( - lhs.type(), column_property_comparator{}, lhs, rhs, *indices, *indices); + lhs.type(), column_property_comparator{}, lhs, rhs, *indices, *indices, throw_on_fail); } /** @@ -671,11 +736,18 @@ void expect_column_properties_equivalent(column_view const& lhs, column_view con */ void expect_columns_equal(cudf::column_view const& lhs, cudf::column_view const& rhs, - bool print_all_differences) + bool print_all_differences, + bool throw_on_fail) { auto indices = generate_all_row_indices(lhs.size()); - cudf::type_dispatcher( - lhs.type(), column_comparator{}, lhs, rhs, *indices, *indices, print_all_differences); + cudf::type_dispatcher(lhs.type(), + column_comparator{}, + lhs, + rhs, + *indices, + *indices, + print_all_differences, + throw_on_fail); } /** @@ -683,11 +755,18 @@ void expect_columns_equal(cudf::column_view const& lhs, */ void expect_columns_equivalent(cudf::column_view const& lhs, cudf::column_view const& rhs, - bool print_all_differences) + bool print_all_differences, + bool throw_on_fail) { auto indices = generate_all_row_indices(lhs.size()); - cudf::type_dispatcher( - lhs.type(), column_comparator{}, lhs, rhs, *indices, *indices, print_all_differences); + cudf::type_dispatcher(lhs.type(), + column_comparator{}, + lhs, + rhs, + *indices, + *indices, + print_all_differences, + throw_on_fail); } /** diff --git a/cpp/tests/utilities_tests/column_utilities_tests.cpp b/cpp/tests/utilities_tests/column_utilities_tests.cpp index 75a8cec24e9..890a6970fa9 100644 --- a/cpp/tests/utilities_tests/column_utilities_tests.cpp +++ b/cpp/tests/utilities_tests/column_utilities_tests.cpp @@ -42,7 +42,6 @@ struct ColumnUtilitiesTest : public cudf::test::BaseFixture { template struct ColumnUtilitiesTestIntegral : public cudf::test::BaseFixture { }; - template struct ColumnUtilitiesTestFloatingPoint : public cudf::test::BaseFixture { }; @@ -324,4 +323,188 @@ TYPED_TEST(ColumnUtilitiesTestFixedPoint, NonNullableToHostWithOffset) EXPECT_TRUE(std::equal(expected.begin(), expected.end(), host_data.first.begin())); } +struct ColumnUtilitiesListsTest : public cudf::test::BaseFixture { +}; + +TEST_F(ColumnUtilitiesListsTest, Equivalence) +{ + // list, nullable vs. non-nullable + { + auto all_valid = cudf::detail::make_counting_transform_iterator(0, [](auto i) { return true; }); + cudf::test::lists_column_wrapper a{{1, 2, 3}, {5, 6}, {8, 9}, {10}, {14, 15}}; + cudf::test::lists_column_wrapper b{{{1, 2, 3}, {5, 6}, {8, 9}, {10}, {14, 15}}, all_valid}; + + // properties + cudf::test::expect_column_properties_equivalent(a, b); + EXPECT_THROW(cudf::test::expect_column_properties_equal(a, b, true), cudf::logic_error); + + // values + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(a, b); + EXPECT_THROW(cudf::test::expect_columns_equal(a, b, false, true), cudf::logic_error); + } + + // list>, nullable vs. non-nullable + { + auto all_valid = cudf::detail::make_counting_transform_iterator(0, [](auto i) { return true; }); + cudf::test::lists_column_wrapper a{{{1, 2, 3}, {5, 6}}, {{8, 9}, {10}}, {{14, 15}}}; + cudf::test::lists_column_wrapper b{{{{1, 2, 3}, {5, 6}}, {{8, 9}, {10}}, {{14, 15}}}, + all_valid}; + + // properties + cudf::test::expect_column_properties_equivalent(a, b); + EXPECT_THROW(cudf::test::expect_column_properties_equal(a, b, true), cudf::logic_error); + + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(a, b); + EXPECT_THROW(cudf::test::expect_columns_equal(a, b, false, true), cudf::logic_error); + } +} + +TEST_F(ColumnUtilitiesListsTest, DifferentPhysicalStructure) +{ + // list + { + std::vector valids = {0, 0, 1, 0, 1, 0, 0}; + + cudf::test::fixed_width_column_wrapper c0_offsets{0, 3, 6, 8, 11, 14, 16, 19}; + cudf::test::fixed_width_column_wrapper c0_data{ + 1, 1, 1, 2, 2, 2, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 7, 7, 7}; + auto c0 = make_lists_column(7, + c0_offsets.release(), + c0_data.release(), + 5, + cudf::test::detail::make_null_mask(valids.begin(), valids.end())); + + cudf::test::fixed_width_column_wrapper c1_offsets{0, 0, 0, 2, 2, 5, 5, 5}; + cudf::test::fixed_width_column_wrapper c1_data{3, 3, 5, 5, 5}; + auto c1 = make_lists_column(7, + c1_offsets.release(), + c1_data.release(), + 5, + cudf::test::detail::make_null_mask(valids.begin(), valids.end())); + + // properties + cudf::test::expect_column_properties_equivalent(*c0, *c1); + EXPECT_THROW(cudf::test::expect_column_properties_equal(*c0, *c1, true), cudf::logic_error); + + // values + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*c0, *c1); + EXPECT_THROW(cudf::test::expect_columns_equal(*c0, *c1, false, true), cudf::logic_error); + } + + // list>> + { + std::vector level1_valids = {0, 0, 1, 0, 1, 0, 0}; + + cudf::test::fixed_width_column_wrapper c0_l1_offsets{0, 1, 2, 4, 4, 7, 7, 7}; + cudf::test::fixed_width_column_wrapper c0_l2_offsets{0, 1, 2, 5, 6, 7, 10, 14}; + cudf::test::fixed_width_column_wrapper c0_l3_ints{ + 1, 1, -1, -2, -3, 1, 1, -4, -5, -6, -7, -8, -9, -10}; + cudf::test::fixed_width_column_wrapper c0_l3_floats{ + 1, 1, 10, 20, 30, 1, 1, 40, 50, 60, 70, 80, 90, 100}; + cudf::test::structs_column_wrapper c0_l2_data({c0_l3_ints, c0_l3_floats}); + std::vector c0_l2_valids = {1, 1, 1, 0, 0, 1, 1}; + auto c0_l2 = make_lists_column( + 7, + c0_l2_offsets.release(), + c0_l2_data.release(), + 0, + cudf::test::detail::make_null_mask(c0_l2_valids.begin(), c0_l2_valids.end())); + auto c0 = make_lists_column( + 7, + c0_l1_offsets.release(), + std::move(c0_l2), + 5, + cudf::test::detail::make_null_mask(level1_valids.begin(), level1_valids.end())); + + cudf::test::fixed_width_column_wrapper c1_l1_offsets{0, 0, 0, 2, 2, 5, 5, 5}; + cudf::test::fixed_width_column_wrapper c1_l2_offsets{0, 3, 3, 3, 6, 10}; + cudf::test::fixed_width_column_wrapper c1_l3_ints{-1, -2, -3, -4, -5, -6, -7, -8, -9, -10}; + cudf::test::fixed_width_column_wrapper c1_l3_floats{ + 10, 20, 30, 40, 50, 60, 70, 80, 90, 100}; + cudf::test::structs_column_wrapper c1_l2_data({c1_l3_ints, c1_l3_floats}); + std::vector c1_l2_valids = {1, 0, 0, 1, 1}; + auto c1_l2 = make_lists_column( + 5, + c1_l2_offsets.release(), + c1_l2_data.release(), + 2, + cudf::test::detail::make_null_mask(c1_l2_valids.begin(), c1_l2_valids.end())); + auto c1 = make_lists_column( + 7, + c1_l1_offsets.release(), + std::move(c1_l2), + 5, + cudf::test::detail::make_null_mask(level1_valids.begin(), level1_valids.end())); + + // properties + cudf::test::expect_column_properties_equivalent(*c0, *c1); + EXPECT_THROW(cudf::test::expect_column_properties_equal(*c0, *c1, true), cudf::logic_error); + + // values + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*c0, *c1); + EXPECT_THROW(cudf::test::expect_columns_equal(*c0, *c1, false, true), cudf::logic_error); + } +} + +struct ColumnUtilitiesStructsTest : public cudf::test::BaseFixture { +}; + +TEST_F(ColumnUtilitiesStructsTest, Properties) +{ + cudf::test::strings_column_wrapper s0_scol0{"mno", "jkl", "ghi", "def", "abc"}; + cudf::test::fixed_width_column_wrapper s0_scol1{5, 4, 3, 2, 1}; + cudf::test::strings_column_wrapper s0_sscol0{"5555", "4444", "333", "22", "1"}; + cudf::test::fixed_width_column_wrapper s0_sscol1{50, 40, 30, 20, 10}; + cudf::test::lists_column_wrapper s0_sscol2{{1, 2}, {3, 4}, {5}, {6, 7, 8}, {12, 12}}; + cudf::test::structs_column_wrapper s0_scol2({s0_sscol0, s0_sscol1, s0_sscol2}); + cudf::test::structs_column_wrapper s_col0({s0_scol0, s0_scol1, s0_scol2}); + + auto all_valid = thrust::make_constant_iterator(true); + + cudf::test::strings_column_wrapper s1_scol0{"mno", "jkl", "ghi", "def", "abc"}; + cudf::test::fixed_width_column_wrapper s1_scol1{5, 4, 3, 2, 1}; + cudf::test::strings_column_wrapper s1_sscol0{"5555", "4444", "333", "22", "1"}; + cudf::test::fixed_width_column_wrapper s1_sscol1{50, 40, 30, 20, 10}; + cudf::test::lists_column_wrapper s1_sscol2{{{1, 2}, {3, 4}, {5}, {6, 7, 8}, {12, 12}}, + all_valid}; + cudf::test::structs_column_wrapper s1_scol2({s1_sscol0, s1_sscol1, s1_sscol2}); + cudf::test::structs_column_wrapper s_col1({s1_scol0, s1_scol1, s1_scol2}); + + // equivalent, but not equal + cudf::test::expect_column_properties_equivalent(s_col0, s_col1); + EXPECT_THROW(cudf::test::expect_column_properties_equal(s_col0, s_col1, true), cudf::logic_error); + + cudf::test::expect_column_properties_equal(s_col0, s_col0); + cudf::test::expect_column_properties_equal(s_col1, s_col1); +} + +TEST_F(ColumnUtilitiesStructsTest, Values) +{ + cudf::test::strings_column_wrapper s0_scol0{"mno", "jkl", "ghi", "def", "abc"}; + cudf::test::fixed_width_column_wrapper s0_scol1{5, 4, 3, 2, 1}; + cudf::test::strings_column_wrapper s0_sscol0{"5555", "4444", "333", "22", "1"}; + cudf::test::fixed_width_column_wrapper s0_sscol1{50, 40, 30, 20, 10}; + cudf::test::lists_column_wrapper s0_sscol2{{1, 2}, {3, 4}, {5}, {6, 7, 8}, {12, 12}}; + cudf::test::structs_column_wrapper s0_scol2({s0_sscol0, s0_sscol1, s0_sscol2}); + cudf::test::structs_column_wrapper s_col0({s0_scol0, s0_scol1, s0_scol2}); + + auto all_valid = thrust::make_constant_iterator(true); + + cudf::test::strings_column_wrapper s1_scol0{"mno", "jkl", "ghi", "def", "abc"}; + cudf::test::fixed_width_column_wrapper s1_scol1{5, 4, 3, 2, 1}; + cudf::test::strings_column_wrapper s1_sscol0{"5555", "4444", "333", "22", "1"}; + cudf::test::fixed_width_column_wrapper s1_sscol1{50, 40, 30, 20, 10}; + cudf::test::lists_column_wrapper s1_sscol2{{{1, 2}, {3, 4}, {5}, {6, 7, 8}, {12, 12}}, + all_valid}; + cudf::test::structs_column_wrapper s1_scol2({s1_sscol0, s1_sscol1, s1_sscol2}); + cudf::test::structs_column_wrapper s_col1({s1_scol0, s1_scol1, s1_scol2}); + + // equivalent, but not equal + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(s_col0, s_col1); + EXPECT_THROW(cudf::test::expect_columns_equal(s_col0, s_col1, false, true), cudf::logic_error); + + CUDF_TEST_EXPECT_COLUMNS_EQUAL(s_col0, s_col0); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(s_col1, s_col1); +} + CUDF_TEST_PROGRAM_MAIN() From adf178c09906c52791ea46a78222e44a6e30bf2f Mon Sep 17 00:00:00 2001 From: Dave Baranec Date: Mon, 12 Jul 2021 16:31:20 -0500 Subject: [PATCH 3/6] Cleanup some variable declarations and type usage. --- cpp/tests/utilities/column_utilities.cu | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/cpp/tests/utilities/column_utilities.cu b/cpp/tests/utilities/column_utilities.cu index bb88d46875c..6e60178769e 100644 --- a/cpp/tests/utilities/column_utilities.cu +++ b/cpp/tests/utilities/column_utilities.cu @@ -73,7 +73,7 @@ std::unique_ptr generate_child_row_indices(lists_column_view const& c, 0, [row_indices = row_indices.begin(), validity = c.null_mask(), - offsets = c.offsets().begin(), + offsets = c.offsets().begin(), offset = c.offset()] __device__(int index) { // both null mask and offsets data are not pre-sliced. so we need to add the column offset to // every incoming index. @@ -125,7 +125,7 @@ std::unique_ptr generate_child_row_indices(lists_column_view const& c, auto output_row_iter = cudf::detail::make_counting_transform_iterator( 0, [row_indices = row_indices.begin(), - offsets = c.offsets().begin(), + offsets = c.offsets().begin(), offset = c.offset(), first_offset = cudf::detail::get_value( c.offsets(), c.offset(), rmm::cuda_stream_default)] __device__(int index) { @@ -440,10 +440,12 @@ std::string stringify_column_differences(cudf::device_span difference << h_differences[i] << "] = " << h_right_strings[i] << std::endl; return buffer.str(); } else { - int index = h_differences[0]; // only stringify first difference + auto const index = h_differences[0]; // only stringify first difference - int lhs_index = cudf::detail::get_value(lhs_row_indices, index, rmm::cuda_stream_default); - int rhs_index = cudf::detail::get_value(rhs_row_indices, index, rmm::cuda_stream_default); + auto const lhs_index = + cudf::detail::get_value(lhs_row_indices, index, rmm::cuda_stream_default); + auto const rhs_index = + cudf::detail::get_value(rhs_row_indices, index, rmm::cuda_stream_default); auto diff_lhs = cudf::detail::slice(lhs, lhs_index, lhs_index + 1); auto diff_rhs = cudf::detail::slice(rhs, rhs_index, rhs_index + 1); return depth_str + "first difference: " + "lhs[" + std::to_string(index) + @@ -575,8 +577,8 @@ struct column_comparator_impl { rhs_valids, lhs_indices = lhs_row_indices.begin(), rhs_indices = rhs_row_indices.begin()] __device__(size_type index) { - size_type lhs_index = lhs_indices[index]; - size_type rhs_index = rhs_indices[index]; + auto const lhs_index = lhs_indices[index]; + auto const rhs_index = rhs_indices[index]; // check for validity match if (lhs_valids[lhs_index] != rhs_valids[rhs_index]) { return true; } From 6f18fbd74444edc8a2b714f117a24fc6503b2ff6 Mon Sep 17 00:00:00 2001 From: Dave Baranec Date: Wed, 14 Jul 2021 16:39:19 -0500 Subject: [PATCH 4/6] PR review changes. --- cpp/tests/utilities/column_utilities.cu | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cpp/tests/utilities/column_utilities.cu b/cpp/tests/utilities/column_utilities.cu index 6e60178769e..2bdb77136bf 100644 --- a/cpp/tests/utilities/column_utilities.cu +++ b/cpp/tests/utilities/column_utilities.cu @@ -61,7 +61,7 @@ std::unique_ptr generate_child_row_indices(lists_column_view const& c, // Length : 7 // Offsets : 0, 3, 6, 8, 11, 14, 16, 19 // | | <-- non-null input rows - // Null count: 7 + // Null count: 5 // 0010100 // 1, 1, 1, 2, 2, 2, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 7, 7, 7 // | | | | | <-- child rows of non-null rows @@ -297,7 +297,7 @@ struct column_property_comparator { structs_column_view r_scv(rhs); std::for_each(thrust::make_counting_iterator(0), - thrust::make_counting_iterator(0) + lhs.num_children(), + thrust::make_counting_iterator(lhs.num_children()), [&](auto i) { column_view lhs_child = l_scv.get_sliced_child(i); column_view rhs_child = r_scv.get_sliced_child(i); @@ -700,10 +700,10 @@ std::unique_ptr generate_all_row_indices(size_type num_rows) { auto indices = cudf::make_fixed_width_column(data_type{type_id::INT32}, num_rows, mask_state::UNALLOCATED); - thrust::tabulate(rmm::exec_policy(), + thrust::sequence(rmm::exec_policy(), indices->mutable_view().begin(), indices->mutable_view().end(), - thrust::identity()); + 0); return indices; } From 0769c9258f04d4c0ff72a20fb80b3ec69af8df10 Mon Sep 17 00:00:00 2001 From: Dave Baranec Date: Fri, 16 Jul 2021 18:10:00 -0500 Subject: [PATCH 5/6] Change equality and equivalence functions to return a bool instead of void. Change the print_all_differences parameter to be an enum with 3 values : FIRST_ERROR, ALL_ERRORS and QUIET. --- cpp/include/cudf_test/column_utilities.hpp | 59 ++-- cpp/tests/ast/transform_tests.cpp | 46 +-- cpp/tests/binaryop/binop-integration-test.cpp | 64 +++-- cpp/tests/copying/reverse_tests.cpp | 6 +- .../copying/scatter_struct_scalar_tests.cpp | 24 +- cpp/tests/copying/scatter_struct_tests.cpp | 26 +- cpp/tests/datetime/datetime_ops_test.cpp | 12 +- cpp/tests/filling/repeat_tests.cpp | 4 +- cpp/tests/groupby/groupby_test_util.hpp | 9 +- cpp/tests/groupby/m2_tests.cpp | 38 +-- cpp/tests/groupby/merge_lists_tests.cpp | 36 +-- cpp/tests/groupby/merge_m2_tests.cpp | 46 +-- cpp/tests/groupby/merge_sets_tests.cpp | 32 +-- cpp/tests/hashing/hash_test.cpp | 52 ++-- cpp/tests/io/orc_test.cpp | 4 +- .../concatenate_list_elements_tests.cpp | 48 ++-- .../lists/combine/concatenate_rows_tests.cpp | 36 +-- .../reshape/interleave_columns_tests.cpp | 41 +-- cpp/tests/search/search_struct_test.cpp | 98 +++---- .../strings/combine/concatenate_tests.cpp | 36 +-- .../combine/join_list_elements_tests.cpp | 74 ++--- cpp/tests/strings/floats_tests.cpp | 10 +- cpp/tests/strings/repeat_strings_tests.cpp | 38 +-- cpp/tests/strings/substring_tests.cpp | 44 +-- cpp/tests/utilities/column_utilities.cu | 271 +++++++++--------- .../column_utilities_tests.cpp | 33 ++- 26 files changed, 622 insertions(+), 565 deletions(-) diff --git a/cpp/include/cudf_test/column_utilities.hpp b/cpp/include/cudf_test/column_utilities.hpp index 1fb72c4a28c..beb34c6c452 100644 --- a/cpp/include/cudf_test/column_utilities.hpp +++ b/cpp/include/cudf_test/column_utilities.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2020, NVIDIA CORPORATION. + * Copyright (c) 2019-2021, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,16 +27,29 @@ namespace cudf { namespace test { + +/** + * @brief Verbosity level of output from column and table comparison functions. + * + */ +enum class debug_output_level { + FIRST_ERROR = 0, // print first error only + ALL_ERRORS, // print all errors + QUIET, // no debug output +}; + /** * @brief Verifies the property equality of two columns. * * @param lhs The first column * @param rhs The second column - * @param throw_on_fail If true, throw a cudf::logic error on failure instead of printing + * @param verbosity Level of debug output verbosity + * + * @returns True if the column properties are equal, false otherwise */ -void expect_column_properties_equal(cudf::column_view const& lhs, +bool expect_column_properties_equal(cudf::column_view const& lhs, cudf::column_view const& rhs, - bool throw_on_fail = false); + debug_output_level verbosity = debug_output_level::FIRST_ERROR); /** * @brief Verifies the property equivalence of two columns. @@ -47,25 +60,29 @@ void expect_column_properties_equal(cudf::column_view const& lhs, * * @param lhs The first column * @param rhs The second column + * @param verbosity Level of debug output verbosity + * + * @returns True if the column properties are equivalent, false otherwise */ -void expect_column_properties_equivalent(cudf::column_view const& lhs, - cudf::column_view const& rhs, - bool throw_on_fail = false); +bool expect_column_properties_equivalent( + cudf::column_view const& lhs, + cudf::column_view const& rhs, + debug_output_level verbosity = debug_output_level::FIRST_ERROR); /** * @brief Verifies the element-wise equality of two columns. * * Treats null elements as equivalent. * - * @param lhs The first column - * @param rhs The second column - * @param print_all_differences If true display all differences - * @param throw_on_fail If true, throw a cudf::logic error on failure instead of printing + * @param lhs The first column + * @param rhs The second column + * @param verbosity Level of debug output verbosity + * + * @returns True if the columns (and their properties) are equal, false otherwise */ -void expect_columns_equal(cudf::column_view const& lhs, +bool expect_columns_equal(cudf::column_view const& lhs, cudf::column_view const& rhs, - bool print_all_differences = false, - bool throw_on_fail = false); + debug_output_level verbosity = debug_output_level::FIRST_ERROR); /** * @brief Verifies the element-wise equivalence of two columns. @@ -73,15 +90,15 @@ void expect_columns_equal(cudf::column_view const& lhs, * Uses machine epsilon to compare floating point types. * Treats null elements as equivalent. * - * @param lhs The first column - * @param rhs The second column - * @param print_all_differences If true display all differences - * @param throw_on_fail If true, throw a cudf::logic error on failure instead of printing + * @param lhs The first column + * @param rhs The second column + * @param verbosity Level of debug output verbosity + * + * @returns True if the columns (and their properties) are equivalent, false otherwise */ -void expect_columns_equivalent(cudf::column_view const& lhs, +bool expect_columns_equivalent(cudf::column_view const& lhs, cudf::column_view const& rhs, - bool print_all_differences = false, - bool throw_on_fail = false); + debug_output_level verbosity = debug_output_level::FIRST_ERROR); /** * @brief Verifies the bitwise equality of two device memory buffers. diff --git a/cpp/tests/ast/transform_tests.cpp b/cpp/tests/ast/transform_tests.cpp index 48e19a2f587..738c58c32b8 100644 --- a/cpp/tests/ast/transform_tests.cpp +++ b/cpp/tests/ast/transform_tests.cpp @@ -42,6 +42,8 @@ template using column_wrapper = cudf::test::fixed_width_column_wrapper; +constexpr cudf::test::debug_output_level verbosity{cudf::test::debug_output_level::ALL_ERRORS}; + struct TransformTest : public cudf::test::BaseFixture { }; @@ -58,7 +60,7 @@ TEST_F(TransformTest, BasicAddition) auto expected = column_wrapper{13, 27, 21, 50}; auto result = cudf::ast::compute_column(table, expression); - cudf::test::expect_columns_equal(expected, result->view(), true); + cudf::test::expect_columns_equal(expected, result->view(), verbosity); } TEST_F(TransformTest, BasicAdditionLarge) @@ -74,7 +76,7 @@ TEST_F(TransformTest, BasicAdditionLarge) auto expected = column_wrapper(b, b + 2000); auto result = cudf::ast::compute_column(table, expression); - cudf::test::expect_columns_equal(expected, result->view(), true); + cudf::test::expect_columns_equal(expected, result->view(), verbosity); } TEST_F(TransformTest, LessComparator) @@ -90,7 +92,7 @@ TEST_F(TransformTest, LessComparator) auto expected = column_wrapper{true, false, true, false}; auto result = cudf::ast::compute_column(table, expression); - cudf::test::expect_columns_equal(expected, result->view(), true); + cudf::test::expect_columns_equal(expected, result->view(), verbosity); } TEST_F(TransformTest, LessComparatorLarge) @@ -109,7 +111,7 @@ TEST_F(TransformTest, LessComparatorLarge) auto expected = column_wrapper(c, c + 2000); auto result = cudf::ast::compute_column(table, expression); - cudf::test::expect_columns_equal(expected, result->view(), true); + cudf::test::expect_columns_equal(expected, result->view(), verbosity); } TEST_F(TransformTest, MultiLevelTreeArithmetic) @@ -135,7 +137,7 @@ TEST_F(TransformTest, MultiLevelTreeArithmetic) auto result = cudf::ast::compute_column(table, expression_tree); auto expected = column_wrapper{7, 73, 22, -99}; - cudf::test::expect_columns_equal(expected, result->view(), true); + cudf::test::expect_columns_equal(expected, result->view(), verbosity); } TEST_F(TransformTest, MultiLevelTreeArithmeticLarge) @@ -163,7 +165,7 @@ TEST_F(TransformTest, MultiLevelTreeArithmeticLarge) auto d = cudf::detail::make_counting_transform_iterator(0, [&](auto i) { return calc(i); }); auto expected = column_wrapper(d, d + 2000); - cudf::test::expect_columns_equal(expected, result->view(), true); + cudf::test::expect_columns_equal(expected, result->view(), verbosity); } TEST_F(TransformTest, ImbalancedTreeArithmetic) @@ -187,7 +189,7 @@ TEST_F(TransformTest, ImbalancedTreeArithmetic) auto expected = column_wrapper{0.6, std::numeric_limits::infinity(), -3.201, -2099.18}; - cudf::test::expect_columns_equal(expected, result->view(), true); + cudf::test::expect_columns_equal(expected, result->view(), verbosity); } TEST_F(TransformTest, MultiLevelTreeComparator) @@ -213,7 +215,7 @@ TEST_F(TransformTest, MultiLevelTreeComparator) auto result = cudf::ast::compute_column(table, expression_tree); auto expected = column_wrapper{false, true, false, false}; - cudf::test::expect_columns_equal(expected, result->view(), true); + cudf::test::expect_columns_equal(expected, result->view(), verbosity); } TEST_F(TransformTest, MultiTypeOperationFailure) @@ -249,7 +251,7 @@ TEST_F(TransformTest, LiteralComparison) auto result = cudf::ast::compute_column(table, expression); auto expected = column_wrapper{false, false, false, true}; - cudf::test::expect_columns_equal(expected, result->view(), true); + cudf::test::expect_columns_equal(expected, result->view(), verbosity); } TEST_F(TransformTest, UnaryNot) @@ -264,7 +266,7 @@ TEST_F(TransformTest, UnaryNot) auto result = cudf::ast::compute_column(table, expression); auto expected = column_wrapper{false, true, false, false}; - cudf::test::expect_columns_equal(expected, result->view(), true); + cudf::test::expect_columns_equal(expected, result->view(), verbosity); } TEST_F(TransformTest, UnaryTrigonometry) @@ -277,17 +279,17 @@ TEST_F(TransformTest, UnaryTrigonometry) auto expected_sin = column_wrapper{0.0, std::sqrt(2) / 2, std::sqrt(3.0) / 2.0}; auto expression_sin = cudf::ast::expression(cudf::ast::ast_operator::SIN, col_ref_0); auto result_sin = cudf::ast::compute_column(table, expression_sin); - cudf::test::expect_columns_equivalent(expected_sin, result_sin->view(), true); + cudf::test::expect_columns_equivalent(expected_sin, result_sin->view(), verbosity); auto expected_cos = column_wrapper{1.0, std::sqrt(2) / 2, 0.5}; auto expression_cos = cudf::ast::expression(cudf::ast::ast_operator::COS, col_ref_0); auto result_cos = cudf::ast::compute_column(table, expression_cos); - cudf::test::expect_columns_equivalent(expected_cos, result_cos->view(), true); + cudf::test::expect_columns_equivalent(expected_cos, result_cos->view(), verbosity); auto expected_tan = column_wrapper{0.0, 1.0, std::sqrt(3.0)}; auto expression_tan = cudf::ast::expression(cudf::ast::ast_operator::TAN, col_ref_0); auto result_tan = cudf::ast::compute_column(table, expression_tan); - cudf::test::expect_columns_equivalent(expected_tan, result_tan->view(), true); + cudf::test::expect_columns_equivalent(expected_tan, result_tan->view(), verbosity); } TEST_F(TransformTest, ArityCheckFailure) @@ -311,7 +313,7 @@ TEST_F(TransformTest, StringComparison) auto expected = column_wrapper{true, false, true, false}; auto result = cudf::ast::compute_column(table, expression); - cudf::test::expect_columns_equal(expected, result->view(), true); + cudf::test::expect_columns_equal(expected, result->view(), verbosity); } TEST_F(TransformTest, CopyColumn) @@ -325,7 +327,7 @@ TEST_F(TransformTest, CopyColumn) auto result = cudf::ast::compute_column(table, expression); auto expected = column_wrapper{3, 0, 1, 50}; - cudf::test::expect_columns_equal(expected, result->view(), true); + cudf::test::expect_columns_equal(expected, result->view(), verbosity); } TEST_F(TransformTest, CopyLiteral) @@ -341,7 +343,7 @@ TEST_F(TransformTest, CopyLiteral) auto result = cudf::ast::compute_column(table, expression); auto expected = column_wrapper{-123, -123, -123, -123}; - cudf::test::expect_columns_equal(expected, result->view(), true); + cudf::test::expect_columns_equal(expected, result->view(), verbosity); } TEST_F(TransformTest, TrueDiv) @@ -358,7 +360,7 @@ TEST_F(TransformTest, TrueDiv) auto result = cudf::ast::compute_column(table, expression); auto expected = column_wrapper{1.5, 0.0, 0.5, 25.0}; - cudf::test::expect_columns_equal(expected, result->view(), true); + cudf::test::expect_columns_equal(expected, result->view(), verbosity); } TEST_F(TransformTest, FloorDiv) @@ -375,7 +377,7 @@ TEST_F(TransformTest, FloorDiv) auto result = cudf::ast::compute_column(table, expression); auto expected = column_wrapper{1.0, 0.0, 0.0, 25.0}; - cudf::test::expect_columns_equal(expected, result->view(), true); + cudf::test::expect_columns_equal(expected, result->view(), verbosity); } TEST_F(TransformTest, Mod) @@ -392,7 +394,7 @@ TEST_F(TransformTest, Mod) auto result = cudf::ast::compute_column(table, expression); auto expected = column_wrapper{1.0, 0.0, -1.0, 0.0}; - cudf::test::expect_columns_equal(expected, result->view(), true); + cudf::test::expect_columns_equal(expected, result->view(), verbosity); } TEST_F(TransformTest, PyMod) @@ -409,7 +411,7 @@ TEST_F(TransformTest, PyMod) auto result = cudf::ast::compute_column(table, expression); auto expected = column_wrapper{1.0, 0.0, 1.0, 0.0}; - cudf::test::expect_columns_equal(expected, result->view(), true); + cudf::test::expect_columns_equal(expected, result->view(), verbosity); } TEST_F(TransformTest, BasicAdditionNulls) @@ -425,7 +427,7 @@ TEST_F(TransformTest, BasicAdditionNulls) auto expected = column_wrapper{{0, 0, 0, 50}, {0, 0, 0, 1}}; auto result = cudf::ast::compute_column(table, expression); - cudf::test::expect_columns_equal(expected, result->view(), true); + cudf::test::expect_columns_equal(expected, result->view(), verbosity); } TEST_F(TransformTest, BasicAdditionLargeNulls) @@ -451,7 +453,7 @@ TEST_F(TransformTest, BasicAdditionLargeNulls) auto expected = column_wrapper(b, b + N, validities.begin()); auto result = cudf::ast::compute_column(table, expression); - cudf::test::expect_columns_equal(expected, result->view(), true); + cudf::test::expect_columns_equal(expected, result->view(), verbosity); } CUDF_TEST_PROGRAM_MAIN() diff --git a/cpp/tests/binaryop/binop-integration-test.cpp b/cpp/tests/binaryop/binop-integration-test.cpp index 3f4cb073eb5..68a8845132b 100644 --- a/cpp/tests/binaryop/binop-integration-test.cpp +++ b/cpp/tests/binaryop/binop-integration-test.cpp @@ -37,6 +37,8 @@ namespace cudf { namespace test { namespace binop { +constexpr debug_output_level verbosity{debug_output_level::ALL_ERRORS}; + struct BinaryOperationIntegrationTest : public BinaryOperationTest { }; @@ -1089,7 +1091,7 @@ TEST_F(BinaryOperationIntegrationTest, NullAwareEqual_Vector_Scalar_B8_SI32_SI32 CUDF_TEST_EXPECT_COLUMNS_EQUAL( *op_col, fixed_width_column_wrapper{{true, false, false, false}, {true, true, true, true}}, - true); + verbosity); } TEST_F(BinaryOperationIntegrationTest, NullAwareEqual_Vector_ScalarInvalid_B8_SI32_SI32) @@ -1112,7 +1114,7 @@ TEST_F(BinaryOperationIntegrationTest, NullAwareEqual_Vector_ScalarInvalid_B8_SI {true, false, true, false, false, true}, {true, true, true, true, true, true}, }, - true); + verbosity); } TEST_F(BinaryOperationIntegrationTest, NullAwareEqual_Scalar_Vector_B8_tsD_tsD) @@ -1144,7 +1146,7 @@ TEST_F(BinaryOperationIntegrationTest, NullAwareEqual_Scalar_Vector_B8_tsD_tsD) {false, false, true, false, false, false, false, false}, {true, true, true, true, true, true, true, true}, }, - true); + verbosity); } TEST_F(BinaryOperationIntegrationTest, NullAwareEqual_Vector_Scalar_B8_string_string_EmptyString) @@ -1164,7 +1166,7 @@ TEST_F(BinaryOperationIntegrationTest, NullAwareEqual_Vector_Scalar_B8_string_st *op_col, fixed_width_column_wrapper{{false, false, false, true, false, false, false}, {true, true, true, true, true, true, true}}, - true); + verbosity); } TEST_F(BinaryOperationIntegrationTest, NullAwareEqual_Scalar_Vector_B8_string_string_ValidString) @@ -1184,7 +1186,7 @@ TEST_F(BinaryOperationIntegrationTest, NullAwareEqual_Scalar_Vector_B8_string_st *op_col, fixed_width_column_wrapper{{false, false, true, false, false, false, false}, {true, true, true, true, true, true, true}}, - true); + verbosity); } TEST_F(BinaryOperationIntegrationTest, NullAwareEqual_Vector_Scalar_B8_string_string_NoMatch) @@ -1205,7 +1207,7 @@ TEST_F(BinaryOperationIntegrationTest, NullAwareEqual_Vector_Scalar_B8_string_st *op_col, fixed_width_column_wrapper{{false, false, false, false, false, false, false}, {true, true, true, true, true, true, true}}, - true); + verbosity); } TEST_F(BinaryOperationIntegrationTest, NullAwareEqual_Scalar_Vector_B8_string_string_NullNonNull) @@ -1227,7 +1229,7 @@ TEST_F(BinaryOperationIntegrationTest, NullAwareEqual_Scalar_Vector_B8_string_st *op_col, fixed_width_column_wrapper{{false, false, false, false, false, false, false}, {true, true, true, true, true, true, true}}, - true); + verbosity); } TEST_F(BinaryOperationIntegrationTest, NullAwareEqual_Vector_Scalar_B8_string_string_NullNonNull) @@ -1249,7 +1251,7 @@ TEST_F(BinaryOperationIntegrationTest, NullAwareEqual_Vector_Scalar_B8_string_st *op_col, fixed_width_column_wrapper{{false, false, false, false, false, false, false}, {true, true, true, true, true, true, true}}, - true); + verbosity); } TEST_F(BinaryOperationIntegrationTest, NullAwareEqual_Scalar_Vector_B8_string_string_NullNull) @@ -1272,7 +1274,7 @@ TEST_F(BinaryOperationIntegrationTest, NullAwareEqual_Scalar_Vector_B8_string_st *op_col, fixed_width_column_wrapper{{true, true, true, true, true, true, true}, {true, true, true, true, true, true, true}}, - true); + verbosity); } TEST_F(BinaryOperationIntegrationTest, NullAwareEqual_Scalar_Vector_B8_string_string_MatchInvalid) @@ -1292,7 +1294,7 @@ TEST_F(BinaryOperationIntegrationTest, NullAwareEqual_Scalar_Vector_B8_string_st *op_col, fixed_width_column_wrapper{{false, false, false, false, false, false, false}, {true, true, true, true, true, true, true}}, - true); + verbosity); } TEST_F(BinaryOperationIntegrationTest, NullAwareEqual_Vector_InvalidScalar_B8_string_string) @@ -1313,7 +1315,7 @@ TEST_F(BinaryOperationIntegrationTest, NullAwareEqual_Vector_InvalidScalar_B8_st *op_col, fixed_width_column_wrapper{{false, true, false, false, false, true, false}, {true, true, true, true, true, true, true}}, - true); + verbosity); } TEST_F(BinaryOperationIntegrationTest, NullAwareEqual_Vector_Vector_B8_tsD_tsD_NonNullable) @@ -1347,7 +1349,7 @@ TEST_F(BinaryOperationIntegrationTest, NullAwareEqual_Vector_Vector_B8_tsD_tsD_N {true, false, true, false, true}, {true, true, true, true, true}, }, - true); + verbosity); } // Both vectors with mixed validity @@ -1370,7 +1372,7 @@ TEST_F(BinaryOperationIntegrationTest, NullAwareEqual_Vector_Vector_B8_string_st *op_col, fixed_width_column_wrapper{{false, false, true, true, false, true, true}, {true, true, true, true, true, true, true}}, - true); + verbosity); } TEST_F(BinaryOperationIntegrationTest, NullAwareEqual_Vector_Vector_B8_string_string_MixValid) @@ -1391,7 +1393,7 @@ TEST_F(BinaryOperationIntegrationTest, NullAwareEqual_Vector_Vector_B8_string_st *op_col, fixed_width_column_wrapper{{true, false, true, true, true, false, true}, {true, true, true, true, true, true, true}}, - true); + verbosity); } TEST_F(BinaryOperationIntegrationTest, NullAwareEqual_Vector_Vector_B8_string_string_MixInvalid) @@ -1413,7 +1415,7 @@ TEST_F(BinaryOperationIntegrationTest, NullAwareEqual_Vector_Vector_B8_string_st *op_col, fixed_width_column_wrapper{{false, true, false, false, false, true, false}, {true, true, true, true, true, true, true}}, - true); + verbosity); } TEST_F(BinaryOperationIntegrationTest, NullAwareEqual_Vector_Vector_B8_string_string_ValidValid) @@ -1433,7 +1435,7 @@ TEST_F(BinaryOperationIntegrationTest, NullAwareEqual_Vector_Vector_B8_string_st *op_col, fixed_width_column_wrapper{{true, true, true, true, true, true, true}, {true, true, true, true, true, true, true}}, - true); + verbosity); } TEST_F(BinaryOperationIntegrationTest, NullAwareEqual_Vector_Vector_B8_string_string_ValidInvalid) @@ -1454,7 +1456,7 @@ TEST_F(BinaryOperationIntegrationTest, NullAwareEqual_Vector_Vector_B8_string_st *op_col, fixed_width_column_wrapper{{false, false, false, false, false, false, false}, {true, true, true, true, true, true, true}}, - true); + verbosity); } TEST_F(BinaryOperationIntegrationTest, NullAwareEqual_Vector_Vector_B8_string_string_InvalidInvalid) @@ -1476,7 +1478,7 @@ TEST_F(BinaryOperationIntegrationTest, NullAwareEqual_Vector_Vector_B8_string_st *op_col, fixed_width_column_wrapper{{true, true, true, true, true, true, true}, {true, true, true, true, true, true, true}}, - true); + verbosity); } TEST_F(BinaryOperationIntegrationTest, NullAwareEqual_Vector_VectorAllInvalid_B8_SI32_SI32) @@ -1498,7 +1500,7 @@ TEST_F(BinaryOperationIntegrationTest, NullAwareEqual_Vector_VectorAllInvalid_B8 {true, true, true, true, true, true}, {true, true, true, true, true, true}, }, - true); + verbosity); } TEST_F(BinaryOperationIntegrationTest, NullAwareMin_Vector_Scalar_SI64_SI32_SI8) @@ -1517,7 +1519,9 @@ TEST_F(BinaryOperationIntegrationTest, NullAwareMin_Vector_Scalar_SI64_SI32_SI8) // Every row has a value CUDF_TEST_EXPECT_COLUMNS_EQUAL( - *op_col, fixed_width_column_wrapper{{77, -37, 0, 77}, {true, true, true, true}}, true); + *op_col, + fixed_width_column_wrapper{{77, -37, 0, 77}, {true, true, true, true}}, + verbosity); } TEST_F(BinaryOperationIntegrationTest, NullAwareMax_Scalar_Vector_FP64_SI32_SI64) @@ -1540,7 +1544,7 @@ TEST_F(BinaryOperationIntegrationTest, NullAwareMax_Scalar_Vector_FP64_SI32_SI64 fixed_width_column_wrapper{ {INT32_MAX, INT32_MAX, INT32_MAX, INT32_MAX, INT32_MAX, INT32_MAX, INT32_MAX}, {true, true, true, true, true, true, true}}, - true); + verbosity); } TEST_F(BinaryOperationIntegrationTest, NullAwareMin_Vector_Scalar_SI64_SI32_FP32) @@ -1563,7 +1567,7 @@ TEST_F(BinaryOperationIntegrationTest, NullAwareMin_Vector_Scalar_SI64_SI32_FP32 *op_col, fixed_width_column_wrapper{{0, -37, 0, INT32_MAX, 0, -4379, 0}, {false, true, false, true, false, true, false}}, - true); + verbosity); } TEST_F(BinaryOperationIntegrationTest, NullAwareMax_Scalar_Vector_SI8_SI8_FP32) @@ -1585,7 +1589,7 @@ TEST_F(BinaryOperationIntegrationTest, NullAwareMax_Scalar_Vector_SI8_SI8_FP32) *op_col, fixed_width_column_wrapper{{0, 0, 0, 0, 0, 0, 0}, {false, false, false, false, false, false, false}}, - true); + verbosity); } TEST_F(BinaryOperationIntegrationTest, NullAwareMin_Vector_Vector_SI64_SI32_SI8) @@ -1607,7 +1611,7 @@ TEST_F(BinaryOperationIntegrationTest, NullAwareMin_Vector_Vector_SI64_SI32_SI8) *op_col, fixed_width_column_wrapper{{0, 0, 0, 0, 0, 0, 0}, {false, false, false, false, false, false, false}}, - true); + verbosity); } TEST_F(BinaryOperationIntegrationTest, NullAwareMax_Vector_Vector_SI64_SI32_SI8) @@ -1628,7 +1632,7 @@ TEST_F(BinaryOperationIntegrationTest, NullAwareMax_Vector_Vector_SI64_SI32_SI8) *op_col, fixed_width_column_wrapper{{999, -37, 0, INT32_MAX, -INT32_MAX, -4379, 55}, {true, true, true, true, true, true, true}}, - true); + verbosity); } TEST_F(BinaryOperationIntegrationTest, NullAwareMin_Vector_Vector_tsD_tsD_tsD) @@ -1660,7 +1664,7 @@ TEST_F(BinaryOperationIntegrationTest, NullAwareMin_Vector_Vector_tsD_tsD_tsD) *op_col, fixed_width_column_wrapper{ {0, 44380, 47695, 66068, 0}, {true, true, true, true, false}}, - true); + verbosity); } TEST_F(BinaryOperationIntegrationTest, NullAwareMax_Vector_Vector_SI32_SI64_SI8) @@ -1682,7 +1686,7 @@ TEST_F(BinaryOperationIntegrationTest, NullAwareMax_Vector_Vector_SI32_SI64_SI8) *op_col, fixed_width_column_wrapper{{9, 0, 0, 0, -47, 0, 55}, {true, false, true, false, true, false, true}}, - true); + verbosity); } TEST_F(BinaryOperationIntegrationTest, NullAwareMax_Vector_Vector_string_string_string_Mix) @@ -1701,7 +1705,7 @@ TEST_F(BinaryOperationIntegrationTest, NullAwareMax_Vector_Vector_string_string_ {"", "invalid", "", "", "", "", "ééé", "", "", "def", "def"}, {false, true, true, true, true, true, true, false, false, true, true}); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*op_col, exp_col, true); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*op_col, exp_col, verbosity); } TEST_F(BinaryOperationIntegrationTest, NullAwareMin_Vector_Scalar_string_string_string_Mix) @@ -1719,7 +1723,7 @@ TEST_F(BinaryOperationIntegrationTest, NullAwareMin_Vector_Scalar_string_string_ auto exp_col = cudf::test::strings_column_wrapper( {"foo", "foo", "", "foo", "", "", "foo", "foo", "foo", "abc", "foo"}); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*op_col, exp_col, true); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*op_col, exp_col, verbosity); } TEST_F(BinaryOperationIntegrationTest, NullAwareMax_Scalar_Vector_string_string_string_Mix) @@ -1738,7 +1742,7 @@ TEST_F(BinaryOperationIntegrationTest, NullAwareMax_Scalar_Vector_string_string_ {"", "invalid", "", "", "", "", "ééé", "", "", "abc", "foo"}, {false, true, true, false, true, true, true, false, false, true, true}); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*op_col, exp_col, true); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*op_col, exp_col, verbosity); } TEST_F(BinaryOperationIntegrationTest, CastAdd_Vector_Vector_SI32_float_float) diff --git a/cpp/tests/copying/reverse_tests.cpp b/cpp/tests/copying/reverse_tests.cpp index 7f911e0aa85..3ba928f0249 100644 --- a/cpp/tests/copying/reverse_tests.cpp +++ b/cpp/tests/copying/reverse_tests.cpp @@ -30,6 +30,8 @@ #include #include +constexpr cudf::test::debug_output_level verbosity{cudf::test::debug_output_level::ALL_ERRORS}; + template class ReverseTypedTestFixture : public cudf::test::BaseFixture { }; @@ -54,7 +56,7 @@ TYPED_TEST(ReverseTypedTestFixture, ReverseTable) auto const p_ret = cudf::reverse(input_table); EXPECT_EQ(p_ret->num_columns(), 1); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(p_ret->view().column(0), expected, true); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(p_ret->view().column(0), expected, verbosity); } TYPED_TEST(ReverseTypedTestFixture, ReverseColumn) @@ -74,7 +76,7 @@ TYPED_TEST(ReverseTypedTestFixture, ReverseColumn) auto const column_ret = cudf::reverse(input); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(column_ret->view(), expected, true); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(column_ret->view(), expected, verbosity); } TYPED_TEST(ReverseTypedTestFixture, ReverseNullable) diff --git a/cpp/tests/copying/scatter_struct_scalar_tests.cpp b/cpp/tests/copying/scatter_struct_scalar_tests.cpp index c0594b4fd9a..4cfc1029566 100644 --- a/cpp/tests/copying/scatter_struct_scalar_tests.cpp +++ b/cpp/tests/copying/scatter_struct_scalar_tests.cpp @@ -27,9 +27,9 @@ namespace cudf { namespace test { -constexpr bool print_all{true}; // For debugging -constexpr int32_t null{0}; // Mark for null child elements -constexpr int32_t XXX{0}; // Mark for null struct elements +constexpr debug_output_level verbosity{debug_output_level::ALL_ERRORS}; +constexpr int32_t null{0}; // Mark for null child elements +constexpr int32_t XXX{0}; // Mark for null struct elements using structs_col = cudf::test::structs_column_wrapper; @@ -69,7 +69,7 @@ TYPED_TEST(TypedStructScalarScatterTest, Basic) auto got = scatter_single_scalar(*slr, scatter_map, target); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected, got, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected, got, verbosity); } TYPED_TEST(TypedStructScalarScatterTest, FillNulls) @@ -93,7 +93,7 @@ TYPED_TEST(TypedStructScalarScatterTest, FillNulls) auto got = scatter_single_scalar(*slr, scatter_map, target); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected, got, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected, got, verbosity); } TYPED_TEST(TypedStructScalarScatterTest, ScatterNullElements) @@ -118,7 +118,7 @@ TYPED_TEST(TypedStructScalarScatterTest, ScatterNullElements) auto got = scatter_single_scalar(*slr, scatter_map, target); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, got, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, got, verbosity); } TYPED_TEST(TypedStructScalarScatterTest, ScatterNullFields) @@ -142,7 +142,7 @@ TYPED_TEST(TypedStructScalarScatterTest, ScatterNullFields) auto got = scatter_single_scalar(*slr, scatter_map, target); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, got, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, got, verbosity); } TYPED_TEST(TypedStructScalarScatterTest, NegativeIndices) @@ -166,7 +166,7 @@ TYPED_TEST(TypedStructScalarScatterTest, NegativeIndices) auto got = scatter_single_scalar(*slr, scatter_map, target); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected, got, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected, got, verbosity); } TYPED_TEST(TypedStructScalarScatterTest, EmptyInputTest) @@ -190,7 +190,7 @@ TYPED_TEST(TypedStructScalarScatterTest, EmptyInputTest) auto got = scatter_single_scalar(*slr, scatter_map, target); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected, got, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected, got, verbosity); } TYPED_TEST(TypedStructScalarScatterTest, EmptyScatterMapTest) @@ -210,7 +210,7 @@ TYPED_TEST(TypedStructScalarScatterTest, EmptyScatterMapTest) auto got = scatter_single_scalar(*slr, scatter_map, target); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(target, got, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(target, got, verbosity); } TYPED_TEST(TypedStructScalarScatterTest, FixedWidthStringTypes) @@ -239,7 +239,7 @@ TYPED_TEST(TypedStructScalarScatterTest, FixedWidthStringTypes) auto got = scatter_single_scalar(*slr, scatter_map, target); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected, got, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected, got, verbosity); } TYPED_TEST(TypedStructScalarScatterTest, StructOfLists) @@ -263,7 +263,7 @@ TYPED_TEST(TypedStructScalarScatterTest, StructOfLists) auto got = scatter_single_scalar(*slr, scatter_map, target); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected, got, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected, got, verbosity); } } // namespace test diff --git a/cpp/tests/copying/scatter_struct_tests.cpp b/cpp/tests/copying/scatter_struct_tests.cpp index f469ee4d55a..14d3710f0e6 100644 --- a/cpp/tests/copying/scatter_struct_tests.cpp +++ b/cpp/tests/copying/scatter_struct_tests.cpp @@ -31,9 +31,9 @@ using int32s_col = cudf::test::fixed_width_column_wrapper; using structs_col = cudf::test::structs_column_wrapper; using strings_col = cudf::test::strings_column_wrapper; -constexpr bool print_all{false}; // For debugging -constexpr int32_t null{0}; // Mark for null child elements -constexpr int32_t XXX{0}; // Mark for null struct elements +constexpr cudf::test::debug_output_level verbosity{cudf::test::debug_output_level::FIRST_ERROR}; +constexpr int32_t null{0}; // Mark for null child elements +constexpr int32_t XXX{0}; // Mark for null struct elements template struct TypedStructScatterTest : public cudf::test::BaseFixture { @@ -71,7 +71,7 @@ TYPED_TEST(TypedStructScatterTest, EmptyInputTest) auto const scatter_map = int32s_col{}.release(); CUDF_TEST_EXPECT_COLUMNS_EQUAL( - *structs_src, scatter_structs(structs_src, structs_tgt, scatter_map), print_all); + *structs_src, scatter_structs(structs_src, structs_tgt, scatter_map), verbosity); } // Test case when only the scatter map is empty @@ -87,7 +87,7 @@ TYPED_TEST(TypedStructScatterTest, EmptyScatterMapTest) auto const scatter_map = int32s_col{}.release(); CUDF_TEST_EXPECT_COLUMNS_EQUAL( - *structs_tgt, scatter_structs(structs_src, structs_tgt, scatter_map), print_all); + *structs_tgt, scatter_structs(structs_src, structs_tgt, scatter_map), verbosity); } TYPED_TEST(TypedStructScatterTest, ScatterAsCopyTest) @@ -103,7 +103,7 @@ TYPED_TEST(TypedStructScatterTest, ScatterAsCopyTest) // Scatter as copy: the target should be the same as source auto const scatter_map = int32s_col{0, 1, 2, 3, 4, 5}.release(); CUDF_TEST_EXPECT_COLUMNS_EQUAL( - *structs_src, scatter_structs(structs_src, structs_tgt, scatter_map), print_all); + *structs_src, scatter_structs(structs_src, structs_tgt, scatter_map), verbosity); } TYPED_TEST(TypedStructScatterTest, ScatterAsLeftShiftTest) @@ -121,7 +121,7 @@ TYPED_TEST(TypedStructScatterTest, ScatterAsLeftShiftTest) auto const scatter_map = int32s_col{-2, -1, 0, 1, 2, 3}.release(); CUDF_TEST_EXPECT_COLUMNS_EQUAL( - *structs_expected, scatter_structs(structs_src, structs_tgt, scatter_map), print_all); + *structs_expected, scatter_structs(structs_src, structs_tgt, scatter_map), verbosity); } TYPED_TEST(TypedStructScatterTest, SimpleScatterTests) @@ -141,14 +141,14 @@ TYPED_TEST(TypedStructScatterTest, SimpleScatterTests) auto const structs_expected1 = structs_col{{child_col_expected1}, null_at(3)}.release(); auto const scatter_map1 = int32s_col{-2, 0, 5}.release(); CUDF_TEST_EXPECT_COLUMNS_EQUAL( - *structs_expected1, scatter_structs(structs_src, structs_tgt, scatter_map1), print_all); + *structs_expected1, scatter_structs(structs_src, structs_tgt, scatter_map1), verbosity); // Expected data auto child_col_expected2 = col_wrapper{{1, null, 70, 3, 0, 2}, null_at(1)}; auto const structs_expected2 = structs_col{{child_col_expected2}, no_nulls()}.release(); auto const scatter_map2 = int32s_col{-2, 0, 5, 3}.release(); CUDF_TEST_EXPECT_COLUMNS_EQUAL( - *structs_expected2, scatter_structs(structs_src, structs_tgt, scatter_map2), print_all); + *structs_expected2, scatter_structs(structs_src, structs_tgt, scatter_map2), verbosity); } TYPED_TEST(TypedStructScatterTest, ComplexDataScatterTest) @@ -187,7 +187,7 @@ TYPED_TEST(TypedStructScatterTest, ComplexDataScatterTest) // The first element of the target is not overwritten auto const scatter_map = int32s_col{-1, 4, 3, 2, 1}.release(); CUDF_TEST_EXPECT_COLUMNS_EQUAL( - *structs_expected, scatter_structs(structs_src, structs_tgt, scatter_map), print_all); + *structs_expected, scatter_structs(structs_src, structs_tgt, scatter_map), verbosity); } TYPED_TEST(TypedStructScatterTest, ScatterStructOfListsTest) @@ -219,7 +219,7 @@ TYPED_TEST(TypedStructScatterTest, ScatterStructOfListsTest) // The first 2 elements of the target is not overwritten auto const scatter_map = int32s_col{-3, -2, -1, 5, 4, 3, 2}.release(); CUDF_TEST_EXPECT_COLUMNS_EQUAL( - *structs_expected, scatter_structs(structs_src, structs_tgt, scatter_map), print_all); + *structs_expected, scatter_structs(structs_src, structs_tgt, scatter_map), verbosity); } TYPED_TEST(TypedStructScatterTest, SourceSmallerThanTargetScatterTest) @@ -237,7 +237,7 @@ TYPED_TEST(TypedStructScatterTest, SourceSmallerThanTargetScatterTest) auto const scatter_map = int32s_col{2, 5}.release(); CUDF_TEST_EXPECT_COLUMNS_EQUAL( - *structs_expected, scatter_structs(structs_src, structs_tgt, scatter_map), print_all); + *structs_expected, scatter_structs(structs_src, structs_tgt, scatter_map), verbosity); } TYPED_TEST(TypedStructScatterTest, IntStructNullMaskRegression) @@ -256,5 +256,5 @@ TYPED_TEST(TypedStructScatterTest, IntStructNullMaskRegression) auto expected_struct = structs_col({expected_child}).release(); auto const result = scatter_structs(struct_col_src, struct_col_tgt, scatter_map); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*expected_struct, result, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*expected_struct, result, verbosity); } diff --git a/cpp/tests/datetime/datetime_ops_test.cpp b/cpp/tests/datetime/datetime_ops_test.cpp index cdfc9de395c..c200dc6c935 100644 --- a/cpp/tests/datetime/datetime_ops_test.cpp +++ b/cpp/tests/datetime/datetime_ops_test.cpp @@ -28,6 +28,8 @@ #define XXX false // stub for null values +constexpr cudf::test::debug_output_level verbosity{cudf::test::debug_output_level::ALL_ERRORS}; + template struct NonTimestampTest : public cudf::test::BaseFixture { cudf::data_type type() { return cudf::data_type{cudf::type_to_id()}; } @@ -302,7 +304,7 @@ TEST_F(BasicDatetimeOpsTest, TestLastDayOfMonthWithSeconds) 30, // This is the UNIX epoch - when rounded up becomes 1970-01-31 -1523 // 1965-10-31 }, - true); + verbosity); } TEST_F(BasicDatetimeOpsTest, TestLastDayOfMonthWithDate) @@ -342,7 +344,7 @@ TEST_F(BasicDatetimeOpsTest, TestLastDayOfMonthWithDate) 111 // Random nullable field }, {false, true, true, true, false, true, true, false}}, - true); + verbosity); } TEST_F(BasicDatetimeOpsTest, TestDayOfYearWithDate) @@ -384,7 +386,7 @@ TEST_F(BasicDatetimeOpsTest, TestDayOfYearWithDate) }, {false, true, true, true, false, true, true, false, true}, }, - true); + verbosity); } TEST_F(BasicDatetimeOpsTest, TestDayOfYearWithEmptyColumn) @@ -480,7 +482,7 @@ TEST_F(BasicDatetimeOpsTest, TestAddMonthsWithSeconds) -128952000L, // 1965-11-30 12:00:00 GMT -123587928L // 1966-01-31 14:01:12 GMT }, - true); + verbosity); } TEST_F(BasicDatetimeOpsTest, TestAddMonthsWithSecondsAndNullValues) @@ -531,7 +533,7 @@ TEST_F(BasicDatetimeOpsTest, TestAddMonthsWithSecondsAndNullValues) -123587928L // 1966-01-31 14:01:12 GMT }, {false, false, true, false, true, false, true, false, true, true, true, true}}, - true); + verbosity); } TEST_F(BasicDatetimeOpsTest, TestIsLeapYear) diff --git a/cpp/tests/filling/repeat_tests.cpp b/cpp/tests/filling/repeat_tests.cpp index 730ef8c1d16..6c4f0f6b7f0 100644 --- a/cpp/tests/filling/repeat_tests.cpp +++ b/cpp/tests/filling/repeat_tests.cpp @@ -34,6 +34,8 @@ #include #include +constexpr cudf::test::debug_output_level verbosity{cudf::test::debug_output_level::ALL_ERRORS}; + template class RepeatTypedTestFixture : public cudf::test::BaseFixture, cudf::test::UniformRandomGenerator { @@ -67,7 +69,7 @@ TYPED_TEST(RepeatTypedTestFixture, RepeatScalarCount) auto const p_ret = cudf::repeat(input_table, repeat_count); EXPECT_EQ(p_ret->num_columns(), 1); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(p_ret->view().column(0), expected, true); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(p_ret->view().column(0), expected, verbosity); } TYPED_TEST(RepeatTypedTestFixture, RepeatColumnCount) diff --git a/cpp/tests/groupby/groupby_test_util.hpp b/cpp/tests/groupby/groupby_test_util.hpp index 12d46cebb1c..9a083ac8e74 100644 --- a/cpp/tests/groupby/groupby_test_util.hpp +++ b/cpp/tests/groupby/groupby_test_util.hpp @@ -88,14 +88,16 @@ inline void test_single_agg(column_view const& keys, if (use_sort == force_use_sort_impl::YES) { CUDF_TEST_EXPECT_TABLES_EQUAL(table_view({expect_keys}), result.first->view()); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expect_vals, *result.second[0].results[0], true); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT( + expect_vals, *result.second[0].results[0], debug_output_level::ALL_ERRORS); } else { auto const sort_order = sorted_order(result.first->view(), {}, {null_order::AFTER}); auto const sorted_keys = gather(result.first->view(), *sort_order); auto const sorted_vals = gather(table_view({result.second[0].results[0]->view()}), *sort_order); CUDF_TEST_EXPECT_TABLES_EQUAL(table_view({expect_keys}), *sorted_keys); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expect_vals, sorted_vals->get_column(0), true); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT( + expect_vals, sorted_vals->get_column(0), debug_output_level::ALL_ERRORS); } } @@ -122,7 +124,8 @@ inline void test_single_scan(column_view const& keys, auto result = gb_obj.scan(requests); CUDF_TEST_EXPECT_TABLES_EQUAL(table_view({expect_keys}), result.first->view()); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expect_vals, *result.second[0].results[0], true); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT( + expect_vals, *result.second[0].results[0], debug_output_level::ALL_ERRORS); } } // namespace test diff --git a/cpp/tests/groupby/m2_tests.cpp b/cpp/tests/groupby/m2_tests.cpp index 7611dce2271..7b338a0d9b8 100644 --- a/cpp/tests/groupby/m2_tests.cpp +++ b/cpp/tests/groupby/m2_tests.cpp @@ -26,7 +26,7 @@ using namespace cudf::test::iterators; namespace { -constexpr bool print_all{false}; // For debugging +constexpr cudf::test::debug_output_level verbosity{cudf::test::debug_output_level::FIRST_ERROR}; constexpr int32_t null{0}; // Mark for null elements constexpr double NaN{std::numeric_limits::quiet_NaN()}; // Mark for NaN double elements @@ -72,8 +72,8 @@ TYPED_TEST(GroupbyM2TypedTest, EmptyInput) auto const [out_keys, out_M2s] = compute_M2(keys, vals); auto const expected_M2s = M2s_col{}; - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(keys, *out_keys, print_all); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_M2s, *out_M2s, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(keys, *out_keys, verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_M2s, *out_M2s, verbosity); } TYPED_TEST(GroupbyM2TypedTest, AllNullKeysInput) @@ -88,8 +88,8 @@ TYPED_TEST(GroupbyM2TypedTest, AllNullKeysInput) auto const expected_keys = keys_col{}; auto const expected_M2s = M2s_col{}; - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_keys, *out_keys, print_all); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_M2s, *out_M2s, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_keys, *out_keys, verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_M2s, *out_M2s, verbosity); } TYPED_TEST(GroupbyM2TypedTest, AllNullValuesInput) @@ -103,8 +103,8 @@ TYPED_TEST(GroupbyM2TypedTest, AllNullValuesInput) auto const [out_keys, out_M2s] = compute_M2(keys, vals); auto const expected_M2s = M2s_col{{null, null, null}, all_nulls()}; - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(keys, *out_keys, print_all); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_M2s, *out_M2s, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(keys, *out_keys, verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_M2s, *out_M2s, verbosity); } TYPED_TEST(GroupbyM2TypedTest, SimpleInput) @@ -122,8 +122,8 @@ TYPED_TEST(GroupbyM2TypedTest, SimpleInput) auto const expected_keys = keys_col{1, 2, 3}; auto const expected_M2s = M2s_col{18.0, 32.75, 20.0 + 2.0 / 3.0}; - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_keys, *out_keys, print_all); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_M2s, *out_M2s, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_keys, *out_keys, verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_M2s, *out_M2s, verbosity); } TYPED_TEST(GroupbyM2TypedTest, SimpleInputHavingNegativeValues) @@ -141,8 +141,8 @@ TYPED_TEST(GroupbyM2TypedTest, SimpleInputHavingNegativeValues) auto const expected_keys = keys_col{1, 2, 3}; auto const expected_M2s = M2s_col{42.0, 122.75, 114.0}; - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_keys, *out_keys, print_all); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_M2s, *out_M2s, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_keys, *out_keys, verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_M2s, *out_M2s, verbosity); } TYPED_TEST(GroupbyM2TypedTest, ValuesHaveNulls) @@ -157,8 +157,8 @@ TYPED_TEST(GroupbyM2TypedTest, ValuesHaveNulls) auto const expected_keys = keys_col{1, 2, 3, 4, 5}; auto const expected_M2s = M2s_col{{0.0, 2.0, 8.0, 0.0, 0.0 /*NULL*/}, null_at(4)}; - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_keys, *out_keys, print_all); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_M2s, *out_M2s, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_keys, *out_keys, verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_M2s, *out_M2s, verbosity); } TYPED_TEST(GroupbyM2TypedTest, KeysAndValuesHaveNulls) @@ -177,8 +177,8 @@ TYPED_TEST(GroupbyM2TypedTest, KeysAndValuesHaveNulls) auto const expected_keys = keys_col{1, 2, 3, 4}; auto const expected_M2s = M2s_col{{4.5, 32.0 + 2.0 / 3.0, 18.0, 0.0 /*NULL*/}, null_at(3)}; - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_keys, *out_keys, print_all); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_M2s, *out_M2s, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_keys, *out_keys, verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_M2s, *out_M2s, verbosity); } TYPED_TEST(GroupbyM2TypedTest, InputHaveNullsAndNaNs) @@ -199,8 +199,8 @@ TYPED_TEST(GroupbyM2TypedTest, InputHaveNullsAndNaNs) auto const expected_keys = keys_col{1, 2, 3, 4}; auto const expected_M2s = M2s_col{18.0, NaN, 18.0, NaN}; - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_keys, *out_keys, print_all); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_M2s, *out_M2s, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_keys, *out_keys, verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_M2s, *out_M2s, verbosity); } TYPED_TEST(GroupbyM2TypedTest, SlicedColumnsInput) @@ -238,6 +238,6 @@ TYPED_TEST(GroupbyM2TypedTest, SlicedColumnsInput) auto const expected_keys = keys_col{1, 2, 3, 4}; auto const expected_M2s = M2s_col{18.0, NaN, 18.0, NaN}; - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_keys, *out_keys, print_all); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_M2s, *out_M2s, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_keys, *out_keys, verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_M2s, *out_M2s, verbosity); } diff --git a/cpp/tests/groupby/merge_lists_tests.cpp b/cpp/tests/groupby/merge_lists_tests.cpp index 7851565d86a..29c6185e3a5 100644 --- a/cpp/tests/groupby/merge_lists_tests.cpp +++ b/cpp/tests/groupby/merge_lists_tests.cpp @@ -28,8 +28,8 @@ using namespace cudf::test::iterators; namespace { -constexpr bool print_all{false}; // For debugging -constexpr int32_t null{0}; // Mark for null elements +constexpr cudf::test::debug_output_level verbosity{cudf::test::debug_output_level::FIRST_ERROR}; +constexpr int32_t null{0}; // Mark for null elements using vcol_views = std::vector; @@ -91,8 +91,8 @@ TYPED_TEST(GroupbyMergeListsTypedTest, EmptyInput) auto const expected_keys = keys_col{}; auto const expected_lists = cudf::empty_like(lists0); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_keys, *out_keys, print_all); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*expected_lists, *out_lists, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_keys, *out_keys, verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*expected_lists, *out_lists, verbosity); } TYPED_TEST(GroupbyMergeListsTypedTest, InputWithoutNull) @@ -128,8 +128,8 @@ TYPED_TEST(GroupbyMergeListsTypedTest, InputWithoutNull) {24, 25, 26} // key = 4 }; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_keys, *out_keys, print_all); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_lists, *out_lists, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_keys, *out_keys, verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_lists, *out_lists, verbosity); } TYPED_TEST(GroupbyMergeListsTypedTest, InputHasNulls) @@ -167,8 +167,8 @@ TYPED_TEST(GroupbyMergeListsTypedTest, InputHasNulls) lists_col{24, 25, 26} // key = 4 }; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_keys, *out_keys, print_all); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_lists, *out_lists, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_keys, *out_keys, verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_lists, *out_lists, verbosity); } TYPED_TEST(GroupbyMergeListsTypedTest, InputHasEmptyLists) @@ -204,8 +204,8 @@ TYPED_TEST(GroupbyMergeListsTypedTest, InputHasEmptyLists) {24, 25, 26} // key = 4 }; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_keys, *out_keys, print_all); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_lists, *out_lists, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_keys, *out_keys, verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_lists, *out_lists, verbosity); } TYPED_TEST(GroupbyMergeListsTypedTest, InputHasNullsAndEmptyLists) @@ -245,8 +245,8 @@ TYPED_TEST(GroupbyMergeListsTypedTest, InputHasNullsAndEmptyLists) lists_col{24, 25, 26} // key = 4 }; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_keys, *out_keys, print_all); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_lists, *out_lists, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_keys, *out_keys, verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_lists, *out_lists, verbosity); } TYPED_TEST(GroupbyMergeListsTypedTest, InputHasListsOfLists) @@ -283,8 +283,8 @@ TYPED_TEST(GroupbyMergeListsTypedTest, InputHasListsOfLists) lists_col{lists_col{17, 18, 19, 20, 21}, lists_col{18, 19, 20}} // key = 4 }; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_keys, *out_keys, print_all); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_lists, *out_lists, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_keys, *out_keys, verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_lists, *out_lists, verbosity); } TYPED_TEST(GroupbyMergeListsTypedTest, SlicedColumnsInput) @@ -331,8 +331,8 @@ TYPED_TEST(GroupbyMergeListsTypedTest, SlicedColumnsInput) {24, 25, 26} // key = 4 }; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_keys, *out_keys, print_all); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_lists, *out_lists, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_keys, *out_keys, verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_lists, *out_lists, verbosity); } struct GroupbyMergeListsTest : public cudf::test::BaseFixture { @@ -383,6 +383,6 @@ TEST_F(GroupbyMergeListsTest, StringsColumnInput) lists_col{{"Seeedless", "Mini"}, no_nulls()} // key = "water melon" }; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_keys, *out_keys, print_all); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_lists, *out_lists, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_keys, *out_keys, verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_lists, *out_lists, verbosity); } diff --git a/cpp/tests/groupby/merge_m2_tests.cpp b/cpp/tests/groupby/merge_m2_tests.cpp index 63451f9612d..3ec8bfec774 100644 --- a/cpp/tests/groupby/merge_m2_tests.cpp +++ b/cpp/tests/groupby/merge_m2_tests.cpp @@ -28,7 +28,7 @@ using namespace cudf::test::iterators; namespace { -constexpr bool print_all{false}; // For debugging +constexpr cudf::test::debug_output_level verbosity{cudf::test::debug_output_level::FIRST_ERROR}; constexpr int32_t null{0}; // Mark for null elements constexpr double NaN{std::numeric_limits::quiet_NaN()}; // Mark for NaN double elements @@ -148,8 +148,8 @@ TYPED_TEST(GroupbyMergeM2TypedTest, EmptyInput) auto const vals = structs_col{vals_count, vals_mean, vals_M2}; auto const [out_keys, out_vals] = merge_M2({keys}, {vals}); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(keys, *out_keys, print_all); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(vals, *out_vals, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(keys, *out_keys, verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(vals, *out_vals, verbosity); } TYPED_TEST(GroupbyMergeM2TypedTest, SimpleInput) @@ -196,8 +196,8 @@ TYPED_TEST(GroupbyMergeM2TypedTest, SimpleInput) merge_M2(vcol_views{*out3_keys, *out4_keys}, vcol_views{*out3_vals, *out4_vals}); auto const out_M2s = final_vals->child(2); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_keys, *final_keys, print_all); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_M2s, out_M2s, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_keys, *final_keys, verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_M2s, out_M2s, verbosity); } // One step merging: @@ -206,8 +206,8 @@ TYPED_TEST(GroupbyMergeM2TypedTest, SimpleInput) vcol_views{*out1_vals, *out2_vals, *out3_vals}); auto const out_M2s = final_vals->child(2); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_keys, *final_keys, print_all); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_M2s, out_M2s, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_keys, *final_keys, verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_M2s, out_M2s, verbosity); } } @@ -255,8 +255,8 @@ TYPED_TEST(GroupbyMergeM2TypedTest, SimpleInputHavingNegativeValues) merge_M2(vcol_views{*out3_keys, *out4_keys}, vcol_views{*out3_vals, *out4_vals}); auto const out_M2s = final_vals->child(2); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_keys, *final_keys, print_all); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_M2s, out_M2s, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_keys, *final_keys, verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_M2s, out_M2s, verbosity); } // One step merging: @@ -265,8 +265,8 @@ TYPED_TEST(GroupbyMergeM2TypedTest, SimpleInputHavingNegativeValues) vcol_views{*out1_vals, *out2_vals, *out3_vals}); auto const out_M2s = final_vals->child(2); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_keys, *final_keys, print_all); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_M2s, out_M2s, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_keys, *final_keys, verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_M2s, out_M2s, verbosity); } } @@ -315,8 +315,8 @@ TYPED_TEST(GroupbyMergeM2TypedTest, InputHasNulls) merge_M2(vcol_views{*out3_keys, *out4_keys}, vcol_views{*out3_vals, *out4_vals}); auto const out_M2s = final_vals->child(2); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_keys, *final_keys, print_all); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_M2s, out_M2s, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_keys, *final_keys, verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_M2s, out_M2s, verbosity); } // One step merging: @@ -325,8 +325,8 @@ TYPED_TEST(GroupbyMergeM2TypedTest, InputHasNulls) vcol_views{*out1_vals, *out2_vals, *out3_vals}); auto const out_M2s = final_vals->child(2); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_keys, *final_keys, print_all); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_M2s, out_M2s, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_keys, *final_keys, verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_M2s, out_M2s, verbosity); } } @@ -380,8 +380,8 @@ TYPED_TEST(GroupbyMergeM2TypedTest, InputHaveNullsAndNaNs) merge_M2(vcol_views{*out5_keys, *out6_keys}, vcol_views{*out5_vals, *out6_vals}); auto const out_M2s = final_vals->child(2); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_keys, *final_keys, print_all); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_M2s, out_M2s, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_keys, *final_keys, verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_M2s, out_M2s, verbosity); } // One step merging: @@ -391,8 +391,8 @@ TYPED_TEST(GroupbyMergeM2TypedTest, InputHaveNullsAndNaNs) vcol_views{*out1_vals, *out2_vals, *out3_vals, *out4_vals}); auto const out_M2s = final_vals->child(2); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_keys, *final_keys, print_all); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_M2s, out_M2s, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_keys, *final_keys, verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_M2s, out_M2s, verbosity); } } @@ -462,8 +462,8 @@ TYPED_TEST(GroupbyMergeM2TypedTest, SlicedColumnsInput) merge_M2(vcol_views{*out5_keys, *out6_keys}, vcol_views{*out5_vals, *out6_vals}); auto const out_M2s = final_vals->child(2); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_keys, *final_keys, print_all); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_M2s, out_M2s, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_keys, *final_keys, verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_M2s, out_M2s, verbosity); } // One step merging: @@ -473,7 +473,7 @@ TYPED_TEST(GroupbyMergeM2TypedTest, SlicedColumnsInput) vcol_views{*out1_vals, *out2_vals, *out3_vals, *out4_vals}); auto const out_M2s = final_vals->child(2); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_keys, *final_keys, print_all); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_M2s, out_M2s, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_keys, *final_keys, verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_M2s, out_M2s, verbosity); } } diff --git a/cpp/tests/groupby/merge_sets_tests.cpp b/cpp/tests/groupby/merge_sets_tests.cpp index 1365245c8af..ee4f61bf44f 100644 --- a/cpp/tests/groupby/merge_sets_tests.cpp +++ b/cpp/tests/groupby/merge_sets_tests.cpp @@ -28,8 +28,8 @@ using namespace cudf::test::iterators; namespace { -constexpr bool print_all{false}; // For debugging -constexpr int32_t null{0}; // Mark for null elements +constexpr cudf::test::debug_output_level verbosity{cudf::test::debug_output_level::FIRST_ERROR}; +constexpr int32_t null{0}; // Mark for null elements using vcol_views = std::vector; @@ -91,8 +91,8 @@ TYPED_TEST(GroupbyMergeSetsTypedTest, EmptyInput) auto const expected_keys = keys_col{}; auto const expected_lists = cudf::empty_like(lists0); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_keys, *out_keys, print_all); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*expected_lists, *out_lists, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_keys, *out_keys, verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*expected_lists, *out_lists, verbosity); } TYPED_TEST(GroupbyMergeSetsTypedTest, InputWithoutNull) @@ -128,8 +128,8 @@ TYPED_TEST(GroupbyMergeSetsTypedTest, InputWithoutNull) {30, 31, 32} // key = 4 }; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_keys, *out_keys, print_all); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_lists, *out_lists, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_keys, *out_keys, verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_lists, *out_lists, verbosity); } TYPED_TEST(GroupbyMergeSetsTypedTest, InputHasNulls) @@ -167,8 +167,8 @@ TYPED_TEST(GroupbyMergeSetsTypedTest, InputHasNulls) lists_col{{30, 32, null}, null_at(2)} // key = 4 }; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_keys, *out_keys, print_all); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_lists, *out_lists, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_keys, *out_keys, verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_lists, *out_lists, verbosity); } TYPED_TEST(GroupbyMergeSetsTypedTest, InputHasEmptyLists) @@ -204,8 +204,8 @@ TYPED_TEST(GroupbyMergeSetsTypedTest, InputHasEmptyLists) {24, 25, 26} // key = 4 }; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_keys, *out_keys, print_all); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_lists, *out_lists, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_keys, *out_keys, verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_lists, *out_lists, verbosity); } TYPED_TEST(GroupbyMergeSetsTypedTest, InputHasNullsAndEmptyLists) @@ -245,8 +245,8 @@ TYPED_TEST(GroupbyMergeSetsTypedTest, InputHasNullsAndEmptyLists) lists_col{{20, 24, 25, 26, null}, null_at(4)} // key = 4 }; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_keys, *out_keys, print_all); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_lists, *out_lists, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_keys, *out_keys, verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_lists, *out_lists, verbosity); } TYPED_TEST(GroupbyMergeSetsTypedTest, SlicedColumnsInput) @@ -293,8 +293,8 @@ TYPED_TEST(GroupbyMergeSetsTypedTest, SlicedColumnsInput) {24, 25, 26} // key = 4 }; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_keys, *out_keys, print_all); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_lists, *out_lists, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_keys, *out_keys, verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_lists, *out_lists, verbosity); } struct GroupbyMergeSetsTest : public cudf::test::BaseFixture { @@ -340,6 +340,6 @@ TEST_F(GroupbyMergeSetsTest, StringsColumnInput) lists_col{{"Mini", "Seeedless"}, no_nulls()} // key = "water melon" }; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_keys, *out_keys, print_all); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_lists, *out_lists, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_keys, *out_keys, verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_lists, *out_lists, verbosity); } diff --git a/cpp/tests/hashing/hash_test.cpp b/cpp/tests/hashing/hash_test.cpp index d928a17b3d1..a605fdee6a0 100644 --- a/cpp/tests/hashing/hash_test.cpp +++ b/cpp/tests/hashing/hash_test.cpp @@ -27,6 +27,8 @@ using cudf::test::fixed_width_column_wrapper; using cudf::test::strings_column_wrapper; using namespace cudf::test; +constexpr debug_output_level verbosity{debug_output_level::ALL_ERRORS}; + class HashTest : public cudf::test::BaseFixture { }; @@ -216,16 +218,16 @@ TYPED_TEST(HashTestFloatTyped, TestExtremes) auto const hash_col_neg_zero = cudf::hash(table_col_neg_zero); auto const hash_col_neg_nan = cudf::hash(table_col_neg_nan); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*hash_col, *hash_col_neg_zero, true); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*hash_col, *hash_col_neg_nan, true); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*hash_col, *hash_col_neg_zero, verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*hash_col, *hash_col_neg_nan, verbosity); constexpr auto serial_hasher = cudf::hash_id::HASH_SERIAL_MURMUR3; auto const serial_col = cudf::hash(table_col, serial_hasher, {}, 0); auto const serial_col_neg_zero = cudf::hash(table_col_neg_zero, serial_hasher); auto const serial_col_neg_nan = cudf::hash(table_col_neg_nan, serial_hasher); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*serial_col, *serial_col_neg_zero, true); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*serial_col, *serial_col_neg_nan, true); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*serial_col, *serial_col_neg_zero, verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*serial_col, *serial_col_neg_nan, verbosity); // Spark hash is sensitive to 0 and -0 constexpr auto spark_hasher = cudf::hash_id::HASH_SPARK_MURMUR3; @@ -273,11 +275,11 @@ TEST_F(SerialMurmurHash3Test, MultiValueWithSeeds) auto const combo2_hash = cudf::hash(combo2, hasher, {}); auto const structs_hash = cudf::hash(cudf::table_view({structs_col}), hasher, {}); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*strings_hash, strings_col_result, true); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*ints_hash, ints_col_result, true); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*strings_hash, strings_col_result, verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*ints_hash, ints_col_result, verbosity); EXPECT_EQ(combo1.num_rows(), combo1_hash->size()); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*combo1_hash, *combo2_hash, true); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*structs_hash, *combo1_hash, true); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*combo1_hash, *combo2_hash, verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*structs_hash, *combo1_hash, verbosity); } TEST_F(SerialMurmurHash3Test, ListThrows) @@ -409,20 +411,20 @@ TEST_F(SparkMurmurHash3Test, MultiValueWithSeeds) auto const hash_bools1 = cudf::hash(cudf::table_view({bools_col1}), hasher, {}, 42); auto const hash_bools2 = cudf::hash(cudf::table_view({bools_col2}), hasher, {}, 42); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*hash_structs, hash_structs_expected, true); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*hash_strings, hash_strings_expected, true); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*hash_doubles, hash_doubles_expected, true); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*hash_timestamps, hash_timestamps_expected, true); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*hash_decimal64, hash_decimal64_expected, true); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*hash_longs, hash_longs_expected, true); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*hash_floats, hash_floats_expected, true); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*hash_dates, hash_dates_expected, true); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*hash_decimal32, hash_decimal32_expected, true); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*hash_ints, hash_ints_expected, true); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*hash_shorts, hash_shorts_expected, true); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*hash_bytes, hash_bytes_expected, true); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*hash_bools1, hash_bools_expected, true); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*hash_bools2, hash_bools_expected, true); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*hash_structs, hash_structs_expected, verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*hash_strings, hash_strings_expected, verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*hash_doubles, hash_doubles_expected, verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*hash_timestamps, hash_timestamps_expected, verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*hash_decimal64, hash_decimal64_expected, verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*hash_longs, hash_longs_expected, verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*hash_floats, hash_floats_expected, verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*hash_dates, hash_dates_expected, verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*hash_decimal32, hash_decimal32_expected, verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*hash_ints, hash_ints_expected, verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*hash_shorts, hash_shorts_expected, verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*hash_bytes, hash_bytes_expected, verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*hash_bools1, hash_bools_expected, verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*hash_bools2, hash_bools_expected, verbosity); auto const combined_table = cudf::table_view({structs_col, strings_col, @@ -438,7 +440,7 @@ TEST_F(SparkMurmurHash3Test, MultiValueWithSeeds) bytes_col, bools_col2}); auto const hash_combined = cudf::hash(combined_table, hasher, {}, 42); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*hash_combined, hash_combined_expected, true); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*hash_combined, hash_combined_expected, verbosity); } TEST_F(SparkMurmurHash3Test, ListThrows) @@ -687,7 +689,7 @@ TYPED_TEST(MD5HashTestFloatTyped, TestExtremes) auto const output1 = cudf::hash(input1, cudf::hash_id::HASH_MD5); auto const output2 = cudf::hash(input2, cudf::hash_id::HASH_MD5); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(output1->view(), output2->view(), true); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(output1->view(), output2->view(), verbosity); } TYPED_TEST(MD5HashTestFloatTyped, TestListExtremes) @@ -709,7 +711,7 @@ TYPED_TEST(MD5HashTestFloatTyped, TestListExtremes) auto const output1 = cudf::hash(input1, cudf::hash_id::HASH_MD5); auto const output2 = cudf::hash(input2, cudf::hash_id::HASH_MD5); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(output1->view(), output2->view(), true); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(output1->view(), output2->view(), verbosity); } CUDF_TEST_PROGRAM_MAIN() diff --git a/cpp/tests/io/orc_test.cpp b/cpp/tests/io/orc_test.cpp index 56573ddab40..e6eb3020795 100644 --- a/cpp/tests/io/orc_test.cpp +++ b/cpp/tests/io/orc_test.cpp @@ -634,7 +634,9 @@ TEST_F(OrcWriterTest, negTimestampsNano) cudf_io::orc_reader_options::builder(cudf_io::source_info{filepath}).use_index(false); auto result = cudf_io::read_orc(in_opts); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected->view().column(0), result.tbl->view().column(0), true); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected->view().column(0), + result.tbl->view().column(0), + cudf::test::debug_output_level::ALL_ERRORS); CUDF_TEST_EXPECT_TABLES_EQUAL(expected->view(), result.tbl->view()); } diff --git a/cpp/tests/lists/combine/concatenate_list_elements_tests.cpp b/cpp/tests/lists/combine/concatenate_list_elements_tests.cpp index c71e5224fe9..0d988da34ea 100644 --- a/cpp/tests/lists/combine/concatenate_list_elements_tests.cpp +++ b/cpp/tests/lists/combine/concatenate_list_elements_tests.cpp @@ -28,7 +28,7 @@ using StrListsCol = cudf::test::lists_column_wrapper; using IntListsCol = cudf::test::lists_column_wrapper; using IntCol = cudf::test::fixed_width_column_wrapper; -constexpr bool print_all{false}; // For debugging +constexpr cudf::test::debug_output_level verbosity{cudf::test::debug_output_level::FIRST_ERROR}; constexpr int32_t null{0}; template @@ -76,7 +76,7 @@ TYPED_TEST(ConcatenateListElementsTypedTest, SimpleInputNoNull) auto const col = build_lists_col(row0, row1, row2); auto const results = cudf::lists::concatenate_list_elements(col); auto const expected = ListsCol{{1, 2, 3, 4, 5, 6}, {}, {7, 8, 9, 10}}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, verbosity); } TYPED_TEST(ConcatenateListElementsTypedTest, SimpleInputNestedManyLevelsNoNull) @@ -103,7 +103,7 @@ TYPED_TEST(ConcatenateListElementsTypedTest, SimpleInputNestedManyLevelsNoNull) auto const expected = ListsCol{ListsCol{{1, 2}, {3}, {4, 5, 6}, {}, {7, 8}, {9, 10}}, ListsCol{{1, 2}, {3}, {4, 5, 6}, {}, {7, 8}, {9, 10}}, ListsCol{{1, 2}, {3}, {4, 5, 6}, {}, {7, 8}, {9, 10}}}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, verbosity); } TEST_F(ConcatenateListElementsTest, SimpleInputStringsColumnNoNull) @@ -116,7 +116,7 @@ TEST_F(ConcatenateListElementsTest, SimpleInputStringsColumnNoNull) auto const expected = StrListsCol{StrListsCol{"Tomato", "Apple", "Orange"}, StrListsCol{"Banana", "Kiwi", "Cherry", "Lemon", "Peach"}, StrListsCol{"Coconut"}}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, verbosity); } TYPED_TEST(ConcatenateListElementsTypedTest, SimpleInputWithNulls) @@ -157,7 +157,7 @@ TYPED_TEST(ConcatenateListElementsTypedTest, SimpleInputWithNulls) nulls_at({3, 4, 5, 6, 7, 8, 9})}, ListsCol{} /*NULL*/}, null_at(6)}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, verbosity); } // Null lists result in null rows. @@ -174,7 +174,7 @@ TYPED_TEST(ConcatenateListElementsTypedTest, SimpleInputWithNulls) nulls_at({3, 4, 5, 6, 7, 8, 9})}, ListsCol{} /*NULL*/}, nulls_at({0, 2, 3, 6})}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, verbosity); } } @@ -206,7 +206,7 @@ TYPED_TEST(ConcatenateListElementsTypedTest, SimpleInputNestedManyLevelsWithNull ListsCol{ListsCol{{1, 2}, {3}, {4, 5, 6}, {7, 8}, {9, 10}}, ListsCol{{{1, 2}, {3}, {} /*NULL*/, {}, {7, 8}, {9, 10}}, null_at(2)}, ListsCol{{1, 2}, {3}, {4, 5, 6}, {}, ListsCol{{null, 8}, null_at(0)}, {9, 10}}}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, verbosity); } // Null lists result in null rows. @@ -218,7 +218,7 @@ TYPED_TEST(ConcatenateListElementsTypedTest, SimpleInputNestedManyLevelsWithNull ListsCol{{{1, 2}, {3}, {} /*NULL*/, {}, {7, 8}, {9, 10}}, null_at(2)}, ListsCol{{1, 2}, {3}, {4, 5, 6}, {}, ListsCol{{null, 8}, null_at(0)}, {9, 10}}}, null_at(0)}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, verbosity); } } @@ -243,7 +243,7 @@ TEST_F(ConcatenateListElementsTest, SimpleInputStringsColumnWithNulls) StrListsCol{{"Banana", "" /*NULL*/, "Kiwi", "Cherry", "" /*NULL*/, "Lemon", "Peach"}, nulls_at({1, 4})}, StrListsCol{"Coconut"}}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, verbosity); } // Null lists result in null rows. @@ -258,7 +258,7 @@ TEST_F(ConcatenateListElementsTest, SimpleInputStringsColumnWithNulls) nulls_at({1, 4})}, StrListsCol{} /*NULL*/}, null_at(2)}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, verbosity); } } TEST_F(ConcatenateListElementsTest, SimpleInputStringsColumnWithEmptyStringsAndNulls) @@ -280,7 +280,7 @@ TEST_F(ConcatenateListElementsTest, SimpleInputStringsColumnWithEmptyStringsAndN nulls_at({4, 5, 6})}, StrListsCol{{"Banana", "" /*NULL*/, "Kiwi", "Cherry", "" /*NULL*/, ""}, nulls_at({1, 4})}, StrListsCol{"Coconut"}}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, verbosity); } // Null lists result in null rows. @@ -293,7 +293,7 @@ TEST_F(ConcatenateListElementsTest, SimpleInputStringsColumnWithEmptyStringsAndN StrListsCol{{"Banana", "" /*NULL*/, "Kiwi", "Cherry", "" /*NULL*/, ""}, nulls_at({1, 4})}, StrListsCol{} /*NULL*/}, null_at(2)}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, verbosity); } } @@ -313,25 +313,25 @@ TYPED_TEST(ConcatenateListElementsTypedTest, SlicedColumnsInputNoNull) auto const results = cudf::lists::concatenate_list_elements(col); auto const expected = ListsCol{{1, 2, 3, 2, 3}, {3, 4, 5, 6, 5, 6, 7}, {7, 7, 7, 7, 8, 1, 0, 1}}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, verbosity); } { auto const col = cudf::slice(col_original, {1, 4})[0]; auto const results = cudf::lists::concatenate_list_elements(col); auto const expected = ListsCol{{3, 4, 5, 6, 5, 6, 7}, {7, 7, 7, 7, 8, 1, 0, 1}, {9, 10, 11}}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, verbosity); } { auto const col = cudf::slice(col_original, {2, 5})[0]; auto const results = cudf::lists::concatenate_list_elements(col); auto const expected = ListsCol{{7, 7, 7, 7, 8, 1, 0, 1}, {9, 10, 11}, {}}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, verbosity); } { auto const col = cudf::slice(col_original, {3, 6})[0]; auto const results = cudf::lists::concatenate_list_elements(col); auto const expected = ListsCol{{9, 10, 11}, {}, {12, 13, 14, 15, 16, 17}}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, verbosity); } } @@ -357,7 +357,7 @@ TYPED_TEST(ConcatenateListElementsTypedTest, SlicedColumnsInputWithNulls) ListsCol{ListsCol{{null, 2, 3, 2, 3}, null_at(0)}, ListsCol{{3, null, null, 6, 5, 6, null, 7, null}, nulls_at({1, 2, 6, 8})}, ListsCol{{7, 7, 7, 7, 8, null, 0, 1}, null_at(5)}}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, verbosity); } { auto const col = cudf::slice(col_original, {1, 4})[0]; @@ -366,21 +366,21 @@ TYPED_TEST(ConcatenateListElementsTypedTest, SlicedColumnsInputWithNulls) ListsCol{ListsCol{{3, null, null, 6, 5, 6, null, 7, null}, nulls_at({1, 2, 6, 8})}, ListsCol{{7, 7, 7, 7, 8, null, 0, 1}, null_at(5)}, ListsCol{9, 10, 11}}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, verbosity); } { auto const col = cudf::slice(col_original, {2, 5})[0]; auto const results = cudf::lists::concatenate_list_elements(col); auto const expected = ListsCol{ListsCol{{7, 7, 7, 7, 8, null, 0, 1}, null_at(5)}, ListsCol{9, 10, 11}, ListsCol{}}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, verbosity); } { auto const col = cudf::slice(col_original, {3, 6})[0]; auto const results = cudf::lists::concatenate_list_elements(col); auto const expected = ListsCol{ListsCol{9, 10, 11}, ListsCol{}, ListsCol{{12, null, 14, 15, 16, 17}, null_at(1)}}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, verbosity); } } @@ -429,7 +429,7 @@ TEST_F(ConcatenateListElementsTest, SlicedStringsColumnsInputWithNulls) "" /*NULL*/, "" /*NULL*/}, nulls_at({1, 4, 7, 8, 9})}}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, verbosity); } { auto const col = cudf::slice(col_original, {1, 3})[0]; @@ -453,7 +453,7 @@ TEST_F(ConcatenateListElementsTest, SlicedStringsColumnsInputWithNulls) "Lemon", "Peach"}, nulls_at({2, 3, 4})}}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, verbosity); } { auto const col = cudf::slice(col_original, {2, 4})[0]; @@ -473,7 +473,7 @@ TEST_F(ConcatenateListElementsTest, SlicedStringsColumnsInputWithNulls) "Lemon", "Peach"}, nulls_at({1, 2, 3})}}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, verbosity); } { auto const col = cudf::slice(col_original, {2, 4})[0]; @@ -489,6 +489,6 @@ TEST_F(ConcatenateListElementsTest, SlicedStringsColumnsInputWithNulls) nulls_at({2, 3, 4})}, StrListsCol{} /*NULL*/}, null_at(1)}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, verbosity); } } diff --git a/cpp/tests/lists/combine/concatenate_rows_tests.cpp b/cpp/tests/lists/combine/concatenate_rows_tests.cpp index cbd02a81f69..8aae523d12b 100644 --- a/cpp/tests/lists/combine/concatenate_rows_tests.cpp +++ b/cpp/tests/lists/combine/concatenate_rows_tests.cpp @@ -29,7 +29,7 @@ using IntListsCol = cudf::test::lists_column_wrapper; using IntCol = cudf::test::fixed_width_column_wrapper; using TView = cudf::table_view; -constexpr bool print_all{false}; // For debugging +constexpr cudf::test::debug_output_level verbosity{cudf::test::debug_output_level::FIRST_ERROR}; constexpr int32_t null{0}; } // namespace @@ -80,7 +80,7 @@ TYPED_TEST(ListConcatenateRowsTypedTest, ConcatenateEmptyColumns) auto const col = ListsCol{}.release(); auto const results = cudf::lists::concatenate_rows(TView{{col->view(), col->view()}}); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*col, *results, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*col, *results, verbosity); } TYPED_TEST(ListConcatenateRowsTypedTest, ConcatenateOneColumnNotNull) @@ -89,7 +89,7 @@ TYPED_TEST(ListConcatenateRowsTypedTest, ConcatenateOneColumnNotNull) auto const col = ListsCol{{1, 2}, {3, 4}, {5, 6}}.release(); auto const results = cudf::lists::concatenate_rows(TView{{col->view()}}); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*col, *results, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*col, *results, verbosity); } TYPED_TEST(ListConcatenateRowsTypedTest, ConcatenateOneColumnWithNulls) @@ -103,7 +103,7 @@ TYPED_TEST(ListConcatenateRowsTypedTest, ConcatenateOneColumnWithNulls) null_at(1)} .release(); auto const results = cudf::lists::concatenate_rows(TView{{col->view()}}); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*col, *results, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*col, *results, verbosity); } TYPED_TEST(ListConcatenateRowsTypedTest, SimpleInputNoNull) @@ -114,7 +114,7 @@ TYPED_TEST(ListConcatenateRowsTypedTest, SimpleInputNoNull) auto const col2 = ListsCol{{7, 8}, {9, 10}, {11, 12}}.release(); auto const expected = ListsCol{{1, 2, 7, 8}, {3, 4, 9, 10}, {5, 6, 11, 12}}.release(); auto const results = cudf::lists::concatenate_rows(TView{{col1->view(), col2->view()}}); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*expected, *results, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*expected, *results, verbosity); } TYPED_TEST(ListConcatenateRowsTypedTest, SimpleInputWithNullableChild) @@ -126,7 +126,7 @@ TYPED_TEST(ListConcatenateRowsTypedTest, SimpleInputWithNullableChild) auto const expected = ListsCol{{1, 2, 7, 8}, ListsCol{{null, 9, 10}, null_at(0)}, {5, 6, 11, 12}}.release(); auto const results = cudf::lists::concatenate_rows(TView{{col1->view(), col2->view()}}); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*expected, *results, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*expected, *results, verbosity); } TEST_F(ListConcatenateRowsTest, SimpleInputStringsColumnsNoNull) @@ -144,7 +144,7 @@ TEST_F(ListConcatenateRowsTest, SimpleInputStringsColumnsNoNull) StrListsCol{ "Coconut"}}.release(); auto const results = cudf::lists::concatenate_rows(TView{{col1->view(), col2->view()}}); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*expected, *results, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*expected, *results, verbosity); } TEST_F(ListConcatenateRowsTest, SimpleInputStringsColumnsWithNullableChild) @@ -164,7 +164,7 @@ TEST_F(ListConcatenateRowsTest, SimpleInputStringsColumnsWithNullableChild) StrListsCol{ "Coconut"}}.release(); auto const results = cudf::lists::concatenate_rows(TView{{col1->view(), col2->view()}}); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*expected, *results, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*expected, *results, verbosity); } TYPED_TEST(ListConcatenateRowsTypedTest, SimpleInputWithNulls) @@ -214,7 +214,7 @@ TYPED_TEST(ListConcatenateRowsTypedTest, SimpleInputWithNulls) ListsCol{} /*NULL*/}, null_at(6)} .release(); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*expected, *results, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*expected, *results, verbosity); } // Null list rows result in null list rows @@ -233,7 +233,7 @@ TYPED_TEST(ListConcatenateRowsTypedTest, SimpleInputWithNulls) ListsCol{} /*NULL*/}, nulls_at({0, 2, 3, 6})} .release(); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*expected, *results, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*expected, *results, verbosity); } } @@ -263,7 +263,7 @@ TEST_F(ListConcatenateRowsTest, SimpleInputStringsColumnsWithNulls) nulls_at({1, 4})}, StrListsCol{ "Coconut"}}.release(); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*expected, *results, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*expected, *results, verbosity); } // Null list rows result in null list rows @@ -281,7 +281,7 @@ TEST_F(ListConcatenateRowsTest, SimpleInputStringsColumnsWithNulls) StrListsCol{""} /*NULL*/}, null_at(2)} .release(); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*expected, *results, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*expected, *results, verbosity); } } @@ -306,7 +306,7 @@ TEST_F(ListConcatenateRowsTest, SimpleInputStringsColumnsWithEmptyLists) nulls_at({0, 2})}, StrListsCol{"One", "Two"}}.release(); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*expected, *results, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*expected, *results, verbosity); } // Null list rows result in null list rows @@ -320,7 +320,7 @@ TEST_F(ListConcatenateRowsTest, SimpleInputStringsColumnsWithEmptyLists) StrListsCol{""} /*NULL*/}, null_at(1)} .release(); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*expected, *results, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*expected, *results, verbosity); } } @@ -338,7 +338,7 @@ TYPED_TEST(ListConcatenateRowsTypedTest, SlicedColumnsInputNoNull) {2, 3, 3, 4, 5, 6, 5, 6}, {3, 4, 5, 6, 5, 6, 7}}.release(); auto const results = cudf::lists::concatenate_rows(TView{{col1, col2, col3, col4}}); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*expected, *results, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*expected, *results, verbosity); } TYPED_TEST(ListConcatenateRowsTypedTest, SlicedColumnsInputWithNulls) @@ -365,7 +365,7 @@ TYPED_TEST(ListConcatenateRowsTypedTest, SlicedColumnsInputWithNulls) ListsCol{{3, null, 5, 6, 7, 8, 9, 10}, null_at(1)}}.release(); auto const results = cudf::lists::concatenate_rows(TView{{col1, col2, col3, col4, col5}}); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*expected, *results, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*expected, *results, verbosity); } TEST_F(ListConcatenateRowsTest, SlicedStringsColumnsInputWithNulls) @@ -427,7 +427,7 @@ TEST_F(ListConcatenateRowsTest, SlicedStringsColumnsInputWithNulls) }, nulls_at({2, 3, 4})}} .release(); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*expected, *results, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*expected, *results, verbosity); } { @@ -463,6 +463,6 @@ TEST_F(ListConcatenateRowsTest, SlicedStringsColumnsInputWithNulls) StrListsCol{} /*NULL*/}, null_at(2)} .release(); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*expected, *results, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*expected, *results, verbosity); } } diff --git a/cpp/tests/reshape/interleave_columns_tests.cpp b/cpp/tests/reshape/interleave_columns_tests.cpp index 4f7fab09443..2281d8526fe 100644 --- a/cpp/tests/reshape/interleave_columns_tests.cpp +++ b/cpp/tests/reshape/interleave_columns_tests.cpp @@ -24,6 +24,8 @@ using namespace cudf::test::iterators; +constexpr cudf::test::debug_output_level verbosity{cudf::test::debug_output_level::ALL_ERRORS}; + template struct InterleaveColumnsTest : public cudf::test::BaseFixture { }; @@ -189,7 +191,7 @@ TEST_F(InterleaveStringsColumnsTest, SingleColumn) auto col0 = cudf::test::strings_column_wrapper({"", "", "", ""}, {false, true, true, false}); auto results = cudf::interleave_columns(cudf::table_view{{col0}}); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, col0, true); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, col0, verbosity); } TEST_F(InterleaveStringsColumnsTest, MultiColumnNullAndEmpty) @@ -201,7 +203,7 @@ TEST_F(InterleaveStringsColumnsTest, MultiColumnNullAndEmpty) {"", "", "", "", "", "", "", ""}, {false, true, true, false, true, true, false, false}); auto results = cudf::interleave_columns(cudf::table_view{{col0, col1}}); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, exp_results, true); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, exp_results, verbosity); } TEST_F(InterleaveStringsColumnsTest, MultiColumnEmptyNonNullable) @@ -212,7 +214,7 @@ TEST_F(InterleaveStringsColumnsTest, MultiColumnEmptyNonNullable) auto exp_results = cudf::test::strings_column_wrapper({"", "", "", "", "", "", "", ""}); auto results = cudf::interleave_columns(cudf::table_view{{col0, col1}}); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, exp_results, true); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, exp_results, verbosity); } TEST_F(InterleaveStringsColumnsTest, MultiColumnStringMix) @@ -262,7 +264,7 @@ TEST_F(InterleaveStringsColumnsTest, MultiColumnStringMix) false}); auto results = cudf::interleave_columns(cudf::table_view{{col0, col1, col2}}); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, exp_results, true); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, exp_results, verbosity); } TEST_F(InterleaveStringsColumnsTest, MultiColumnStringMixNonNullable) @@ -291,7 +293,7 @@ TEST_F(InterleaveStringsColumnsTest, MultiColumnStringMixNonNullable) "c25"}); auto results = cudf::interleave_columns(cudf::table_view{{col0, col1, col2}}); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, exp_results, true); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, exp_results, verbosity); } TEST_F(InterleaveStringsColumnsTest, MultiColumnStringMixNullableMix) @@ -339,7 +341,7 @@ TEST_F(InterleaveStringsColumnsTest, MultiColumnStringMixNullableMix) true}); auto results = cudf::interleave_columns(cudf::table_view{{col0, col1, col2}}); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, exp_results, true); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, exp_results, verbosity); } template @@ -376,7 +378,6 @@ using IntListsCol = cudf::test::lists_column_wrapper; using IntCol = cudf::test::fixed_width_column_wrapper; using TView = cudf::table_view; -constexpr bool print_all{false}; // For debugging constexpr int32_t null{0}; } // namespace @@ -421,7 +422,7 @@ TYPED_TEST(ListsColumnsInterleaveTypedTest, InterleaveEmptyColumns) auto const col = ListsCol{}.release(); auto const results = cudf::interleave_columns(TView{{col->view(), col->view()}}); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*col, *results, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*col, *results, verbosity); } TYPED_TEST(ListsColumnsInterleaveTypedTest, InterleaveOneColumnNotNull) @@ -430,7 +431,7 @@ TYPED_TEST(ListsColumnsInterleaveTypedTest, InterleaveOneColumnNotNull) auto const col = ListsCol{{1, 2}, {3, 4}, {5, 6}}.release(); auto const results = cudf::interleave_columns(TView{{col->view()}}); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*col, *results, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*col, *results, verbosity); } TYPED_TEST(ListsColumnsInterleaveTypedTest, InterleaveOneColumnWithNulls) @@ -444,7 +445,7 @@ TYPED_TEST(ListsColumnsInterleaveTypedTest, InterleaveOneColumnWithNulls) null_at(1)} .release(); auto const results = cudf::interleave_columns(TView{{col->view()}}); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*col, *results, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*col, *results, verbosity); } TYPED_TEST(ListsColumnsInterleaveTypedTest, SimpleInputNoNull) @@ -455,7 +456,7 @@ TYPED_TEST(ListsColumnsInterleaveTypedTest, SimpleInputNoNull) auto const col2 = ListsCol{{7, 8}, {9, 10}, {11, 12}}.release(); auto const expected = ListsCol{{1, 2}, {7, 8}, {3, 4}, {9, 10}, {5, 6}, {11, 12}}.release(); auto const results = cudf::interleave_columns(TView{{col1->view(), col2->view()}}); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*expected, *results, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*expected, *results, verbosity); } TEST_F(ListsColumnsInterleaveTest, SimpleInputStringsColumnsNoNull) @@ -475,7 +476,7 @@ TEST_F(ListsColumnsInterleaveTest, SimpleInputStringsColumnsNoNull) StrListsCol{"Coconut"}, StrListsCol{}}.release(); auto const results = cudf::interleave_columns(TView{{col1->view(), col2->view()}}); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*expected, *results, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*expected, *results, verbosity); } TYPED_TEST(ListsColumnsInterleaveTypedTest, SimpleInputWithNulls) @@ -527,7 +528,7 @@ TYPED_TEST(ListsColumnsInterleaveTypedTest, SimpleInputWithNulls) nulls_at({2, 7, 9})} .release(); auto const results = cudf::interleave_columns(TView{{col1->view(), col2->view(), col3->view()}}); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*expected, *results, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*expected, *results, verbosity); } TYPED_TEST(ListsColumnsInterleaveTypedTest, SimpleInputWithNullableChild) @@ -540,7 +541,7 @@ TYPED_TEST(ListsColumnsInterleaveTypedTest, SimpleInputWithNullableChild) auto const expected = ListsCol{{1, 2}, {5, 6}, {9, 10}, {3, 4}, {7, 8}, ListsCol{{null, 12}, null_at(0)}}.release(); auto const results = cudf::interleave_columns(TView{{col1->view(), col2->view(), col3->view()}}); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*expected, *results, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*expected, *results, verbosity); } TEST_F(ListsColumnsInterleaveTest, SimpleInputStringsColumnsWithNulls) @@ -570,7 +571,7 @@ TEST_F(ListsColumnsInterleaveTest, SimpleInputStringsColumnsWithNulls) null_at(5)} .release(); auto const results = cudf::interleave_columns(TView{{col1->view(), col2->view()}}); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*expected, *results, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*expected, *results, verbosity); } TEST_F(ListsColumnsInterleaveTest, SimpleInputStringsColumnsWithNullableChild) @@ -597,7 +598,7 @@ TEST_F(ListsColumnsInterleaveTest, SimpleInputStringsColumnsWithNullableChild) {"Deer" /*NULL*/, "Snake" /*NULL*/, "Horse" /*NULL*/}, all_nulls()}}.release(); auto const results = cudf::interleave_columns(TView{{col1->view(), col2->view()}}); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*expected, *results, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*expected, *results, verbosity); } TYPED_TEST(ListsColumnsInterleaveTypedTest, SlicedColumnsInputNoNull) @@ -623,7 +624,7 @@ TYPED_TEST(ListsColumnsInterleaveTypedTest, SlicedColumnsInputNoNull) ListsCol{}, ListsCol{7}}.release(); auto const results = cudf::interleave_columns(TView{{col1, col2, col3, col4}}); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*expected, *results, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*expected, *results, verbosity); } TYPED_TEST(ListsColumnsInterleaveTypedTest, SlicedColumnsInputWithNulls) @@ -662,7 +663,7 @@ TYPED_TEST(ListsColumnsInterleaveTypedTest, SlicedColumnsInputWithNulls) nulls_at({1, 3, 4, 5, 7, 8, 11, 12})} .release(); auto const results = cudf::interleave_columns(TView{{col1, col2, col3, col4, col5}}); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*expected, *results, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*expected, *results, verbosity); } TYPED_TEST(ListsColumnsInterleaveTypedTest, SlicedColumnsInputNullableChild) @@ -689,7 +690,7 @@ TYPED_TEST(ListsColumnsInterleaveTypedTest, SlicedColumnsInputNullableChild) ListsCol{}, ListsCol{7}}.release(); auto const results = cudf::interleave_columns(TView{{col1, col2, col3, col4}}); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*expected, *results, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*expected, *results, verbosity); } TEST_F(ListsColumnsInterleaveTest, SlicedStringsColumnsInputWithNulls) @@ -727,7 +728,7 @@ TEST_F(ListsColumnsInterleaveTest, SlicedStringsColumnsInputWithNulls) null_at(11)} .release(); auto const results = cudf::interleave_columns(TView{{col1, col2, col3, col4}}); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*expected, *results, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*expected, *results, verbosity); } CUDF_TEST_PROGRAM_MAIN() diff --git a/cpp/tests/search/search_struct_test.cpp b/cpp/tests/search/search_struct_test.cpp index f760aeeb16b..8738a9195a5 100644 --- a/cpp/tests/search/search_struct_test.cpp +++ b/cpp/tests/search/search_struct_test.cpp @@ -31,9 +31,9 @@ using int32s_col = cudf::test::fixed_width_column_wrapper; using structs_col = cudf::test::structs_column_wrapper; using strings_col = cudf::test::strings_column_wrapper; -constexpr bool print_all{false}; // For debugging only -constexpr int32_t null{0}; // Mark for null child elements -constexpr int32_t XXX{0}; // Mark for null struct elements +constexpr cudf::test::debug_output_level verbosity{cudf::test::debug_output_level::FIRST_ERROR}; +constexpr int32_t null{0}; // Mark for null child elements +constexpr int32_t XXX{0}; // Mark for null struct elements template struct TypedStructSearchTest : public cudf::test::BaseFixture { @@ -84,8 +84,8 @@ TYPED_TEST(TypedStructSearchTest, EmptyInputTest) auto const results = search_bounds(structs_t, structs_values); auto const expected = int32s_col{}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, results.first->view(), print_all); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, results.second->view(), print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, results.first->view(), verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, results.second->view(), verbosity); } TYPED_TEST(TypedStructSearchTest, TrivialInputTests) @@ -103,13 +103,13 @@ TYPED_TEST(TypedStructSearchTest, TrivialInputTests) auto const results1 = search_bounds(structs_t, structs_values1); auto const expected1 = int32s_col{0, 0, 0, 0, 0}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected1, results1.first->view(), print_all); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected1, results1.second->view(), print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected1, results1.first->view(), verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected1, results1.second->view(), verbosity); auto const results2 = search_bounds(structs_t, structs_values2); auto const expected2 = int32s_col{5, 5, 5, 5, 5}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected2, results2.first->view(), print_all); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected2, results2.second->view(), print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected2, results2.first->view(), verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected2, results2.second->view(), verbosity); } TYPED_TEST(TypedStructSearchTest, SlicedColumnInputTests) @@ -126,22 +126,22 @@ TYPED_TEST(TypedStructSearchTest, SlicedColumnInputTests) auto results = search_bounds(structs_t, structs_values); auto expected_lower_bound = int32s_col{0, 1, 2, 6, 8, 10}; auto expected_upper_bound = int32s_col{1, 2, 6, 8, 10, 10}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_lower_bound, results.first->view(), print_all); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_upper_bound, results.second->view(), print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_lower_bound, results.first->view(), verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_upper_bound, results.second->view(), verbosity); structs_t = cudf::slice(structs_t_original->view(), {0, 5})[0]; results = search_bounds(structs_t, structs_values); expected_lower_bound = int32s_col{0, 1, 2, 5, 5, 5}; expected_upper_bound = int32s_col{1, 2, 5, 5, 5, 5}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_lower_bound, results.first->view(), print_all); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_upper_bound, results.second->view(), print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_lower_bound, results.first->view(), verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_upper_bound, results.second->view(), verbosity); structs_t = cudf::slice(structs_t_original->view(), {5, 10})[0]; results = search_bounds(structs_t, structs_values); expected_lower_bound = int32s_col{0, 0, 0, 1, 3, 5}; expected_upper_bound = int32s_col{0, 0, 1, 3, 5, 5}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_lower_bound, results.first->view(), print_all); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_upper_bound, results.second->view(), print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_lower_bound, results.first->view(), verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_upper_bound, results.second->view(), verbosity); } TYPED_TEST(TypedStructSearchTest, SimpleInputWithNullsTests) @@ -159,8 +159,8 @@ TYPED_TEST(TypedStructSearchTest, SimpleInputWithNullsTests) search_bounds(structs_t, structs_values, {cudf::order::ASCENDING}, {cudf::null_order::BEFORE}); auto expected_lower_bound = int32s_col{3, 1, 11, 0, 4, 11}; auto expected_upper_bound = int32s_col{4, 2, 11, 1, 8, 11}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_lower_bound, results.first->view(), print_all); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_upper_bound, results.second->view(), print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_lower_bound, results.first->view(), verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_upper_bound, results.second->view(), verbosity); // Sorted asc, nulls last child_col_t = col_wrapper{{0, 1, 2, 2, 2, 2, 3, 3, 4, null, XXX}, null_at(9)}; @@ -169,8 +169,8 @@ TYPED_TEST(TypedStructSearchTest, SimpleInputWithNullsTests) search_bounds(structs_t, structs_values, {cudf::order::ASCENDING}, {cudf::null_order::AFTER}); expected_lower_bound = int32s_col{1, 9, 9, 10, 2, 9}; expected_upper_bound = int32s_col{2, 10, 9, 11, 6, 9}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_lower_bound, results.first->view(), print_all); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_upper_bound, results.second->view(), print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_lower_bound, results.first->view(), verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_upper_bound, results.second->view(), verbosity); // Sorted dsc, nulls first child_col_t = col_wrapper{{XXX, null, 4, 3, 3, 2, 2, 2, 2, 1, 0}, null_at(1)}; @@ -179,8 +179,8 @@ TYPED_TEST(TypedStructSearchTest, SimpleInputWithNullsTests) search_bounds(structs_t, structs_values, {cudf::order::DESCENDING}, {cudf::null_order::BEFORE}); expected_lower_bound = int32s_col{9, 11, 0, 11, 5, 0}; expected_upper_bound = int32s_col{10, 11, 0, 11, 9, 0}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_lower_bound, results.first->view(), print_all); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_upper_bound, results.second->view(), print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_lower_bound, results.first->view(), verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_upper_bound, results.second->view(), verbosity); // Sorted dsc, nulls last child_col_t = col_wrapper{{4, 3, 3, 2, 2, 2, 2, 1, 0, null, XXX}, null_at(9)}; @@ -189,8 +189,8 @@ TYPED_TEST(TypedStructSearchTest, SimpleInputWithNullsTests) search_bounds(structs_t, structs_values, {cudf::order::DESCENDING}, {cudf::null_order::AFTER}); expected_lower_bound = int32s_col{7, 0, 0, 0, 3, 0}; expected_upper_bound = int32s_col{8, 0, 0, 0, 7, 0}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_lower_bound, results.first->view(), print_all); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_upper_bound, results.second->view(), print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_lower_bound, results.first->view(), verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_upper_bound, results.second->view(), verbosity); } TYPED_TEST(TypedStructSearchTest, SimpleInputWithValuesHavingNullsTests) @@ -208,16 +208,16 @@ TYPED_TEST(TypedStructSearchTest, SimpleInputWithValuesHavingNullsTests) search_bounds(structs_t, structs_values, {cudf::order::ASCENDING}, {cudf::null_order::BEFORE}); auto expected_lower_bound = int32s_col{3, 0, 11, 0, 4, 11}; auto expected_upper_bound = int32s_col{4, 0, 11, 0, 8, 11}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_lower_bound, results.first->view(), print_all); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_upper_bound, results.second->view(), print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_lower_bound, results.first->view(), verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_upper_bound, results.second->view(), verbosity); // Sorted asc, search nulls last results = search_bounds(structs_t, structs_values, {cudf::order::ASCENDING}, {cudf::null_order::AFTER}); expected_lower_bound = int32s_col{3, 11, 11, 11, 4, 11}; expected_upper_bound = int32s_col{4, 11, 11, 11, 8, 11}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_lower_bound, results.first->view(), print_all); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_upper_bound, results.second->view(), print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_lower_bound, results.first->view(), verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_upper_bound, results.second->view(), verbosity); // Sorted dsc, search nulls first child_col_t = col_wrapper{4, 3, 3, 2, 2, 2, 2, 1, 0, 0, 0}; @@ -226,16 +226,16 @@ TYPED_TEST(TypedStructSearchTest, SimpleInputWithValuesHavingNullsTests) search_bounds(structs_t, structs_values, {cudf::order::DESCENDING}, {cudf::null_order::BEFORE}); expected_lower_bound = int32s_col{7, 11, 0, 11, 3, 0}; expected_upper_bound = int32s_col{8, 11, 0, 11, 7, 0}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_lower_bound, results.first->view(), print_all); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_upper_bound, results.second->view(), print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_lower_bound, results.first->view(), verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_upper_bound, results.second->view(), verbosity); // Sorted dsc, search nulls last results = search_bounds(structs_t, structs_values, {cudf::order::DESCENDING}, {cudf::null_order::AFTER}); expected_lower_bound = int32s_col{7, 0, 0, 0, 3, 0}; expected_upper_bound = int32s_col{8, 0, 0, 0, 7, 0}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_lower_bound, results.first->view(), print_all); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_upper_bound, results.second->view(), print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_lower_bound, results.first->view(), verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_upper_bound, results.second->view(), verbosity); } TYPED_TEST(TypedStructSearchTest, SimpleInputWithTargetHavingNullsTests) @@ -253,8 +253,8 @@ TYPED_TEST(TypedStructSearchTest, SimpleInputWithTargetHavingNullsTests) search_bounds(structs_t, structs_values, {cudf::order::ASCENDING}, {cudf::null_order::BEFORE}); auto expected_lower_bound = int32s_col{3, 2, 11, 2, 4, 11}; auto expected_upper_bound = int32s_col{4, 3, 11, 3, 8, 11}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_lower_bound, results.first->view(), print_all); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_upper_bound, results.second->view(), print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_lower_bound, results.first->view(), verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_upper_bound, results.second->view(), verbosity); // Sorted asc, nulls last child_col_t = col_wrapper{{0, 1, 2, 2, 2, 2, 3, 3, 4, null, XXX}, null_at(9)}; @@ -263,8 +263,8 @@ TYPED_TEST(TypedStructSearchTest, SimpleInputWithTargetHavingNullsTests) search_bounds(structs_t, structs_values, {cudf::order::ASCENDING}, {cudf::null_order::AFTER}); expected_lower_bound = int32s_col{1, 0, 9, 0, 2, 9}; expected_upper_bound = int32s_col{2, 1, 9, 1, 6, 9}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_lower_bound, results.first->view(), print_all); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_upper_bound, results.second->view(), print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_lower_bound, results.first->view(), verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_upper_bound, results.second->view(), verbosity); // Sorted dsc, nulls first child_col_t = col_wrapper{{XXX, null, 4, 3, 3, 2, 2, 2, 2, 1, 0}, null_at(1)}; @@ -273,8 +273,8 @@ TYPED_TEST(TypedStructSearchTest, SimpleInputWithTargetHavingNullsTests) search_bounds(structs_t, structs_values, {cudf::order::DESCENDING}, {cudf::null_order::BEFORE}); expected_lower_bound = int32s_col{9, 10, 0, 10, 5, 0}; expected_upper_bound = int32s_col{10, 11, 0, 11, 9, 0}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_lower_bound, results.first->view(), print_all); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_upper_bound, results.second->view(), print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_lower_bound, results.first->view(), verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_upper_bound, results.second->view(), verbosity); // Sorted dsc, nulls last child_col_t = col_wrapper{{4, 3, 3, 2, 2, 2, 2, 1, 0, null, XXX}, null_at(9)}; @@ -283,8 +283,8 @@ TYPED_TEST(TypedStructSearchTest, SimpleInputWithTargetHavingNullsTests) search_bounds(structs_t, structs_values, {cudf::order::DESCENDING}, {cudf::null_order::AFTER}); expected_lower_bound = int32s_col{7, 8, 0, 8, 3, 0}; expected_upper_bound = int32s_col{8, 11, 0, 11, 7, 0}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_lower_bound, results.first->view(), print_all); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_upper_bound, results.second->view(), print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_lower_bound, results.first->view(), verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_upper_bound, results.second->view(), verbosity); } TYPED_TEST(TypedStructSearchTest, OneColumnHasNullMaskButNoNullElementTest) @@ -307,10 +307,10 @@ TYPED_TEST(TypedStructSearchTest, OneColumnHasNullMaskButNoNullElementTest) auto const results2 = search_bounds(structs_col1, structs_col3); auto const expected_lower_bound = int32s_col{0, 1, 1}; auto const expected_upper_bound = int32s_col{0, 1, 1}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_lower_bound, results1.first->view(), print_all); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_lower_bound, results2.first->view(), print_all); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_upper_bound, results1.second->view(), print_all); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_upper_bound, results2.second->view(), print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_lower_bound, results1.first->view(), verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_lower_bound, results2.first->view(), verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_upper_bound, results1.second->view(), verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_upper_bound, results2.second->view(), verbosity); } // Search struct elements of structs_col1 in the columns structs_col2 and structs_col3 @@ -319,10 +319,10 @@ TYPED_TEST(TypedStructSearchTest, OneColumnHasNullMaskButNoNullElementTest) auto const results2 = search_bounds(structs_col3, structs_col1); auto const expected_lower_bound = int32s_col{1, 3, 3}; auto const expected_upper_bound = int32s_col{1, 3, 3}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_lower_bound, results1.first->view(), print_all); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_lower_bound, results2.first->view(), print_all); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_upper_bound, results1.second->view(), print_all); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_upper_bound, results2.second->view(), print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_lower_bound, results1.first->view(), verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_lower_bound, results2.first->view(), verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_upper_bound, results1.second->view(), verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_upper_bound, results2.second->view(), verbosity); } } @@ -350,6 +350,6 @@ TYPED_TEST(TypedStructSearchTest, ComplexStructTest) search_bounds(structs_t, structs_values, {cudf::order::ASCENDING}, {cudf::null_order::AFTER}); auto const expected_lower_bound = int32s_col{0, 4, 3, 5, 0}; auto const expected_upper_bound = int32s_col{0, 5, 3, 6, 0}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_lower_bound, results.first->view(), print_all); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_upper_bound, results.second->view(), print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_lower_bound, results.first->view(), verbosity); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_upper_bound, results.second->view(), verbosity); } diff --git a/cpp/tests/strings/combine/concatenate_tests.cpp b/cpp/tests/strings/combine/concatenate_tests.cpp index d91f669e42d..be1dacd0b5d 100644 --- a/cpp/tests/strings/combine/concatenate_tests.cpp +++ b/cpp/tests/strings/combine/concatenate_tests.cpp @@ -28,6 +28,8 @@ #include +constexpr cudf::test::debug_output_level verbosity{cudf::test::debug_output_level::ALL_ERRORS}; + struct StringsCombineTest : public cudf::test::BaseFixture { }; @@ -217,7 +219,7 @@ TEST_F(StringsConcatenateWithColSeparatorTest, SingleColumnEmptyAndNullStringsNo cudf::test::strings_column_wrapper({"", "", "", ""}, {false, true, false, false}); auto results = cudf::strings::concatenate(cudf::table_view{{col0}}, cudf::strings_column_view(sep_col)); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, exp_results, true); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, exp_results, verbosity); } TEST_F(StringsConcatenateWithColSeparatorTest, SingleColumnEmptyAndNullStringsSeparatorReplacement) @@ -231,7 +233,7 @@ TEST_F(StringsConcatenateWithColSeparatorTest, SingleColumnEmptyAndNullStringsSe auto results = cudf::strings::concatenate( cudf::table_view{{col0}}, cudf::strings_column_view(sep_col), sep_rep); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, exp_results, true); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, exp_results, verbosity); } TEST_F(StringsConcatenateWithColSeparatorTest, SingleColumnEmptyAndNullStringsColumnReplacement) @@ -247,7 +249,7 @@ TEST_F(StringsConcatenateWithColSeparatorTest, SingleColumnEmptyAndNullStringsCo cudf::strings_column_view(sep_col), cudf::string_scalar("", false), col_rep); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, exp_results, true); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, exp_results, verbosity); } TEST_F(StringsConcatenateWithColSeparatorTest, @@ -262,7 +264,7 @@ TEST_F(StringsConcatenateWithColSeparatorTest, auto results = cudf::strings::concatenate( cudf::table_view{{col0}}, cudf::strings_column_view(sep_col), sep_rep, col_rep); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*results, exp_results, true); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*results, exp_results, verbosity); } TEST_F(StringsConcatenateWithColSeparatorTest, SingleColumnStringMixNoReplacements) @@ -280,7 +282,7 @@ TEST_F(StringsConcatenateWithColSeparatorTest, SingleColumnStringMixNoReplacemen auto results = cudf::strings::concatenate(cudf::table_view{{col0}}, cudf::strings_column_view(sep_col)); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, exp_results, true); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, exp_results, verbosity); } TEST_F(StringsConcatenateWithColSeparatorTest, SingleColumnStringMixSeparatorReplacement) @@ -299,7 +301,7 @@ TEST_F(StringsConcatenateWithColSeparatorTest, SingleColumnStringMixSeparatorRep auto results = cudf::strings::concatenate( cudf::table_view{{col0}}, cudf::strings_column_view(sep_col), sep_rep); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, exp_results, true); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, exp_results, verbosity); } TEST_F(StringsConcatenateWithColSeparatorTest, SingleColumnStringMixColumnReplacement) @@ -320,7 +322,7 @@ TEST_F(StringsConcatenateWithColSeparatorTest, SingleColumnStringMixColumnReplac cudf::strings_column_view(sep_col), cudf::string_scalar("", false), col_rep); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, exp_results, true); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, exp_results, verbosity); } TEST_F(StringsConcatenateWithColSeparatorTest, SingleColumnStringMixSeparatorAndColumnReplacement) @@ -340,7 +342,7 @@ TEST_F(StringsConcatenateWithColSeparatorTest, SingleColumnStringMixSeparatorAnd auto results = cudf::strings::concatenate( cudf::table_view{{col0}}, cudf::strings_column_view(sep_col), sep_rep, col_rep); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*results, exp_results, true); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*results, exp_results, verbosity); } TEST_F(StringsConcatenateWithColSeparatorTest, MultiColumnEmptyAndNullStringsNoReplacements) @@ -356,7 +358,7 @@ TEST_F(StringsConcatenateWithColSeparatorTest, MultiColumnEmptyAndNullStringsNoR {"", "", "", "", "", "", "", ""}, {false, false, true, false, false, false, false, false}); auto results = cudf::strings::concatenate(cudf::table_view{{col0, col1}}, cudf::strings_column_view(sep_col)); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, exp_results1, true); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, exp_results1, verbosity); auto exp_results2 = cudf::test::strings_column_wrapper( {"", "", "", "", "", "", "", ""}, {true, false, true, false, true, false, true, false}); @@ -365,7 +367,7 @@ TEST_F(StringsConcatenateWithColSeparatorTest, MultiColumnEmptyAndNullStringsNoR cudf::string_scalar("", false), cudf::string_scalar(""), cudf::strings::separator_on_nulls::NO); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, exp_results2, true); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, exp_results2, verbosity); } TEST_F(StringsConcatenateWithColSeparatorTest, MultiColumnStringMixNoReplacements) @@ -386,7 +388,7 @@ TEST_F(StringsConcatenateWithColSeparatorTest, MultiColumnStringMixNoReplacement auto results = cudf::strings::concatenate(cudf::table_view{{col0, col1}}, cudf::strings_column_view(sep_col)); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, exp_results1, true); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, exp_results1, verbosity); auto exp_results2 = cudf::test::strings_column_wrapper( {"eeexyzfoo", "~~~", "", "éééf", "", "", "", "valid", "doo", "", "", ""}, @@ -396,7 +398,7 @@ TEST_F(StringsConcatenateWithColSeparatorTest, MultiColumnStringMixNoReplacement cudf::string_scalar("", false), cudf::string_scalar(""), cudf::strings::separator_on_nulls::NO); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, exp_results2, true); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, exp_results2, verbosity); } TEST_F(StringsConcatenateWithColSeparatorTest, MultiColumnStringMixSeparatorReplacement) @@ -418,7 +420,7 @@ TEST_F(StringsConcatenateWithColSeparatorTest, MultiColumnStringMixSeparatorRepl auto results = cudf::strings::concatenate( cudf::table_view{{col0, col1}}, cudf::strings_column_view(sep_col), sep_rep); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, exp_results1, true); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, exp_results1, verbosity); auto exp_results2 = cudf::test::strings_column_wrapper( {"eeexyzfoo", "~~~", "!!!!!!!éaff", "éééf", "éa", "", "éaff", "valid", "doo", "", "", ""}, @@ -429,7 +431,7 @@ TEST_F(StringsConcatenateWithColSeparatorTest, MultiColumnStringMixSeparatorRepl sep_rep, cudf::string_scalar(""), cudf::strings::separator_on_nulls::NO); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, exp_results2, true); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, exp_results2, verbosity); } TEST_F(StringsConcatenateWithColSeparatorTest, MultiColumnStringMixColumnReplacement) @@ -464,7 +466,7 @@ TEST_F(StringsConcatenateWithColSeparatorTest, MultiColumnStringMixColumnReplace cudf::strings_column_view(sep_col), cudf::string_scalar("", false), col_rep); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, exp_results, true); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, exp_results, verbosity); } TEST_F(StringsConcatenateWithColSeparatorTest, MultiColumnStringMixSeparatorAndColumnReplacement) @@ -498,7 +500,7 @@ TEST_F(StringsConcatenateWithColSeparatorTest, MultiColumnStringMixSeparatorAndC auto results = cudf::strings::concatenate( cudf::table_view{{col0, col1}}, cudf::strings_column_view(sep_col), sep_rep, col_rep); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*results, exp_results, true); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*results, exp_results, verbosity); } TEST_F(StringsConcatenateWithColSeparatorTest, MultiColumnNonNullableStrings) @@ -514,5 +516,5 @@ TEST_F(StringsConcatenateWithColSeparatorTest, MultiColumnNonNullableStrings) auto results = cudf::strings::concatenate(cudf::table_view{{col0, col1}}, cudf::strings_column_view(sep_col)); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*results, exp_results, true); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*results, exp_results, verbosity); } diff --git a/cpp/tests/strings/combine/join_list_elements_tests.cpp b/cpp/tests/strings/combine/join_list_elements_tests.cpp index b02891b7ffe..d4aafbf5f23 100644 --- a/cpp/tests/strings/combine/join_list_elements_tests.cpp +++ b/cpp/tests/strings/combine/join_list_elements_tests.cpp @@ -34,7 +34,7 @@ using STR_LISTS = cudf::test::lists_column_wrapper; using STR_COL = cudf::test::strings_column_wrapper; using INT_LISTS = cudf::test::lists_column_wrapper; -constexpr bool print_all{false}; +constexpr cudf::test::debug_output_level verbosity{cudf::test::debug_output_level::FIRST_ERROR}; } // namespace TEST_F(StringsListsConcatenateTest, InvalidInput) @@ -72,11 +72,11 @@ TEST_F(StringsListsConcatenateTest, EmptyInput) auto const string_lv = cudf::lists_column_view(string_lists->view()); auto const expected = STR_COL{}; auto results = cudf::strings::join_list_elements(string_lv); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected, verbosity); auto const separators = STR_COL{}.release(); results = cudf::strings::join_list_elements(string_lv, separators->view()); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected, verbosity); } TEST_F(StringsListsConcatenateTest, ZeroSizeStringsInput) @@ -90,11 +90,11 @@ TEST_F(StringsListsConcatenateTest, ZeroSizeStringsInput) auto const expected = STR_COL{"", "", "", ""}; auto results = cudf::strings::join_list_elements(string_lv); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected, verbosity); auto const separators = STR_COL{"", "", "", ""}.release(); results = cudf::strings::join_list_elements(string_lv, separators->view()); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected, verbosity); } // Empty list results in null @@ -106,7 +106,7 @@ TEST_F(StringsListsConcatenateTest, ZeroSizeStringsInput) cudf::string_scalar(""), cudf::strings::separator_on_nulls::NO, cudf::strings::output_if_empty_list::NULL_ELEMENT); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected, verbosity); auto const separators = STR_COL{"", "", "", ""}.release(); results = cudf::strings::join_list_elements(string_lv, @@ -115,7 +115,7 @@ TEST_F(StringsListsConcatenateTest, ZeroSizeStringsInput) cudf::string_scalar(""), cudf::strings::separator_on_nulls::NO, cudf::strings::output_if_empty_list::NULL_ELEMENT); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected, verbosity); } } @@ -132,11 +132,11 @@ TEST_F(StringsListsConcatenateTest, ColumnHasEmptyListAndNullListInput) auto const expected = STR_COL{{"abc-def-", "" /*NULL*/, "", "gh"}, null_at(1)}; auto results = cudf::strings::join_list_elements(string_lv, cudf::string_scalar("-")); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected, verbosity); auto const separators = STR_COL{"-", "", "", ""}.release(); results = cudf::strings::join_list_elements(string_lv, separators->view()); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected, verbosity); } // Empty list results in null @@ -148,7 +148,7 @@ TEST_F(StringsListsConcatenateTest, ColumnHasEmptyListAndNullListInput) cudf::string_scalar(""), cudf::strings::separator_on_nulls::NO, cudf::strings::output_if_empty_list::NULL_ELEMENT); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected, verbosity); auto const separators = STR_COL{"-", "", "", ""}.release(); results = cudf::strings::join_list_elements(string_lv, @@ -157,7 +157,7 @@ TEST_F(StringsListsConcatenateTest, ColumnHasEmptyListAndNullListInput) cudf::string_scalar(""), cudf::strings::separator_on_nulls::NO, cudf::strings::output_if_empty_list::NULL_ELEMENT); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected, verbosity); } } @@ -172,11 +172,11 @@ TEST_F(StringsListsConcatenateTest, AllNullsStringsInput) auto const expected = STR_COL{{"", "", ""}, all_nulls()}; auto results = cudf::strings::join_list_elements(string_lv); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected, verbosity); auto const separators = STR_COL{{"", "", ""}, all_nulls()}.release(); results = cudf::strings::join_list_elements(string_lv, separators->view()); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected, verbosity); } TEST_F(StringsListsConcatenateTest, ScalarSeparator) @@ -196,7 +196,7 @@ TEST_F(StringsListsConcatenateTest, ScalarSeparator) std::vector h_expected{nullptr, nullptr, nullptr, "zzz+++xxxxx", nullptr}; auto const expected = STR_COL{h_expected.begin(), h_expected.end(), nulls_from_nullptrs(h_expected)}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected, verbosity); } // With null replacement @@ -207,7 +207,7 @@ TEST_F(StringsListsConcatenateTest, ScalarSeparator) "a+++___+++ccc", nullptr, "___+++efgh+++ijk", "zzz+++xxxxx", "v+++___+++___+++w"}; auto const expected = STR_COL{h_expected.begin(), h_expected.end(), nulls_from_nullptrs(h_expected)}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected, verbosity); } // Turn off separator-on-nulls @@ -219,7 +219,7 @@ TEST_F(StringsListsConcatenateTest, ScalarSeparator) std::vector h_expected{"a+++ccc", nullptr, "efgh+++ijk", "zzz+++xxxxx", "v+++w"}; auto const expected = STR_COL{h_expected.begin(), h_expected.end(), nulls_from_nullptrs(h_expected)}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected, verbosity); } } @@ -258,7 +258,7 @@ TEST_F(StringsListsConcatenateTest, SlicedListsWithScalarSeparator) "aaaééébbbéééccc+++12345"}; auto const expected = STR_COL{h_expected.begin(), h_expected.end(), nulls_from_nullptrs(h_expected)}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected, verbosity); } // Sliced the entire lists column, with null replacement @@ -279,7 +279,7 @@ TEST_F(StringsListsConcatenateTest, SlicedListsWithScalarSeparator) "aaaééébbbéééccc+++12345"}; auto const expected = STR_COL{h_expected.begin(), h_expected.end(), nulls_from_nullptrs(h_expected)}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected, verbosity); } // Sliced the first half of the lists column, no null replacement @@ -289,7 +289,7 @@ TEST_F(StringsListsConcatenateTest, SlicedListsWithScalarSeparator) std::vector h_expected{nullptr, nullptr, nullptr, "zzz+++xxxxx"}; auto const expected = STR_COL{h_expected.begin(), h_expected.end(), nulls_from_nullptrs(h_expected)}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected, verbosity); } // Sliced the first half of the lists column, with null replacement @@ -301,7 +301,7 @@ TEST_F(StringsListsConcatenateTest, SlicedListsWithScalarSeparator) "a+++___+++ccc", nullptr, "___+++efgh+++ijk", "zzz+++xxxxx"}; auto const expected = STR_COL{h_expected.begin(), h_expected.end(), nulls_from_nullptrs(h_expected)}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected, verbosity); } // Sliced the second half of the lists column, no null replacement @@ -312,7 +312,7 @@ TEST_F(StringsListsConcatenateTest, SlicedListsWithScalarSeparator) nullptr, nullptr, "0a0b0c+++5x5y5z", nullptr, "ééé+++12345abcdef", "aaaééébbbéééccc+++12345"}; auto const expected = STR_COL{h_expected.begin(), h_expected.end(), nulls_from_nullptrs(h_expected)}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected, verbosity); } // Sliced the second half of the lists column, with null replacement @@ -328,7 +328,7 @@ TEST_F(StringsListsConcatenateTest, SlicedListsWithScalarSeparator) "aaaééébbbéééccc+++12345"}; auto const expected = STR_COL{h_expected.begin(), h_expected.end(), nulls_from_nullptrs(h_expected)}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected, verbosity); } // Sliced the middle part of the lists column, no null replacement @@ -339,7 +339,7 @@ TEST_F(StringsListsConcatenateTest, SlicedListsWithScalarSeparator) "zzz+++xxxxx", nullptr, nullptr, nullptr, "0a0b0c+++5x5y5z"}; auto const expected = STR_COL{h_expected.begin(), h_expected.end(), nulls_from_nullptrs(h_expected)}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected, verbosity); } // Sliced the middle part of the lists column, with null replacement @@ -354,7 +354,7 @@ TEST_F(StringsListsConcatenateTest, SlicedListsWithScalarSeparator) "0a0b0c+++5x5y5z"}; auto const expected = STR_COL{h_expected.begin(), h_expected.end(), nulls_from_nullptrs(h_expected)}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected, verbosity); } } @@ -381,7 +381,7 @@ TEST_F(StringsListsConcatenateTest, ColumnSeparators) std::vector h_expected{nullptr, nullptr, nullptr, nullptr, nullptr, "zzz^^^xxxxx"}; auto const expected = STR_COL{h_expected.begin(), h_expected.end(), nulls_from_nullptrs(h_expected)}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected, verbosity); } // With null replacement for separators @@ -392,7 +392,7 @@ TEST_F(StringsListsConcatenateTest, ColumnSeparators) nullptr, nullptr, "0a0b0c|||xyzééé", nullptr, nullptr, "zzz^^^xxxxx"}; auto const expected = STR_COL{h_expected.begin(), h_expected.end(), nulls_from_nullptrs(h_expected)}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected, verbosity); } // With null replacement for strings @@ -403,7 +403,7 @@ TEST_F(StringsListsConcatenateTest, ColumnSeparators) "a+++XXXXX+++ccc", nullptr, nullptr, nullptr, "XXXXX%%%ááá%%%ííí", "zzz^^^xxxxx"}; auto const expected = STR_COL{h_expected.begin(), h_expected.end(), nulls_from_nullptrs(h_expected)}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected, verbosity); } // With null replacement for both separators and strings @@ -418,7 +418,7 @@ TEST_F(StringsListsConcatenateTest, ColumnSeparators) "zzz^^^xxxxx"}; auto const expected = STR_COL{h_expected.begin(), h_expected.end(), nulls_from_nullptrs(h_expected)}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected, verbosity); } // Turn off separator-on-nulls @@ -432,7 +432,7 @@ TEST_F(StringsListsConcatenateTest, ColumnSeparators) "a+++ccc", nullptr, "0a0b0c+++xyzééé", "efgh+++ijk", "ááá%%%ííí", "zzz^^^xxxxx"}; auto const expected = STR_COL{h_expected.begin(), h_expected.end(), nulls_from_nullptrs(h_expected)}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected, verbosity); } } @@ -477,7 +477,7 @@ TEST_F(StringsListsConcatenateTest, SlicedListsWithColumnSeparators) "aaaééébbbéééccc=+=12345"}; auto const expected = STR_COL{h_expected.begin(), h_expected.end(), nulls_from_nullptrs(h_expected)}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected, verbosity); } // Sliced the entire lists column, with null replacements @@ -499,7 +499,7 @@ TEST_F(StringsListsConcatenateTest, SlicedListsWithColumnSeparators) "aaaééébbbéééccc=+=12345"}; auto const expected = STR_COL{h_expected.begin(), h_expected.end(), nulls_from_nullptrs(h_expected)}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected, verbosity); } // Sliced the first half of the lists column, no null replacement @@ -510,7 +510,7 @@ TEST_F(StringsListsConcatenateTest, SlicedListsWithColumnSeparators) std::vector h_expected{nullptr, nullptr, nullptr, nullptr}; auto const expected = STR_COL{h_expected.begin(), h_expected.end(), nulls_from_nullptrs(h_expected)}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected, verbosity); } // Sliced the first half of the lists column, with null replacements @@ -523,7 +523,7 @@ TEST_F(StringsListsConcatenateTest, SlicedListsWithColumnSeparators) "a+++___+++ccc", nullptr, "___|||efgh|||ijk", "zzz|||xxxxx"}; auto const expected = STR_COL{h_expected.begin(), h_expected.end(), nulls_from_nullptrs(h_expected)}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected, verbosity); } // Sliced the second half of the lists column, no null replacement @@ -535,7 +535,7 @@ TEST_F(StringsListsConcatenateTest, SlicedListsWithColumnSeparators) nullptr, nullptr, "0a0b0c###5x5y5z", nullptr, "ééé-+-12345abcdef", "aaaééébbbéééccc=+=12345"}; auto const expected = STR_COL{h_expected.begin(), h_expected.end(), nulls_from_nullptrs(h_expected)}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected, verbosity); } // Sliced the second half of the lists column, with null replacements @@ -552,7 +552,7 @@ TEST_F(StringsListsConcatenateTest, SlicedListsWithColumnSeparators) "aaaééébbbéééccc=+=12345"}; auto const expected = STR_COL{h_expected.begin(), h_expected.end(), nulls_from_nullptrs(h_expected)}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected, verbosity); } // Sliced the middle part of the lists column, no null replacement @@ -563,7 +563,7 @@ TEST_F(StringsListsConcatenateTest, SlicedListsWithColumnSeparators) std::vector h_expected{nullptr, nullptr, nullptr, nullptr, "0a0b0c###5x5y5z"}; auto const expected = STR_COL{h_expected.begin(), h_expected.end(), nulls_from_nullptrs(h_expected)}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected, verbosity); } // Sliced the middle part of the lists column, with null replacements @@ -579,6 +579,6 @@ TEST_F(StringsListsConcatenateTest, SlicedListsWithColumnSeparators) "0a0b0c###5x5y5z"}; auto const expected = STR_COL{h_expected.begin(), h_expected.end(), nulls_from_nullptrs(h_expected)}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected, verbosity); } } diff --git a/cpp/tests/strings/floats_tests.cpp b/cpp/tests/strings/floats_tests.cpp index f7151363d83..126bffa1e49 100644 --- a/cpp/tests/strings/floats_tests.cpp +++ b/cpp/tests/strings/floats_tests.cpp @@ -24,6 +24,8 @@ #include +constexpr cudf::test::debug_output_level verbosity{cudf::test::debug_output_level::ALL_ERRORS}; + struct StringsConvertTest : public cudf::test::BaseFixture { }; @@ -99,7 +101,7 @@ TEST_F(StringsConvertTest, ToFloats32) h_expected.begin(), h_expected.end(), thrust::make_transform_iterator(h_strings.begin(), [](auto str) { return str != nullptr; })); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*results, expected, true); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*results, expected, verbosity); } TEST_F(StringsConvertTest, FromFloats32) @@ -128,7 +130,7 @@ TEST_F(StringsConvertTest, FromFloats32) h_expected.end(), thrust::make_transform_iterator(h_expected.begin(), [](auto str) { return str != nullptr; })); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*results, expected, true); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*results, expected, verbosity); } TEST_F(StringsConvertTest, ToFloats64) @@ -168,7 +170,7 @@ TEST_F(StringsConvertTest, ToFloats64) h_expected.begin(), h_expected.end(), thrust::make_transform_iterator(h_strings.begin(), [](auto str) { return str != nullptr; })); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*results, expected, true); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*results, expected, verbosity); } TEST_F(StringsConvertTest, FromFloats64) @@ -197,7 +199,7 @@ TEST_F(StringsConvertTest, FromFloats64) h_expected.end(), thrust::make_transform_iterator(h_expected.begin(), [](auto str) { return str != nullptr; })); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*results, expected, true); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*results, expected, verbosity); } TEST_F(StringsConvertTest, ZeroSizeStringsColumnFloat) diff --git a/cpp/tests/strings/repeat_strings_tests.cpp b/cpp/tests/strings/repeat_strings_tests.cpp index feca4b25c4d..98f91cb2a0a 100644 --- a/cpp/tests/strings/repeat_strings_tests.cpp +++ b/cpp/tests/strings/repeat_strings_tests.cpp @@ -27,7 +27,7 @@ using namespace cudf::test::iterators; namespace { using STR_COL = cudf::test::strings_column_wrapper; -constexpr bool print_all{false}; +constexpr cudf::test::debug_output_level verbosity{cudf::test::debug_output_level::FIRST_ERROR}; } // namespace struct RepeatJoinStringTest : public cudf::test::BaseFixture { @@ -89,21 +89,21 @@ TEST_F(RepeatJoinStringTest, ZeroSizeStringsColumn) { auto const strs = STR_COL{}; auto const results = cudf::strings::repeat_strings(cudf::strings_column_view(strs), 10); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(strs, *results, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(strs, *results, verbosity); } TEST_F(RepeatJoinStringTest, AllEmptyStringsColumn) { auto const strs = STR_COL{"", "", "", "", ""}; auto const results = cudf::strings::repeat_strings(cudf::strings_column_view(strs), 10); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(strs, *results, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(strs, *results, verbosity); } TEST_F(RepeatJoinStringTest, AllNullStringsColumn) { auto const strs = STR_COL{{"" /*NULL*/, "" /*NULL*/, "" /*NULL*/}, all_nulls()}; auto const results = cudf::strings::repeat_strings(cudf::strings_column_view(strs), 10); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(strs, *results, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(strs, *results, verbosity); } TEST_F(RepeatJoinStringTest, ZeroSizeAndNullStringsColumn) @@ -111,7 +111,7 @@ TEST_F(RepeatJoinStringTest, ZeroSizeAndNullStringsColumn) auto const strs = STR_COL{{"" /*NULL*/, "", "" /*NULL*/, "", "", "" /*NULL*/}, nulls_at({0, 2, 5})}; auto const results = cudf::strings::repeat_strings(cudf::strings_column_view(strs), 10); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(strs, *results, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(strs, *results, verbosity); } TEST_F(RepeatJoinStringTest, StringsColumnNoNull) @@ -121,13 +121,13 @@ TEST_F(RepeatJoinStringTest, StringsColumnNoNull) { auto const results = cudf::strings::repeat_strings(cudf::strings_column_view(strs), 2); auto const expected = STR_COL{"0a0b0c0a0b0c", "abcxyzabcxyz", "xyzéééxyzééé", "áááááá", "íííí"}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, verbosity); } // Repeat once. { auto const results = cudf::strings::repeat_strings(cudf::strings_column_view(strs), 1); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(strs, *results, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(strs, *results, verbosity); } // Non-positive repeat times. @@ -135,10 +135,10 @@ TEST_F(RepeatJoinStringTest, StringsColumnNoNull) auto const expected = STR_COL{"", "", "", "", ""}; auto results = cudf::strings::repeat_strings(cudf::strings_column_view(strs), 0); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, verbosity); results = cudf::strings::repeat_strings(cudf::strings_column_view(strs), -100); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, verbosity); } // Sliced the first half of the column. @@ -146,7 +146,7 @@ TEST_F(RepeatJoinStringTest, StringsColumnNoNull) auto const sliced_strs = cudf::slice(strs, {0, 3})[0]; auto const results = cudf::strings::repeat_strings(cudf::strings_column_view(sliced_strs), 2); auto const expected = STR_COL{"0a0b0c0a0b0c", "abcxyzabcxyz", "xyzéééxyzééé"}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, verbosity); } // Sliced the middle of the column. @@ -154,7 +154,7 @@ TEST_F(RepeatJoinStringTest, StringsColumnNoNull) auto const sliced_strs = cudf::slice(strs, {1, 3})[0]; auto const results = cudf::strings::repeat_strings(cudf::strings_column_view(sliced_strs), 2); auto const expected = STR_COL{"abcxyzabcxyz", "xyzéééxyzééé"}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, verbosity); } // Sliced the second half of the column. @@ -162,7 +162,7 @@ TEST_F(RepeatJoinStringTest, StringsColumnNoNull) auto const sliced_strs = cudf::slice(strs, {2, 5})[0]; auto const results = cudf::strings::repeat_strings(cudf::strings_column_view(sliced_strs), 2); auto const expected = STR_COL{"xyzéééxyzééé", "áááááá", "íííí"}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, verbosity); } } @@ -193,13 +193,13 @@ TEST_F(RepeatJoinStringTest, StringsColumnWithNulls) "", "Hello WorldHello World"}, nulls_at({1, 3, 5})}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, verbosity); } // Repeat once. { auto const results = cudf::strings::repeat_strings(cudf::strings_column_view(strs), 1); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(strs, *results, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(strs, *results, verbosity); } // Non-positive repeat times. @@ -208,10 +208,10 @@ TEST_F(RepeatJoinStringTest, StringsColumnWithNulls) {"", "" /*NULL*/, "", "" /*NULL*/, "", "" /*NULL*/, "", "", "", ""}, nulls_at({1, 3, 5})}; auto results = cudf::strings::repeat_strings(cudf::strings_column_view(strs), 0); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, verbosity); results = cudf::strings::repeat_strings(cudf::strings_column_view(strs), -100); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, verbosity); } // Sliced the first half of the column. @@ -219,7 +219,7 @@ TEST_F(RepeatJoinStringTest, StringsColumnWithNulls) auto const sliced_strs = cudf::slice(strs, {0, 3})[0]; auto const results = cudf::strings::repeat_strings(cudf::strings_column_view(sliced_strs), 2); auto const expected = STR_COL{{"0a0b0c0a0b0c", "" /*NULL*/, "abcxyzabcxyz"}, null_at(1)}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, verbosity); } // Sliced the middle of the column. @@ -228,7 +228,7 @@ TEST_F(RepeatJoinStringTest, StringsColumnWithNulls) auto const results = cudf::strings::repeat_strings(cudf::strings_column_view(sliced_strs), 2); auto const expected = STR_COL{ {"abcxyzabcxyz", "" /*NULL*/, "xyzéééxyzééé", "" /*NULL*/, "áááááá"}, nulls_at({1, 3})}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, verbosity); } // Sliced the second half of the column. @@ -238,6 +238,6 @@ TEST_F(RepeatJoinStringTest, StringsColumnWithNulls) auto const expected = STR_COL{"áááááá", "íííí", "", "Hello WorldHello World"}; // The results strings column may have a bitmask with all valid values. - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected, *results, print_all); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected, *results, verbosity); } } diff --git a/cpp/tests/strings/substring_tests.cpp b/cpp/tests/strings/substring_tests.cpp index dcff678a0a5..f9a71407a0d 100644 --- a/cpp/tests/strings/substring_tests.cpp +++ b/cpp/tests/strings/substring_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2020, NVIDIA CORPORATION. + * Copyright (c) 2019-2021, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,6 +28,8 @@ #include #include +constexpr cudf::test::debug_output_level verbosity{cudf::test::debug_output_level::ALL_ERRORS}; + struct StringsSubstringsTest : public cudf::test::BaseFixture { }; @@ -292,7 +294,7 @@ TEST_F(StringsSubstringsScalarDelimiterTest, AllEmpty) auto exp_results = cudf::test::strings_column_wrapper({"", "", "", "", ""}); auto results = cudf::strings::slice_strings(strings_view, cudf::string_scalar("e"), -1); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, exp_results, true); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, exp_results, verbosity); } TEST_F(StringsSubstringsScalarDelimiterTest, EmptyDelimiter) @@ -305,7 +307,7 @@ TEST_F(StringsSubstringsScalarDelimiterTest, EmptyDelimiter) auto exp_results = cudf::test::strings_column_wrapper({"", "", "", "", "", ""}, {true, true, false, true, true, true}); auto results = cudf::strings::slice_strings(strings_view, cudf::string_scalar(""), 1); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, exp_results, true); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, exp_results, verbosity); } TEST_F(StringsSubstringsScalarDelimiterTest, ZeroCount) @@ -319,7 +321,7 @@ TEST_F(StringsSubstringsScalarDelimiterTest, ZeroCount) {true, true, false, true, true, true}); auto results = cudf::strings::slice_strings(strings_view, cudf::string_scalar("é"), 0); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, exp_results, true); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, exp_results, verbosity); } TEST_F(StringsSubstringsScalarDelimiterTest, SearchDelimiter) @@ -334,7 +336,7 @@ TEST_F(StringsSubstringsScalarDelimiterTest, SearchDelimiter) {true, true, false, true, true, true}); auto results = cudf::strings::slice_strings(strings_view, cudf::string_scalar("é"), 1); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, exp_results, true); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, exp_results, verbosity); } { @@ -342,17 +344,17 @@ TEST_F(StringsSubstringsScalarDelimiterTest, SearchDelimiter) {"llo", "", "", "lease", "st strings", ""}, {true, true, false, true, true, true}); auto results = cudf::strings::slice_strings(strings_view, cudf::string_scalar("é"), -1); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, exp_results, true); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, exp_results, verbosity); } { auto results = cudf::strings::slice_strings(strings_view, cudf::string_scalar("é"), 2); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, strings_view.parent(), true); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, strings_view.parent(), verbosity); } { auto results = cudf::strings::slice_strings(strings_view, cudf::string_scalar("é"), -2); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, strings_view.parent(), true); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, strings_view.parent(), verbosity); } { @@ -365,7 +367,7 @@ TEST_F(StringsSubstringsScalarDelimiterTest, SearchDelimiter) auto results = cudf::strings::slice_strings(cudf::strings_column_view{col0}, cudf::string_scalar("o"), 2); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, exp_results, true); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, exp_results, verbosity); } { @@ -378,7 +380,7 @@ TEST_F(StringsSubstringsScalarDelimiterTest, SearchDelimiter) auto results = cudf::strings::slice_strings(cudf::strings_column_view{col0}, cudf::string_scalar("o"), -2); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, exp_results, true); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, exp_results, verbosity); } { @@ -392,7 +394,7 @@ TEST_F(StringsSubstringsScalarDelimiterTest, SearchDelimiter) auto results = cudf::strings::slice_strings(cudf::strings_column_view{col0}, cudf::string_scalar("éé"), 3); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, exp_results, true); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, exp_results, verbosity); } { @@ -406,7 +408,7 @@ TEST_F(StringsSubstringsScalarDelimiterTest, SearchDelimiter) auto results = cudf::strings::slice_strings(cudf::strings_column_view{col0}, cudf::string_scalar("éé"), -3); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, exp_results, true); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, exp_results, verbosity); } { @@ -422,7 +424,7 @@ TEST_F(StringsSubstringsScalarDelimiterTest, SearchDelimiter) auto results = cudf::strings::slice_strings(cudf::strings_column_view{col0}, cudf::string_scalar("."), 3); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, exp_results, true); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, exp_results, verbosity); } { @@ -439,7 +441,7 @@ TEST_F(StringsSubstringsScalarDelimiterTest, SearchDelimiter) auto results = cudf::strings::slice_strings(cudf::strings_column_view{col0}, cudf::string_scalar(".."), -2); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, exp_results, true); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, exp_results, verbosity); } } @@ -475,7 +477,7 @@ TEST_F(StringsSubstringsColumnDelimiterTest, ColumnAllEmpty) auto results = cudf::strings::slice_strings( cudf::strings_column_view{col0}, cudf::strings_column_view{delim_col}, -1); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, exp_results, true); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, exp_results, verbosity); } TEST_F(StringsSubstringsColumnDelimiterTest, DelimiterAllEmptyAndInvalid) @@ -490,7 +492,7 @@ TEST_F(StringsSubstringsColumnDelimiterTest, DelimiterAllEmptyAndInvalid) auto results = cudf::strings::slice_strings( cudf::strings_column_view{col0}, cudf::strings_column_view{delim_col}, 1); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, exp_results, true); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, exp_results, verbosity); } TEST_F(StringsSubstringsColumnDelimiterTest, ZeroDelimiterCount) @@ -505,7 +507,7 @@ TEST_F(StringsSubstringsColumnDelimiterTest, ZeroDelimiterCount) auto results = cudf::strings::slice_strings( cudf::strings_column_view{col0}, cudf::strings_column_view{delim_col}, 0); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, exp_results, true); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, exp_results, verbosity); } TEST_F(StringsSubstringsColumnDelimiterTest, SearchDelimiter) @@ -521,7 +523,7 @@ TEST_F(StringsSubstringsColumnDelimiterTest, SearchDelimiter) auto results = cudf::strings::slice_strings( cudf::strings_column_view{col0}, cudf::strings_column_view{delim_col}, 1); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, exp_results, true); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, exp_results, verbosity); } { @@ -539,7 +541,7 @@ TEST_F(StringsSubstringsColumnDelimiterTest, SearchDelimiter) auto results = cudf::strings::slice_strings( cudf::strings_column_view{col0}, cudf::strings_column_view{delim_col}, -1); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, exp_results, true); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, exp_results, verbosity); } { @@ -563,7 +565,7 @@ TEST_F(StringsSubstringsColumnDelimiterTest, SearchDelimiter) auto results = cudf::strings::slice_strings( cudf::strings_column_view{col0}, cudf::strings_column_view{delim_col}, 3); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, exp_results, true); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, exp_results, verbosity); } { @@ -585,6 +587,6 @@ TEST_F(StringsSubstringsColumnDelimiterTest, SearchDelimiter) auto results = cudf::strings::slice_strings( cudf::strings_column_view{col0}, cudf::strings_column_view{delim_col}, -3); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, exp_results, true); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, exp_results, verbosity); } } diff --git a/cpp/tests/utilities/column_utilities.cu b/cpp/tests/utilities/column_utilities.cu index 2bdb77136bf..706193a222d 100644 --- a/cpp/tests/utilities/column_utilities.cu +++ b/cpp/tests/utilities/column_utilities.cu @@ -176,13 +176,20 @@ std::unique_ptr generate_child_row_indices(lists_column_view const& c, return result; } -#define PROP_EXPECT_EQ(a, b, _msg) \ - do { \ - if (throw_on_fail) { \ - CUDF_EXPECTS(a == b, _msg); \ - } else { \ - EXPECT_EQ(a, b); \ - } \ +#define PROP_EXPECT_EQ(a, b) \ + do { \ + if (verbosity == debug_output_level::QUIET) { \ + if (a != b) { return false; } \ + } else { \ + EXPECT_EQ(a, b); \ + if (a != b) { \ + if (verbosity == debug_output_level::FIRST_ERROR) { \ + return false; \ + } else { \ + result = false; \ + } \ + } \ + } \ } while (0) template @@ -207,61 +214,63 @@ struct column_property_comparator { return thrust::reduce(rmm::exec_policy(), validity_iter, validity_iter + row_indices.size()); } - void compare_common(cudf::column_view const& lhs, + bool compare_common(cudf::column_view const& lhs, cudf::column_view const& rhs, cudf::column_view const& lhs_row_indices, cudf::column_view const& rhs_row_indices, - bool throw_on_fail) + debug_output_level verbosity) { + bool result = true; + if (check_exact_equality) { - PROP_EXPECT_EQ(lhs.type(), rhs.type(), "Type mismatch"); + PROP_EXPECT_EQ(lhs.type(), rhs.type()); } else { - PROP_EXPECT_EQ(types_equivalent(lhs.type(), rhs.type()), true, "Type mismatch"); + PROP_EXPECT_EQ(types_equivalent(lhs.type(), rhs.type()), true); } // DISCUSSION: does this make sense, semantically? auto const lhs_size = check_exact_equality ? lhs.size() : lhs_row_indices.size(); auto const rhs_size = check_exact_equality ? rhs.size() : rhs_row_indices.size(); - PROP_EXPECT_EQ(lhs_size, rhs_size, "Column size mismatch"); + PROP_EXPECT_EQ(lhs_size, rhs_size); - if (lhs_size > 0 && check_exact_equality) { - PROP_EXPECT_EQ(lhs.nullable(), rhs.nullable(), "Column nullability mismatch"); - } + if (lhs_size > 0 && check_exact_equality) { PROP_EXPECT_EQ(lhs.nullable(), rhs.nullable()); } // DISCUSSION: does this make sense, semantically? auto const lhs_null_count = check_exact_equality ? lhs.null_count() : count_nulls(lhs, lhs_row_indices); auto const rhs_null_count = check_exact_equality ? rhs.null_count() : count_nulls(rhs, rhs_row_indices); - PROP_EXPECT_EQ(lhs_null_count, rhs_null_count, "Null count mismatch"); + PROP_EXPECT_EQ(lhs_null_count, rhs_null_count); // equivalent, but not exactly equal columns can have a different number of children if their // sizes are both 0. Specifically, empty string columns may or may not have children. if (check_exact_equality || (lhs.size() > 0 && lhs.null_count() < lhs.size())) { - PROP_EXPECT_EQ(lhs.num_children(), rhs.num_children(), "Child count mismatch"); + PROP_EXPECT_EQ(lhs.num_children(), rhs.num_children()); } + + return result; } template ::value && !std::is_same::value>* = nullptr> - void operator()(cudf::column_view const& lhs, + bool operator()(cudf::column_view const& lhs, cudf::column_view const& rhs, cudf::column_view const& lhs_row_indices, cudf::column_view const& rhs_row_indices, - bool throw_on_fail) + debug_output_level verbosity) { - compare_common(lhs, rhs, lhs_row_indices, rhs_row_indices, throw_on_fail); + return compare_common(lhs, rhs, lhs_row_indices, rhs_row_indices, verbosity); } template ::value>* = nullptr> - void operator()(cudf::column_view const& lhs, + bool operator()(cudf::column_view const& lhs, cudf::column_view const& rhs, cudf::column_view const& lhs_row_indices, cudf::column_view const& rhs_row_indices, - bool throw_on_fail) + debug_output_level verbosity) { - compare_common(lhs, rhs, lhs_row_indices, rhs_row_indices, throw_on_fail); + if (!compare_common(lhs, rhs, lhs_row_indices, rhs_row_indices, verbosity)) { return false; } cudf::lists_column_view lhs_l(lhs); cudf::lists_column_view rhs_l(rhs); @@ -274,41 +283,44 @@ struct column_property_comparator { if (lhs_child_indices->size() > 0) { auto rhs_child = rhs_l.get_sliced_child(rmm::cuda_stream_default); auto rhs_child_indices = generate_child_row_indices(rhs_l, rhs_row_indices); - cudf::type_dispatcher(lhs_child.type(), - column_property_comparator{}, - lhs_child, - rhs_child, - *lhs_child_indices, - *rhs_child_indices, - throw_on_fail); + return cudf::type_dispatcher(lhs_child.type(), + column_property_comparator{}, + lhs_child, + rhs_child, + *lhs_child_indices, + *rhs_child_indices, + verbosity); } + return true; } template ::value>* = nullptr> - void operator()(cudf::column_view const& lhs, + bool operator()(cudf::column_view const& lhs, cudf::column_view const& rhs, cudf::column_view const& lhs_row_indices, cudf::column_view const& rhs_row_indices, - bool throw_on_fail) + debug_output_level verbosity) { - compare_common(lhs, rhs, lhs_row_indices, rhs_row_indices, throw_on_fail); + if (!compare_common(lhs, rhs, lhs_row_indices, rhs_row_indices, verbosity)) { return false; } structs_column_view l_scv(lhs); structs_column_view r_scv(rhs); - std::for_each(thrust::make_counting_iterator(0), - thrust::make_counting_iterator(lhs.num_children()), - [&](auto i) { - column_view lhs_child = l_scv.get_sliced_child(i); - column_view rhs_child = r_scv.get_sliced_child(i); - cudf::type_dispatcher(lhs_child.type(), - column_property_comparator{}, - lhs_child, - rhs_child, - lhs_row_indices, - rhs_row_indices, - throw_on_fail); - }); + for (size_type i = 0; i < lhs.num_children(); i++) { + column_view lhs_child = l_scv.get_sliced_child(i); + column_view rhs_child = r_scv.get_sliced_child(i); + if (!cudf::type_dispatcher(lhs_child.type(), + column_property_comparator{}, + lhs_child, + rhs_child, + lhs_row_indices, + rhs_row_indices, + verbosity)) { + return false; + } + } + + return true; } }; @@ -416,14 +428,14 @@ std::string stringify_column_differences(cudf::device_span difference column_view const& rhs, column_view const& lhs_row_indices, column_view const& rhs_row_indices, - bool print_all_differences, + debug_output_level verbosity, int depth) { CUDF_EXPECTS(not differences.empty(), "Shouldn't enter this function if `differences` is empty"); std::string const depth_str = depth > 0 ? "depth " + std::to_string(depth) + '\n' : ""; // move the differences to the host. auto h_differences = cudf::detail::make_host_vector_sync(differences); - if (print_all_differences) { + if (verbosity == debug_output_level::ALL_ERRORS) { std::ostringstream buffer; buffer << depth_str << "differences:" << std::endl; @@ -457,12 +469,11 @@ std::string stringify_column_differences(cudf::device_span difference // non-nested column types template struct column_comparator_impl { - void operator()(column_view const& lhs, + bool operator()(column_view const& lhs, column_view const& rhs, column_view const& lhs_row_indices, column_view const& rhs_row_indices, - bool print_all_differences, - bool throw_on_fail, + debug_output_level verbosity, int depth) { auto d_lhs = cudf::table_device_view::create(table_view{{lhs}}); @@ -489,13 +500,16 @@ struct column_comparator_impl { rmm::cuda_stream_default); // shrink back down if (not differences.is_empty()) { - if (throw_on_fail) { - CUDF_FAIL("Column differences detected"); - } else { - GTEST_FAIL() << stringify_column_differences( - differences, lhs, rhs, lhs_row_indices, rhs_row_indices, print_all_differences, depth); + if (verbosity != debug_output_level::QUIET) { + // GTEST_FAIL() does a return that conflicts with our return type. so hide it in a lambda. + [&]() { + GTEST_FAIL() << stringify_column_differences( + differences, lhs, rhs, lhs_row_indices, rhs_row_indices, verbosity, depth); + }(); } + return false; } + return true; } }; @@ -506,19 +520,18 @@ struct column_comparator; // specialization for list columns template struct column_comparator_impl { - void operator()(column_view const& lhs, + bool operator()(column_view const& lhs, column_view const& rhs, column_view const& lhs_row_indices, column_view const& rhs_row_indices, - bool print_all_differences, - bool throw_on_fail, + debug_output_level verbosity, int depth) { lists_column_view lhs_l(lhs); lists_column_view rhs_l(rhs); CUDF_EXPECTS(lhs_row_indices.size() == rhs_row_indices.size(), "List column size mismatch"); - if (lhs_row_indices.is_empty()) { return; } + if (lhs_row_indices.is_empty()) { return true; } // worst case - everything is different rmm::device_uvector differences(lhs_row_indices.size(), rmm::cuda_stream_default); @@ -606,12 +619,14 @@ struct column_comparator_impl { rmm::cuda_stream_default); // shrink back down if (not differences.is_empty()) { - if (throw_on_fail) { - CUDF_FAIL("Column differences detected"); - } else { - GTEST_FAIL() << stringify_column_differences( - differences, lhs, rhs, lhs_row_indices, rhs_row_indices, print_all_differences, depth); + if (verbosity != debug_output_level::QUIET) { + // GTEST_FAIL() does a return that conflicts with our return type. so hide it in a lambda. + [&]() { + GTEST_FAIL() << stringify_column_differences( + differences, lhs, rhs, lhs_row_indices, rhs_row_indices, verbosity, depth); + }(); } + return false; } // recurse. @@ -622,77 +637,77 @@ struct column_comparator_impl { if (lhs_child_indices->size() > 0) { auto rhs_child = rhs_l.get_sliced_child(rmm::cuda_stream_default); auto rhs_child_indices = generate_child_row_indices(rhs_l, rhs_row_indices); - cudf::type_dispatcher(lhs_child.type(), - column_comparator{}, - lhs_child, - rhs_child, - *lhs_child_indices, - *rhs_child_indices, - print_all_differences, - throw_on_fail, - depth + 1); + return cudf::type_dispatcher(lhs_child.type(), + column_comparator{}, + lhs_child, + rhs_child, + *lhs_child_indices, + *rhs_child_indices, + verbosity, + depth + 1); } + + return true; } }; template struct column_comparator_impl { - void operator()(column_view const& lhs, + bool operator()(column_view const& lhs, column_view const& rhs, column_view const& lhs_row_indices, column_view const& rhs_row_indices, - bool print_all_differences, - bool throw_on_fail, + debug_output_level verbosity, int depth) { structs_column_view l_scv(lhs); structs_column_view r_scv(rhs); - std::for_each(thrust::make_counting_iterator(0), - thrust::make_counting_iterator(0) + lhs.num_children(), - [&](auto i) { - column_view lhs_child = l_scv.get_sliced_child(i); - column_view rhs_child = r_scv.get_sliced_child(i); - cudf::type_dispatcher(lhs_child.type(), - column_comparator{}, - lhs_child, - rhs_child, - lhs_row_indices, - rhs_row_indices, - print_all_differences, - throw_on_fail, - depth + 1); - }); + for (size_type i = 0; i < lhs.num_children(); i++) { + column_view lhs_child = l_scv.get_sliced_child(i); + column_view rhs_child = r_scv.get_sliced_child(i); + if (!cudf::type_dispatcher(lhs_child.type(), + column_comparator{}, + lhs_child, + rhs_child, + lhs_row_indices, + rhs_row_indices, + verbosity, + depth + 1)) { + return false; + } + } + return true; } }; template struct column_comparator { template - void operator()(column_view const& lhs, + bool operator()(column_view const& lhs, column_view const& rhs, column_view const& lhs_row_indices, column_view const& rhs_row_indices, - bool print_all_differences = false, - bool throw_on_fail = false, - int depth = 0) + debug_output_level verbosity, + int depth = 0) { CUDF_EXPECTS(lhs_row_indices.size() == rhs_row_indices.size(), "Mismatch in row counts to compare"); // compare properties - cudf::type_dispatcher(lhs.type(), - column_property_comparator{}, - lhs, - rhs, - lhs_row_indices, - rhs_row_indices, - throw_on_fail); + if (!cudf::type_dispatcher(lhs.type(), + column_property_comparator{}, + lhs, + rhs, + lhs_row_indices, + rhs_row_indices, + verbosity)) { + return false; + } // compare values column_comparator_impl comparator{}; - comparator( - lhs, rhs, lhs_row_indices, rhs_row_indices, print_all_differences, throw_on_fail, depth); + return comparator(lhs, rhs, lhs_row_indices, rhs_row_indices, verbosity, depth); } }; @@ -712,63 +727,49 @@ std::unique_ptr generate_all_row_indices(size_type num_rows) /** * @copydoc cudf::test::expect_column_properties_equal */ -void expect_column_properties_equal(column_view const& lhs, +bool expect_column_properties_equal(column_view const& lhs, column_view const& rhs, - bool throw_on_fail) + debug_output_level verbosity) { auto indices = generate_all_row_indices(lhs.size()); - cudf::type_dispatcher( - lhs.type(), column_property_comparator{}, lhs, rhs, *indices, *indices, throw_on_fail); + return cudf::type_dispatcher( + lhs.type(), column_property_comparator{}, lhs, rhs, *indices, *indices, verbosity); } /** * @copydoc cudf::test::expect_column_properties_equivalent */ -void expect_column_properties_equivalent(column_view const& lhs, +bool expect_column_properties_equivalent(column_view const& lhs, column_view const& rhs, - bool throw_on_fail) + debug_output_level verbosity) { auto indices = generate_all_row_indices(lhs.size()); - cudf::type_dispatcher( - lhs.type(), column_property_comparator{}, lhs, rhs, *indices, *indices, throw_on_fail); + return cudf::type_dispatcher( + lhs.type(), column_property_comparator{}, lhs, rhs, *indices, *indices, verbosity); } /** * @copydoc cudf::test::expect_columns_equal */ -void expect_columns_equal(cudf::column_view const& lhs, +bool expect_columns_equal(cudf::column_view const& lhs, cudf::column_view const& rhs, - bool print_all_differences, - bool throw_on_fail) + debug_output_level verbosity) { auto indices = generate_all_row_indices(lhs.size()); - cudf::type_dispatcher(lhs.type(), - column_comparator{}, - lhs, - rhs, - *indices, - *indices, - print_all_differences, - throw_on_fail); + return cudf::type_dispatcher( + lhs.type(), column_comparator{}, lhs, rhs, *indices, *indices, verbosity); } /** * @copydoc cudf::test::expect_columns_equivalent */ -void expect_columns_equivalent(cudf::column_view const& lhs, +bool expect_columns_equivalent(cudf::column_view const& lhs, cudf::column_view const& rhs, - bool print_all_differences, - bool throw_on_fail) + debug_output_level verbosity) { auto indices = generate_all_row_indices(lhs.size()); - cudf::type_dispatcher(lhs.type(), - column_comparator{}, - lhs, - rhs, - *indices, - *indices, - print_all_differences, - throw_on_fail); + return cudf::type_dispatcher( + lhs.type(), column_comparator{}, lhs, rhs, *indices, *indices, verbosity); } /** diff --git a/cpp/tests/utilities_tests/column_utilities_tests.cpp b/cpp/tests/utilities_tests/column_utilities_tests.cpp index 890a6970fa9..9baff0ca203 100644 --- a/cpp/tests/utilities_tests/column_utilities_tests.cpp +++ b/cpp/tests/utilities_tests/column_utilities_tests.cpp @@ -336,11 +336,13 @@ TEST_F(ColumnUtilitiesListsTest, Equivalence) // properties cudf::test::expect_column_properties_equivalent(a, b); - EXPECT_THROW(cudf::test::expect_column_properties_equal(a, b, true), cudf::logic_error); + EXPECT_EQ( + cudf::test::expect_column_properties_equal(a, b, cudf::test::debug_output_level::QUIET), + false); // values CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(a, b); - EXPECT_THROW(cudf::test::expect_columns_equal(a, b, false, true), cudf::logic_error); + EXPECT_EQ(cudf::test::expect_columns_equal(a, b, cudf::test::debug_output_level::QUIET), false); } // list>, nullable vs. non-nullable @@ -352,10 +354,12 @@ TEST_F(ColumnUtilitiesListsTest, Equivalence) // properties cudf::test::expect_column_properties_equivalent(a, b); - EXPECT_THROW(cudf::test::expect_column_properties_equal(a, b, true), cudf::logic_error); + EXPECT_EQ( + cudf::test::expect_column_properties_equal(a, b, cudf::test::debug_output_level::QUIET), + false); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(a, b); - EXPECT_THROW(cudf::test::expect_columns_equal(a, b, false, true), cudf::logic_error); + EXPECT_EQ(cudf::test::expect_columns_equal(a, b, cudf::test::debug_output_level::QUIET), false); } } @@ -384,11 +388,14 @@ TEST_F(ColumnUtilitiesListsTest, DifferentPhysicalStructure) // properties cudf::test::expect_column_properties_equivalent(*c0, *c1); - EXPECT_THROW(cudf::test::expect_column_properties_equal(*c0, *c1, true), cudf::logic_error); + EXPECT_EQ( + cudf::test::expect_column_properties_equal(*c0, *c1, cudf::test::debug_output_level::QUIET), + false); // values CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*c0, *c1); - EXPECT_THROW(cudf::test::expect_columns_equal(*c0, *c1, false, true), cudf::logic_error); + EXPECT_EQ(cudf::test::expect_columns_equal(*c0, *c1, cudf::test::debug_output_level::QUIET), + false); } // list>> @@ -438,11 +445,14 @@ TEST_F(ColumnUtilitiesListsTest, DifferentPhysicalStructure) // properties cudf::test::expect_column_properties_equivalent(*c0, *c1); - EXPECT_THROW(cudf::test::expect_column_properties_equal(*c0, *c1, true), cudf::logic_error); + EXPECT_EQ( + cudf::test::expect_column_properties_equal(*c0, *c1, cudf::test::debug_output_level::QUIET), + false); // values CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*c0, *c1); - EXPECT_THROW(cudf::test::expect_columns_equal(*c0, *c1, false, true), cudf::logic_error); + EXPECT_EQ(cudf::test::expect_columns_equal(*c0, *c1, cudf::test::debug_output_level::QUIET), + false); } } @@ -472,7 +482,9 @@ TEST_F(ColumnUtilitiesStructsTest, Properties) // equivalent, but not equal cudf::test::expect_column_properties_equivalent(s_col0, s_col1); - EXPECT_THROW(cudf::test::expect_column_properties_equal(s_col0, s_col1, true), cudf::logic_error); + EXPECT_EQ(cudf::test::expect_column_properties_equal( + s_col0, s_col1, cudf::test::debug_output_level::QUIET), + false); cudf::test::expect_column_properties_equal(s_col0, s_col0); cudf::test::expect_column_properties_equal(s_col1, s_col1); @@ -501,7 +513,8 @@ TEST_F(ColumnUtilitiesStructsTest, Values) // equivalent, but not equal CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(s_col0, s_col1); - EXPECT_THROW(cudf::test::expect_columns_equal(s_col0, s_col1, false, true), cudf::logic_error); + EXPECT_EQ(cudf::test::expect_columns_equal(s_col0, s_col1, cudf::test::debug_output_level::QUIET), + false); CUDF_TEST_EXPECT_COLUMNS_EQUAL(s_col0, s_col0); CUDF_TEST_EXPECT_COLUMNS_EQUAL(s_col1, s_col1); From 0724a3d8198b8749d5d0cb5084dea4d6d1497df3 Mon Sep 17 00:00:00 2001 From: Dave Baranec Date: Mon, 19 Jul 2021 12:03:48 -0500 Subject: [PATCH 6/6] Formatting changes from PR review. --- cpp/include/cudf_test/column_utilities.hpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cpp/include/cudf_test/column_utilities.hpp b/cpp/include/cudf_test/column_utilities.hpp index beb34c6c452..dfb9ae67c4e 100644 --- a/cpp/include/cudf_test/column_utilities.hpp +++ b/cpp/include/cudf_test/column_utilities.hpp @@ -30,12 +30,11 @@ namespace test { /** * @brief Verbosity level of output from column and table comparison functions. - * */ enum class debug_output_level { FIRST_ERROR = 0, // print first error only ALL_ERRORS, // print all errors - QUIET, // no debug output + QUIET // no debug output }; /**