This commit is contained in:
Will Charczuk 2017-05-01 22:34:58 -07:00
parent c0fc2baa50
commit 1556c5e843
3 changed files with 11 additions and 1 deletions

View File

@ -22,3 +22,7 @@ func TestValueWithStep(t *testing.T) {
assert.Equal(100, values[20])
assert.Len(values, 21)
}
func TestValuesLen(t *testing.T) {
assert := assert.New(t)
}

View File

@ -23,6 +23,11 @@ type Seq struct {
// Array enumerates the sequence into a slice.
func (s Seq) Array() (output []float64) {
if s.Len() == 0 {
return
}
println(s.Len())
output = make([]float64, s.Len())
for i := 0; i < s.Len(); i++ {
output[i] = s.GetValue(i)
@ -236,7 +241,7 @@ func (s Seq) Percentile(percent float64) (percentile float64) {
return percentile
}
// Normalize maps every value to the interval [0, 1.0).
// Normalize maps every value to the interval [0, 1.0].
func (s Seq) Normalize() Seq {
min, max := s.MinMax()

View File

@ -90,5 +90,6 @@ func TestSequenceNormalize(t *testing.T) {
assert.NotEmpty(normalized)
assert.Len(normalized, 5)
assert.Equal(0, normalized[0])
assert.Equal(0.25, normalized[1])
assert.Equal(1, normalized[4])
}