Skip to content

Commit

Permalink
specialize unit test for rolling MEAN of timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
karthikeyann committed May 29, 2020
1 parent afb4f34 commit fe2e54c
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion cpp/tests/rolling/rolling_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,23 @@ class RollingTest : public cudf::test::BaseFixture {
return col.release();
}

template <typename OutputType,
typename agg_op,
bool is_mean_of_timestamp,
std::enable_if_t<!is_mean_of_timestamp>* = nullptr>
auto run_op(OutputType& val, OutputType const& in)
{
val = agg_op{}(in, val);
}
template <typename OutputType,
typename agg_op,
bool is_mean_of_timestamp,
std::enable_if_t<is_mean_of_timestamp>* = nullptr>
auto run_op(OutputType& val, OutputType const& in)
{
val = static_cast<OutputType>(agg_op{}(in.time_since_epoch(), val.time_since_epoch()));
}

template <typename agg_op,
cudf::aggregation::Kind k,
typename OutputType,
Expand Down Expand Up @@ -297,7 +314,8 @@ class RollingTest : public cudf::test::BaseFixture {
size_type count = 0;
for (size_type j = start_index; j < end_index; j++) {
if (!input.nullable() || cudf::bit_is_set(valid_mask, j)) {
val = op(static_cast<OutputType>(in_col[j]), val);
run_op<OutputType, agg_op, (is_mean and cudf::is_timestamp<OutputType>())>(
val, static_cast<OutputType>(in_col[j]));
count++;
}
}
Expand Down

0 comments on commit fe2e54c

Please sign in to comment.