Skip to content

Commit

Permalink
clang-tidy autofixes
Browse files Browse the repository at this point in the history
  • Loading branch information
vyasr committed Sep 27, 2024
1 parent 6973ef8 commit aa615bf
Show file tree
Hide file tree
Showing 46 changed files with 666 additions and 529 deletions.
2 changes: 1 addition & 1 deletion cpp/include/cudf/io/parquet.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1200,7 +1200,7 @@ class parquet_writer_options : public parquet_writer_options_base {
* @param sink The sink used for writer output
* @param table Table to be written to output
*/
explicit parquet_writer_options(sink_info const& sink, table_view const& table);
explicit parquet_writer_options(sink_info const& sink, table_view table);

public:
/**
Expand Down
5 changes: 2 additions & 3 deletions cpp/include/cudf_test/type_list_utilities.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -414,9 +414,8 @@ struct RemoveIfImpl<PRED, Types<>> {

template <class PRED, class HEAD, class... TAIL>
struct RemoveIfImpl<PRED, Types<HEAD, TAIL...>> {
using type =
Concat<typename std::conditional<PRED::template Call<HEAD>::value, Types<>, Types<HEAD>>::type,
typename RemoveIfImpl<PRED, Types<TAIL...>>::type>;
using type = Concat<std::conditional_t<PRED::template Call<HEAD>::value, Types<>, Types<HEAD>>,
typename RemoveIfImpl<PRED, Types<TAIL...>>::type>;
};
// @endcond

Expand Down
5 changes: 3 additions & 2 deletions cpp/src/io/functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include <cudf/utilities/memory_resource.hpp>

#include <algorithm>
#include <utility>

namespace cudf::io {

Expand Down Expand Up @@ -852,8 +853,8 @@ void parquet_writer_options_base::set_sorting_columns(std::vector<sorting_column
_sorting_columns = std::move(sorting_columns);
}

parquet_writer_options::parquet_writer_options(sink_info const& sink, table_view const& table)
: parquet_writer_options_base(sink), _table(table)
parquet_writer_options::parquet_writer_options(sink_info const& sink, table_view table)
: parquet_writer_options_base(sink), _table(std::move(table))
{
}

Expand Down
4 changes: 2 additions & 2 deletions cpp/src/io/utilities/output_builder.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,8 @@ class output_builder {
* @param mr The memory resource used to allocate the output vector.
* @return The output vector.
*/
rmm::device_uvector<T> gather(rmm::cuda_stream_view stream,
rmm::device_async_resource_ref mr) const
[[nodiscard]] rmm::device_uvector<T> gather(rmm::cuda_stream_view stream,
rmm::device_async_resource_ref mr) const
{
rmm::device_uvector<T> output{size(), stream, mr};
auto output_it = output.begin();
Expand Down
47 changes: 24 additions & 23 deletions cpp/tests/ast/transform_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,14 @@ TEST_F(TransformTest, NullLiteral)
auto expression = cudf::ast::operation(cudf::ast::ast_operator::IDENTITY, literal);

auto result = cudf::compute_column(table, expression);
auto expected = column_wrapper<int32_t>({-123, -123, -123, -123}, {0, 0, 0, 0});
auto expected = column_wrapper<int32_t>({-123, -123, -123, -123}, {false, false, false, false});

CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, result->view(), verbosity);
}

