Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ARROW-17304: [C++][Compute] Print actual values when compare fails in aggregate test #13814

Merged
merged 2 commits into from
Aug 9, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions cpp/src/arrow/compute/kernels/aggregate_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2532,6 +2532,7 @@ template <typename CType>
void CheckModes(const Datum& array, const ModeOptions options,
const std::vector<CType>& expected_modes,
const std::vector<int64_t>& expected_counts) {
ARROW_SCOPED_TRACE("Mode Options: ", options.ToString());
ASSERT_OK_AND_ASSIGN(Datum out, Mode(array, options));
ValidateOutput(out);
const StructArray out_array(out.array());
Expand All @@ -2543,7 +2544,9 @@ void CheckModes(const Datum& array, const ModeOptions options,
for (int i = 0; i < out_array.length(); ++i) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could perhaps also add ARROW_SCOPED_TRACE("Mode options = ", options.ToString()) somewhere above to provide better insight into what is computed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

// equal or nan equal
ASSERT_TRUE((expected_modes[i] == out_modes[i]) ||
(expected_modes[i] != expected_modes[i] && out_modes[i] != out_modes[i]));
(expected_modes[i] != expected_modes[i] && out_modes[i] != out_modes[i]))
<< " Actual Value: " << out_modes[i] << "\n"
<< "Expected Value: " << expected_modes[i];
ASSERT_EQ(expected_counts[i], out_counts[i]);
}
}
Expand All @@ -2552,6 +2555,7 @@ template <>
void CheckModes<bool>(const Datum& array, const ModeOptions options,
const std::vector<bool>& expected_modes,
const std::vector<int64_t>& expected_counts) {
ARROW_SCOPED_TRACE("Mode Options: ", options.ToString());
ASSERT_OK_AND_ASSIGN(Datum out, Mode(array, options));
ValidateOutput(out);
const StructArray out_array(out.array());
Expand All @@ -2561,7 +2565,7 @@ void CheckModes<bool>(const Datum& array, const ModeOptions options,
const uint8_t* out_modes = out_array.field(0)->data()->GetValues<uint8_t>(1);
const int64_t* out_counts = out_array.field(1)->data()->GetValues<int64_t>(1);
for (int i = 0; i < out_array.length(); ++i) {
ASSERT_TRUE(expected_modes[i] == bit_util::GetBit(out_modes, i));
ASSERT_EQ(expected_modes[i], bit_util::GetBit(out_modes, i));
ASSERT_EQ(expected_counts[i], out_counts[i]);
}
}
Expand Down Expand Up @@ -3337,6 +3341,7 @@ class TestPrimitiveQuantileKernel : public ::testing::Test {

for (size_t i = 0; i < this->interpolations_.size(); ++i) {
options.interpolation = this->interpolations_[i];
ARROW_SCOPED_TRACE("Quantile Options: ", options.ToString());

ASSERT_OK_AND_ASSIGN(Datum out, Quantile(array, options));
const auto& out_array = out.make_array();
Expand All @@ -3351,7 +3356,9 @@ class TestPrimitiveQuantileKernel : public ::testing::Test {
const auto& numeric_scalar =
checked_pointer_cast<DoubleScalar>(expected[j][i].scalar());
ASSERT_TRUE((quantiles[j] == numeric_scalar->value) ||
(std::isnan(quantiles[j]) && std::isnan(numeric_scalar->value)));
(std::isnan(quantiles[j]) && std::isnan(numeric_scalar->value)))
<< " Actual Value: " << quantiles[j] << "\n"
<< "Expected Value: " << numeric_scalar->value;
}
} else {
AssertTypeEqual(out_array->type(), type_singleton());
Expand Down