Skip to content

Commit

Permalink
fixed averageSeries function
Browse files Browse the repository at this point in the history
  • Loading branch information
EinsamHauer committed Sep 29, 2015
1 parent 86bb934 commit 92d4704
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ public AverageSeriesFunction(String text) {
@Override
public List<TimeSeries> evaluate(TargetEvaluator evaluator) throws EvaluationException {
List<TimeSeries> processedArguments = new ArrayList<>();
processedArguments.addAll(evaluator.eval((Target) arguments.get(0)));
for (Object argument : arguments) {
processedArguments.addAll(evaluator.eval((Target) argument));
}

if (processedArguments.size() == 0) return new ArrayList<>();

Expand Down Expand Up @@ -60,7 +62,11 @@ public List<TimeSeries> evaluate(TargetEvaluator evaluator) throws EvaluationExc

@Override
public void checkArguments() throws InvalidArgumentException {
if (arguments.size() > 1 || arguments.size() == 0) throw new InvalidArgumentException("averageSeries: number of arguments is " + arguments.size() + ". Must be one.");
if (!(arguments.get(0) instanceof Target)) throw new InvalidArgumentException("averageSeries: argument is " + arguments.get(0).getClass().getName() + ". Must be series");
if (arguments.size() == 0) throw new InvalidArgumentException("averageSeries: number of arguments is " + arguments.size() + ". Must be at least one.");

for (int i = 0; i < arguments.size() - 1; i++) {
if (!(arguments.get(i) instanceof Target))
throw new InvalidArgumentException("averageSeries: argument is " + arguments.get(i).getClass().getName() + ". Must be series");
}
}
}

0 comments on commit 92d4704

Please sign in to comment.