TEST_F(TransformTest, IsNull)
{
auto c_0 = column_wrapper<int32_t>{{0, 1, 2, 0}, {0, 1, 1, 0}};
auto c_0 = column_wrapper<int32_t>{{0, 1, 2, 0}, {false, true, true, false}};
auto table = cudf::table_view{{c_0}};

// result of IS_NULL on literal, will be a column of table size, with all values set to
Expand Down Expand Up @@ -378,7 +378,7 @@ TEST_F(TransformTest, DeeplyNestedArithmeticLogicalExpression)
auto expressions = std::list<cudf::ast::operation>();

auto op = arithmetic_operator;
expressions.push_back(cudf::ast::operation(op, col_ref, col_ref));
expressions.emplace_back(op, col_ref, col_ref);

for (int64_t i = 0; i < depth_level - 1; i++) {
if (i == depth_level - 2) {
Expand All @@ -387,9 +387,9 @@ TEST_F(TransformTest, DeeplyNestedArithmeticLogicalExpression)
op = arithmetic_operator;
}
if (nested_left_tree) {
expressions.push_back(cudf::ast::operation(op, expressions.back(), col_ref));
expressions.emplace_back(op, expressions.back(), col_ref);
} else {
expressions.push_back(cudf::ast::operation(op, col_ref, expressions.back()));
expressions.emplace_back(op, col_ref, expressions.back());
}
}
return expressions;
Expand Down Expand Up @@ -717,62 +717,63 @@ TEST_F(TransformTest, BasicEqualityNullEqualNoNulls)

TEST_F(TransformTest, BasicEqualityNormalEqualWithNulls)
{
auto c_0 = column_wrapper<int32_t>{{3, 20, 1, 50}, {1, 1, 0, 0}};
auto c_1 = column_wrapper<int32_t>{{3, 7, 1, 0}, {1, 1, 0, 0}};
auto c_0 = column_wrapper<int32_t>{{3, 20, 1, 50}, {true, true, false, false}};
auto c_1 = column_wrapper<int32_t>{{3, 7, 1, 0}, {true, true, false, false}};
auto table = cudf::table_view{{c_0, c_1}};

auto col_ref_0 = cudf::ast::column_reference(0);
auto col_ref_1 = cudf::ast::column_reference(1);
auto expression = cudf::ast::operation(cudf::ast::ast_operator::EQUAL, col_ref_0, col_ref_1);

auto expected = column_wrapper<bool>{{true, false, true, true}, {1, 1, 0, 0}};
auto expected = column_wrapper<bool>{{true, false, true, true}, {true, true, false, false}};
auto result = cudf::compute_column(table, expression);

CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, result->view(), verbosity);
}

TEST_F(TransformTest, BasicEqualityNulls)
{
auto c_0 = column_wrapper<int32_t>{{3, 20, 1, 2, 50}, {1, 1, 0, 1, 0}};
auto c_1 = column_wrapper<int32_t>{{3, 7, 1, 2, 0}, {1, 1, 1, 0, 0}};
auto c_0 = column_wrapper<int32_t>{{3, 20, 1, 2, 50}, {true, true, false, true, false}};
auto c_1 = column_wrapper<int32_t>{{3, 7, 1, 2, 0}, {true, true, true, false, false}};
auto table = cudf::table_view{{c_0, c_1}};

auto col_ref_0 = cudf::ast::column_reference(0);
auto col_ref_1 = cudf::ast::column_reference(1);
auto expression = cudf::ast::operation(cudf::ast::ast_operator::NULL_EQUAL, col_ref_0, col_ref_1);

auto expected = column_wrapper<bool>{{true, false, false, false, true}, {1, 1, 1, 1, 1}};
auto result = cudf::compute_column(table, expression);
auto expected =
column_wrapper<bool>{{true, false, false, false, true}, {true, true, true, true, true}};
auto result = cudf::compute_column(table, expression);

CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, result->view(), verbosity);
}

TEST_F(TransformTest, UnaryNotNulls)
{
auto c_0 = column_wrapper<int32_t>{{3, 0, 0, 50}, {0, 0, 1, 1}};
auto c_0 = column_wrapper<int32_t>{{3, 0, 0, 50}, {false, false, true, true}};
auto table = cudf::table_view{{c_0}};

auto col_ref_0 = cudf::ast::column_reference(0);

auto expression = cudf::ast::operation(cudf::ast::ast_operator::NOT, col_ref_0);

auto result = cudf::compute_column(table, expression);
auto expected = column_wrapper<bool>{{false, true, true, false}, {0, 0, 1, 1}};
auto expected = column_wrapper<bool>{{false, true, true, false}, {false, false, true, true}};

CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, result->view(), verbosity);
}

