This is an automated email from the ASF dual-hosted git repository.
pitrou pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/main by this push:
new 391be251d3f GH-12681: [C++] Work around FP rounding issues in quantile
tests (#55744)
391be251d3f is described below
commit 391be251d3f1365fdbacfde6112330fb80143510
Author: Antoine Pitrou <[email protected]>
AuthorDate: Tue Nov 24 09:02:07 2026 +0100
GH-12681: [C++] Work around FP rounding issues in quantile tests (#55744)
### Rationale for this change
On some architectures (such as Risc-V) and/or with some optimizations
enabled (such as `-fma` on x86), the quantile compute kernel may not output
results rigorously equal to those from a textbook quantile computation as used
in the tests.
Thanks to PukNgae Cryolitia (GH id `Cryolitia`) for diagnosing the issue
and suggesting the fix.
### What changes are included in this PR?
Allow for some slight divergence (1 ULP) between the results.
### Are these changes tested?
By definition.
### Are there any user-facing changes?
No.
### Was AI used for this PR?
In accordance to the [AI generation
guidelines](https://arrow.apache.org/docs/dev/developers/overview.html#ai-generated-code),
please disclose below whether and how AI was used in this PR.
**PR code and description written by:**
- [x] Human
- [ ] AI
**Reviewed before submission by:**
- [x] Human
- [ ] AI
- [ ] Not reviewed
* GitHub Issue: #12681
Authored-by: Antoine Pitrou <[email protected]>
Signed-off-by: Antoine Pitrou <[email protected]>
---
cpp/src/arrow/compute/kernels/aggregate_test.cc | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/cpp/src/arrow/compute/kernels/aggregate_test.cc
b/cpp/src/arrow/compute/kernels/aggregate_test.cc
index 4ef2b2f88a5..289adf5bfb3 100644
--- a/cpp/src/arrow/compute/kernels/aggregate_test.cc
+++ b/cpp/src/arrow/compute/kernels/aggregate_test.cc
@@ -3849,10 +3849,9 @@ class TestPrimitiveQuantileKernel : public
::testing::Test {
for (int64_t j = 0; j < out_array->length(); ++j) {
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)))
- << " Actual Value: " << quantiles[j] << "\n"
- << "Expected Value: " << numeric_scalar->value;
+ // The results may not be rigorously equal to the "naive" results
+ // on some architecture and/or with some compiler flags (GH-12681).
+ AssertWithinUlp(quantiles[j], numeric_scalar->value, 1);
}
} else {
AssertTypeEqual(out_array->type(), type_singleton());