exp. last value and test.
This commit is contained in:
parent
8bd5cdfe17
commit
2adc3c7fdd
|
@ -78,7 +78,13 @@ func (mas ExponentialMovingAverageSeries) GetLastValue() (x float64, y float64)
|
|||
return
|
||||
}
|
||||
|
||||
return 0.0, 0.0 //this one is going to be a bitch.
|
||||
seriesLength := mas.InnerSeries.Len()
|
||||
for index := 0; index < seriesLength; index++ {
|
||||
x, _ = mas.GetValue(index)
|
||||
}
|
||||
|
||||
y = mas.valueBuffer[seriesLength-1]
|
||||
return
|
||||
}
|
||||
|
||||
// Render renders the series.
|
||||
|
|
|
@ -28,4 +28,8 @@ func TestExponentialMovingAverageSeries(t *testing.T) {
|
|||
|
||||
assert.Equal(10.0, yvalues[0])
|
||||
assert.True(math.Abs(yvalues[9]-3.77) < 0.01)
|
||||
|
||||
lvx, lvy := mas.GetLastValue()
|
||||
assert.Equal(10.0, lvx)
|
||||
assert.True(math.Abs(lvy-3.77) < 0.01)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user