TEST_F(TransformTest, BasicAdditionNulls)
{
auto c_0 = column_wrapper<int32_t>{{3, 20, 1, 50}, {0, 0, 1, 1}};
auto c_1 = column_wrapper<int32_t>{{10, 7, 20, 0}, {0, 1, 0, 1}};
auto c_0 = column_wrapper<int32_t>{{3, 20, 1, 50}, {false, false, true, true}};
auto c_1 = column_wrapper<int32_t>{{10, 7, 20, 0}, {false, true, false, true}};
auto table = cudf::table_view{{c_0, c_1}};

auto col_ref_0 = cudf::ast::column_reference(0);
auto col_ref_1 = cudf::ast::column_reference(1);
auto expression = cudf::ast::operation(cudf::ast::ast_operator::ADD, col_ref_0, col_ref_1);

auto expected = column_wrapper<int32_t>{{0, 0, 0, 50}, {0, 0, 0, 1}};
auto expected = column_wrapper<int32_t>{{0, 0, 0, 50}, {false, false, false, true}};
auto result = cudf::compute_column(table, expression);

CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, result->view(), verbosity);
Expand Down Expand Up @@ -807,9 +808,9 @@ TEST_F(TransformTest, BasicAdditionLargeNulls)
TEST_F(TransformTest, NullLogicalAnd)
{
auto c_0 = column_wrapper<bool>{{false, false, true, true, false, false, true, true},
{1, 1, 1, 1, 1, 0, 0, 0}};
{true, true, true, true, true, false, false, false}};
auto c_1 = column_wrapper<bool>{{false, true, false, true, true, true, false, true},
{1, 1, 1, 1, 0, 1, 1, 0}};
{true, true, true, true, false, true, true, false}};
auto table = cudf::table_view{{c_0, c_1}};

auto col_ref_0 = cudf::ast::column_reference(0);
Expand All @@ -818,7 +819,7 @@ TEST_F(TransformTest, NullLogicalAnd)
cudf::ast::operation(cudf::ast::ast_operator::NULL_LOGICAL_AND, col_ref_0, col_ref_1);

auto expected = column_wrapper<bool>{{false, false, false, true, false, false, false, true},
{1, 1, 1, 1, 1, 0, 1, 0}};
{true, true, true, true, true, false, true, false}};
auto result = cudf::compute_column(table, expression);

CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, result->view(), verbosity);
Expand All @@ -827,9 +828,9 @@ TEST_F(TransformTest, NullLogicalAnd)
TEST_F(TransformTest, NullLogicalOr)
{
auto c_0 = column_wrapper<bool>{{false, false, true, true, false, false, true, true},
{1, 1, 1, 1, 1, 0, 1, 0}};
{true, true, true, true, true, false, true, false}};
auto c_1 = column_wrapper<bool>{{false, true, false, true, true, true, false, true},
{1, 1, 1, 1, 0, 1, 0, 0}};
{true, true, true, true, false, true, false, false}};
auto table = cudf::table_view{{c_0, c_1}};

auto col_ref_0 = cudf::ast::column_reference(0);
Expand All @@ -838,7 +839,7 @@ TEST_F(TransformTest, NullLogicalOr)
cudf::ast::operation(cudf::ast::ast_operator::NULL_LOGICAL_OR, col_ref_0, col_ref_1);

auto expected = column_wrapper<bool>{{false, true, true, true, false, true, true, true},
{1, 1, 1, 1, 0, 1, 1, 0}};
{true, true, true, true, false, true, true, false}};
auto result = cudf::compute_column(table, expression);

CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, result->view(), verbosity);
Expand Down
4 changes: 2 additions & 2 deletions cpp/tests/binaryop/binop-compiled-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ template <>
auto lhs_random_column<std::string>(cudf::size_type size)
{
return cudf::test::strings_column_wrapper({"eee", "bb", "<null>", "", "aa", "bbb", "ééé"},
{1, 1, 0, 1, 1, 1, 1});
{true, true, false, true, true, true, true});
}
template <typename T>
auto rhs_random_column(cudf::size_type size)
Expand All @@ -56,7 +56,7 @@ template <>
auto rhs_random_column<std::string>(cudf::size_type size)
{
return cudf::test::strings_column_wrapper({"ééé", "bbb", "aa", "", "<null>", "bb", "eee"},
{1, 1, 1, 1, 0, 1, 1});
{true, true, true, true, false, true, true});
}

