Skip to content

Commit 6700e75

Browse files
committed
Push fix for imprecisions on macOS
1 parent 11903a2 commit 6700e75

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

cpp/src/arrow/compute/kernels/aggregate_test.cc

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4152,6 +4152,14 @@ class TestRandomQuantileKernel : public TestPrimitiveQuantileKernel<ArrowType> {
41524152

41534153
void VerifyTDigest(const std::shared_ptr<ChunkedArray>& chunked,
41544154
std::vector<double>& quantiles) {
4155+
// For some reason, TDigest computations with libc++ seem much less accurate.
4156+
// A possible explanation is that libc++ has less precise implementations
4157+
// of std::sin and std::asin, used in the TDigest implementation.
4158+
# ifdef _LIBCPP_VERSION
4159+
constexpr double kRelativeTolerance = 0.09;
4160+
# else
4161+
constexpr double kRelativeTolerance = 0.05;
4162+
# endif
41554163
TDigestOptions options(quantiles);
41564164
ASSERT_OK_AND_ASSIGN(Datum out, TDigest(chunked, options));
41574165
const auto& out_array = out.make_array();
@@ -4166,7 +4174,7 @@ class TestRandomQuantileKernel : public TestPrimitiveQuantileKernel<ArrowType> {
41664174
const double* approx = out_array->data()->GetValues<double>(1);
41674175
for (size_t i = 0; i < quantiles.size(); ++i) {
41684176
const auto& exact_scalar = checked_pointer_cast<DoubleScalar>(exact[i][0].scalar());
4169-
const double tolerance = std::fabs(exact_scalar->value) * 0.05;
4177+
const double tolerance = std::fabs(exact_scalar->value) * kRelativeTolerance;
41704178
EXPECT_NEAR(approx[i], exact_scalar->value, tolerance) << quantiles[i];
41714179
}
41724180
}

0 commit comments

Comments
 (0)