Skip to content

Commit

Permalink
Update test coverage
Browse files Browse the repository at this point in the history
Signed-off-by: Andy Kwok <andy.kwok@improving.com>
  • Loading branch information
andy-k-improving committed Feb 14, 2025
1 parent 4be0400 commit 8348950
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -365,9 +365,6 @@ Function<Queue<ExprValue>, ExprValue> getWmaEvaluator(ExprCoreType type) {
@Override
public void accumulate(ExprValue value) {
receivedValues.add(value);
if (receivedValues.size() > dataPointsNeeded.valueOf().integerValue()) {
receivedValues.remove();
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,36 @@ public void calculates_weighted_moving_average_one_field_four_samples_four_rows(
tupleValue(ImmutableMap.of("distance", 200, "time", 10, "distance_alias", 190))));
}

@Test
public void calculates_weighted_moving_average_one_field_five_samples_four_rows() {
mockPlanWithData(
List.of(
tupleValue(ImmutableMap.of("distance", 100, "time", 10)),
tupleValue(ImmutableMap.of("distance", 200, "time", 10)),
tupleValue(ImmutableMap.of("distance", 200, "time", 10)),
tupleValue(ImmutableMap.of("distance", 200, "time", 10)),
tupleValue(ImmutableMap.of("distance", 200, "time", 10))));

var plan =
new TrendlineOperator(
inputPlan,
Collections.singletonList(
Pair.of(
AstDSL.computation(4, AstDSL.field("distance"), "distance_alias", WMA),
ExprCoreType.DOUBLE)));

List<ExprValue> result = execute(plan);
assertEquals(5, result.size());
assertThat(
result,
containsInAnyOrder(
tupleValue(ImmutableMap.of("distance", 100, "time", 10)),
tupleValue(ImmutableMap.of("distance", 200, "time", 10)),
tupleValue(ImmutableMap.of("distance", 200, "time", 10)),
tupleValue(ImmutableMap.of("distance", 200, "time", 10, "distance_alias", 190)),
tupleValue(ImmutableMap.of("distance", 200, "time", 10, "distance_alias", 200))));
}

@Test
public void calculates_weighted_moving_average_multiple_computations() {
mockPlanWithData(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,5 +165,4 @@ public void testTrendlineWithSortWma() throws IOException {
rows(19615.8),
rows(29393.6));
}

}

0 comments on commit 8348950

Please sign in to comment.