Skip to content

Commit

Permalink
ESQL: Make test less precise (elastic#100556)
Browse files Browse the repository at this point in the history
This changes an assertion in a test for median absolute deviation that
hit floating point rounding errors. It happens fairly rarely, maybe 2%
of the time but is reproducable with the right key.
  • Loading branch information
nik9000 committed Oct 31, 2023
1 parent 4550213 commit 94f2051
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import java.util.stream.Collectors;
import java.util.stream.DoubleStream;

import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.closeTo;

public class MedianAbsoluteDeviationDoubleGroupingAggregatorFunctionTests extends GroupingAggregatorFunctionTestCase {

Expand Down Expand Up @@ -58,10 +58,8 @@ protected String expectedDescriptionOfAggregator() {

@Override
protected void assertSimpleGroup(List<Page> input, Block result, int position, Long group) {
assertThat(
((DoubleBlock) result).getDouble(position),
equalTo(medianAbsoluteDeviation(input.stream().flatMapToDouble(p -> allDoubles(p, group))))
);
double medianAbsoluteDeviation = medianAbsoluteDeviation(input.stream().flatMapToDouble(p -> allDoubles(p, group)));
assertThat(((DoubleBlock) result).getDouble(position), closeTo(medianAbsoluteDeviation, medianAbsoluteDeviation * .000001));
}

static double medianAbsoluteDeviation(DoubleStream s) {
Expand Down

0 comments on commit 94f2051

Please sign in to comment.