Skip to content

Commit 8a550a5

Browse files
committed
fix SummarizeValues to return last non-NaN value
1 parent cdab347 commit 8a550a5

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

expr/consolidations/consolidations.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,13 @@ func SummarizeValues(f string, values []float64, XFilesFactor float32) float64 {
188188
}
189189
}
190190
case "last", "current":
191-
rv = values[len(values)-1]
191+
rv = math.NaN()
192+
for i := len(values) - 1; i >= 0; i-- {
193+
if !math.IsNaN(values[i]) {
194+
rv = values[i]
195+
break
196+
}
197+
}
192198
total = notNans(values)
193199
case "range", "rangeOf":
194200
vMax := math.Inf(-1)

0 commit comments

Comments
 (0)