Fix flaky test ParallelIterableTestCase#sumOfFloatConsistentRounding.
This test sometimes fails with a delta greater than the allowed delta.
[ERROR] ParallelCollectListIterableTest>ParallelIterableTestCase.sumOfFloatConsistentRounding:894 Batch size: 1000 ==> expected: <5.0000000000000995> but was: <5.000000000000101>
The test:
@Test
public void sumOfFloatConsistentRounding()
{
FloatFunction<Integer> roundingSensitiveElementFunction = i -> (i <= 99995) ? 1.0e-18f : 1.0f;
MutableList<Integer> list = Interval.oneTo(100_000).toList().shuffleThis();
double baseline = this.getExpectedWith(list.toArray(new Integer[]{}))
.sumOfFloat(roundingSensitiveElementFunction);
for (Integer batchSize : BATCH_SIZES)
{
this.batchSize = batchSize;
ParallelIterable<Integer> testCollection = this.newWith(list.toArray(new Integer[]{}));
assertEquals(
baseline,
testCollection.sumOfFloat(roundingSensitiveElementFunction),
1.0e-15,
"Batch size: " + this.batchSize);
}
}
@motlin , I think the test failure you're encountering in the ParallelIterableTestCase#sumOfFloatConsistentRounding is related to floating-point precision. The error message shows that the expected result is <5.0000000000000995>, but the actual result was <5.000000000000101>. This difference is very small and falls within a "flaky test" range because it depends on how floating-point arithmetic is handled internally, which can vary slightly across platforms or when using parallel processing.
Please assign me to this issue so that i can try and solve it. Thanks!
Assigned to you @IamLRBA !
Thank you @motlin