Helper API refactor (#40)

* api cleaup

* updates

* wtf

* updates

* snapshot.

* tweaks

* snapshot

* api tweaks.

* updates

* updates

* updates

* changes.

* updates

* updates

* sequence => seq

* dont need to use curl, just using wget

* fixing examples
This commit is contained in:
Will Charczuk 2017-05-12 17:12:23 -07:00 committed by GitHub
parent 43212f871f
commit 03708a90ef
100 changed files with 1687 additions and 1055 deletions

View file

@ -1,18 +1,20 @@
package chart
import (
"fmt"
"math"
"testing"
"github.com/blendlabs/go-assert"
"github.com/wcharczuk/go-chart/seq"
)
func TestBollingerBandSeries(t *testing.T) {
assert := assert.New(t)
s1 := mockValueProvider{
X: Sequence.Float64(1.0, 100.0),
Y: Sequence.Random(100, 1024),
s1 := mockValuesProvider{
X: seq.Range(1.0, 100.0),
Y: seq.RandomValuesWithMax(100, 1024),
}
bbs := &BollingerBandsSeries{
@ -24,27 +26,27 @@ func TestBollingerBandSeries(t *testing.T) {
y2values := make([]float64, 100)
for x := 0; x < 100; x++ {
xvalues[x], y1values[x], y2values[x] = bbs.GetBoundedValue(x)
xvalues[x], y1values[x], y2values[x] = bbs.GetBoundedValues(x)
}
for x := bbs.GetPeriod(); x < 100; x++ {
assert.True(y1values[x] > y2values[x])
assert.True(y1values[x] > y2values[x], fmt.Sprintf("%v vs. %v", y1values[x], y2values[x]))
}
}
func TestBollingerBandLastValue(t *testing.T) {
assert := assert.New(t)
s1 := mockValueProvider{
X: Sequence.Float64(1.0, 100.0),
Y: Sequence.Float64(1.0, 100.0),
s1 := mockValuesProvider{
X: seq.Range(1.0, 100.0),
Y: seq.Range(1.0, 100.0),
}
bbs := &BollingerBandsSeries{
InnerSeries: s1,
}
x, y1, y2 := bbs.GetBoundedLastValue()
x, y1, y2 := bbs.GetBoundedLastValues()
assert.Equal(100.0, x)
assert.Equal(101, math.Floor(y1))
assert.Equal(83, math.Floor(y2))