updates
This commit is contained in:
parent
c0fc2baa50
commit
1556c5e843
3 changed files with 11 additions and 1 deletions
|
@ -22,3 +22,7 @@ func TestValueWithStep(t *testing.T) {
|
||||||
assert.Equal(100, values[20])
|
assert.Equal(100, values[20])
|
||||||
assert.Len(values, 21)
|
assert.Len(values, 21)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestValuesLen(t *testing.T) {
|
||||||
|
assert := assert.New(t)
|
||||||
|
}
|
||||||
|
|
|
@ -23,6 +23,11 @@ type Seq struct {
|
||||||
|
|
||||||
// Array enumerates the sequence into a slice.
|
// Array enumerates the sequence into a slice.
|
||||||
func (s Seq) Array() (output []float64) {
|
func (s Seq) Array() (output []float64) {
|
||||||
|
if s.Len() == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
println(s.Len())
|
||||||
output = make([]float64, s.Len())
|
output = make([]float64, s.Len())
|
||||||
for i := 0; i < s.Len(); i++ {
|
for i := 0; i < s.Len(); i++ {
|
||||||
output[i] = s.GetValue(i)
|
output[i] = s.GetValue(i)
|
||||||
|
@ -236,7 +241,7 @@ func (s Seq) Percentile(percent float64) (percentile float64) {
|
||||||
return percentile
|
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 {
|
func (s Seq) Normalize() Seq {
|
||||||
min, max := s.MinMax()
|
min, max := s.MinMax()
|
||||||
|
|
||||||
|
|
|
@ -90,5 +90,6 @@ func TestSequenceNormalize(t *testing.T) {
|
||||||
assert.NotEmpty(normalized)
|
assert.NotEmpty(normalized)
|
||||||
assert.Len(normalized, 5)
|
assert.Len(normalized, 5)
|
||||||
assert.Equal(0, normalized[0])
|
assert.Equal(0, normalized[0])
|
||||||
|
assert.Equal(0.25, normalized[1])
|
||||||
assert.Equal(1, normalized[4])
|
assert.Equal(1, normalized[4])
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue