Skip to content

Commit

Permalink
Merge pull request #213 from lyricnz/bugfix/zero-left
Browse files Browse the repository at this point in the history
Fix edge case with resample min-time
  • Loading branch information
miguelmota authored Oct 9, 2021
2 parents cf52706 + e843b79 commit dfaa8d0
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/timedata/timedata.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ func ResampleTimeSeriesData(data [][]float64, start float64, end float64, numSte
idx := sort.Search(l, func(i int) bool { return data[i][0] >= pos })
var val float64
if idx == 0 {
val = math.NaN() // off the left
if data[0][0] == pos {
val = data[0][1] // exactly left
} else {
val = math.NaN() // off the left
}
} else if idx == l {
val = math.NaN() // off the right
} else {
Expand Down

0 comments on commit dfaa8d0

Please sign in to comment.