// combinations to test
Expand Down
48 changes: 23 additions & 25 deletions cpp/tests/binaryop/util/operation.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ struct Add {
void>* = nullptr>
OutT operator()(TypeLhs lhs, TypeRhs rhs) const
{
using TypeCommon = typename std::common_type<OutT, TypeLhs, TypeRhs>::type;
using TypeCommon = std::common_type_t<OutT, TypeLhs, TypeRhs>;
return static_cast<OutT>(static_cast<TypeCommon>(lhs) + static_cast<TypeCommon>(rhs));
}
};
Expand All @@ -72,7 +72,7 @@ struct Sub {
void>* = nullptr>
OutT operator()(TypeLhs lhs, TypeRhs rhs) const
{
using TypeCommon = typename std::common_type<OutT, TypeLhs, TypeRhs>::type;
using TypeCommon = std::common_type_t<OutT, TypeLhs, TypeRhs>;
return static_cast<OutT>(static_cast<TypeCommon>(lhs) - static_cast<TypeCommon>(rhs));
}
};
Expand All @@ -83,7 +83,7 @@ struct Mul {
std::enable_if_t<!cudf::is_duration_t<OutT>::value, void>* = nullptr>
TypeOut operator()(TypeLhs lhs, TypeRhs rhs) const
{
using TypeCommon = typename std::common_type<TypeOut, TypeLhs, TypeRhs>::type;
using TypeCommon = std::common_type_t<TypeOut, TypeLhs, TypeRhs>;
return static_cast<TypeOut>(static_cast<TypeCommon>(lhs) * static_cast<TypeCommon>(rhs));
}

Expand All @@ -100,7 +100,7 @@ struct Mul {
std::enable_if_t<(cudf::is_duration_t<LhsT>::value && std::is_integral_v<RhsT>) ||
(cudf::is_duration_t<RhsT>::value && std::is_integral_v<LhsT>),
void>* = nullptr>
OutT DurationProduct(LhsT x, RhsT y) const
[[nodiscard]] OutT DurationProduct(LhsT x, RhsT y) const
{
return x * y;
}
Expand All @@ -112,7 +112,7 @@ struct Div {
std::enable_if_t<!cudf::is_duration_t<LhsT>::value, void>* = nullptr>
TypeOut operator()(TypeLhs lhs, TypeRhs rhs)
{
using TypeCommon = typename std::common_type<TypeOut, TypeLhs, TypeRhs>::type;
using TypeCommon = std::common_type_t<TypeOut, TypeLhs, TypeRhs>;
return static_cast<TypeOut>(static_cast<TypeCommon>(lhs) / static_cast<TypeCommon>(rhs));
}

Expand All @@ -128,7 +128,7 @@ struct Div {
typename LhsT,
typename RhsT,
std::enable_if_t<(std::is_integral_v<RhsT> || cudf::is_duration<RhsT>()), void>* = nullptr>
OutT DurationDivide(LhsT x, RhsT y) const
[[nodiscard]] OutT DurationDivide(LhsT x, RhsT y) const
{
return x / y;
}
Expand Down Expand Up @@ -191,33 +191,31 @@ struct FloorDiv {

template <typename TypeOut, typename TypeLhs, typename TypeRhs>
struct Mod {
template <typename OutT = TypeOut,
typename LhsT = TypeLhs,
typename RhsT = TypeRhs,
std::enable_if_t<
(std::is_integral_v<typename std::common_type<OutT, LhsT, RhsT>::type>)>* = nullptr>
template <typename OutT = TypeOut,
typename LhsT = TypeLhs,
typename RhsT = TypeRhs,
std::enable_if_t<(std::is_integral_v<std::common_type_t<OutT, LhsT, RhsT>>)>* = nullptr>
TypeOut operator()(TypeLhs lhs, TypeRhs rhs)
{
using TypeCommon = typename std::common_type<TypeOut, TypeLhs, TypeRhs>::type;
using TypeCommon = std::common_type_t<TypeOut, TypeLhs, TypeRhs>;
return static_cast<TypeOut>(static_cast<TypeCommon>(lhs) % static_cast<TypeCommon>(rhs));
}

template <typename OutT = TypeOut,
typename LhsT = TypeLhs,
typename RhsT = TypeRhs,
std::enable_if_t<(
std::is_same_v<typename std::common_type<OutT, LhsT, RhsT>::type, float>)>* = nullptr>
template <
typename OutT = TypeOut,
typename LhsT = TypeLhs,
typename RhsT = TypeRhs,
std::enable_if_t<(std::is_same_v<std::common_type_t<OutT, LhsT, RhsT>, float>)>* = nullptr>
TypeOut operator()(TypeLhs lhs, TypeRhs rhs)
{
return static_cast<TypeOut>(fmod(static_cast<float>(lhs), static_cast<float>(rhs)));
}

template <
typename OutT = TypeOut,
typename LhsT = TypeLhs,
typename RhsT = TypeRhs,
std::enable_if_t<(std::is_same_v<typename std::common_type<OutT, LhsT, RhsT>::type, double>)>* =
nullptr>
typename OutT = TypeOut,
typename LhsT = TypeLhs,
typename RhsT = TypeRhs,
std::enable_if_t<(std::is_same_v<std::common_type_t<OutT, LhsT, RhsT>, double>)>* = nullptr>
TypeOut operator()(TypeLhs lhs, TypeRhs rhs)
{
return static_cast<TypeOut>(fmod(static_cast<double>(lhs), static_cast<double>(rhs)));
Expand Down Expand Up @@ -326,7 +324,7 @@ struct LogBase {

template <typename TypeOut, typename TypeLhs, typename TypeRhs>
struct PMod {
using CommonArgsT = typename std::common_type<TypeLhs, TypeRhs>::type;
using CommonArgsT = std::common_type_t<TypeLhs, TypeRhs>;

TypeOut operator()(TypeLhs x, TypeRhs y) const
{
Expand All @@ -351,8 +349,8 @@ struct PyMod {
TypeOut operator()(TypeLhs x, TypeRhs y) const
{
if constexpr (std::is_floating_point_v<TypeLhs> or std::is_floating_point_v<TypeRhs>) {
double x1 = static_cast<double>(x);
double y1 = static_cast<double>(y);
auto x1 = static_cast<double>(x);
auto y1 = static_cast<double>(y);
return fmod(fmod(x1, y1) + y1, y1);
} else {
return ((x % y) + y) % y;
Expand Down
12 changes: 8 additions & 4 deletions cpp/tests/bitmask/bitmask_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -696,8 +696,10 @@ struct MergeBitmaskTest : public cudf::test::BaseFixture {};

TEST_F(MergeBitmaskTest, TestBitmaskAnd)
{
cudf::test::fixed_width_column_wrapper<bool> const bools_col1({0, 1, 0, 1, 1}, {0, 1, 1, 1, 0});
cudf::test::fixed_width_column_wrapper<bool> const bools_col2({0, 2, 1, 0, 255}, {1, 1, 0, 1, 0});
cudf::test::fixed_width_column_wrapper<bool> const bools_col1({0, 1, 0, 1, 1},
{false, true, true, true, false});
cudf::test::fixed_width_column_wrapper<bool> const bools_col2({0, 2, 1, 0, 255},
{true, true, false, true, false});
cudf::test::fixed_width_column_wrapper<bool> const bools_col3({0, 2, 1, 0, 255});

auto const input1 = cudf::table_view({bools_col3});
Expand Down Expand Up @@ -728,8 +730,10 @@ TEST_F(MergeBitmaskTest, TestBitmaskAnd)

TEST_F(MergeBitmaskTest, TestBitmaskOr)
{
cudf::test::fixed_width_column_wrapper<bool> const bools_col1({0, 1, 0, 1, 1}, {1, 1, 0, 0, 1});
cudf::test::fixed_width_column_wrapper<bool> const bools_col2({0, 2, 1, 0, 255}, {0, 0, 1, 0, 1});
cudf::test::fixed_width_column_wrapper<bool> const bools_col1({0, 1, 0, 1, 1},
{true, true, false, false, true});
cudf::test::fixed_width_column_wrapper<bool> const bools_col2({0, 2, 1, 0, 255},
{false, false, true, false, true});
cudf::test::fixed_width_column_wrapper<bool> const bools_col3({0, 2, 1, 0, 255});

auto const input1 = cudf::table_view({bools_col3});
Expand Down
4 changes: 2 additions & 2 deletions cpp/tests/copying/copy_range_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,8 @@ TEST_F(CopyRangeTestFixture, CopyWithNullsString)

TEST_F(CopyRangeTestFixture, CopyWithTargetNullsString)
{
auto target =
cudf::test::strings_column_wrapper({"a", "b", "", "d", "", "é"}, {1, 1, 0, 1, 1, 1});
auto target = cudf::test::strings_column_wrapper({"a", "b", "", "d", "", "é"},
{true, true, false, true, true, true});
auto source = cudf::test::strings_column_wrapper({"A", "B", "C", "D", "E", "F"});
auto result = cudf::copy_range(source, target, 1, 5, 1);
auto expected = cudf::test::strings_column_wrapper({"a", "B", "C", "D", "E", "é"});
Expand Down
Loading

0 comments on commit aa615bf

Please sign in to comment.