test updates.
This commit is contained in:
parent
a1fb284797
commit
490d7dae38
4 changed files with 7 additions and 7 deletions
2
util.go
2
util.go
|
@ -109,7 +109,7 @@ func Normalize(values ...float64) []float64 {
|
||||||
}
|
}
|
||||||
output := make([]float64, len(values))
|
output := make([]float64, len(values))
|
||||||
for x, v := range values {
|
for x, v := range values {
|
||||||
output[x] = RoundDown(v/total, 0.00001)
|
output[x] = RoundDown(v/total, 0.0001)
|
||||||
}
|
}
|
||||||
return output
|
return output
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,7 +122,7 @@ func TestNormalize(t *testing.T) {
|
||||||
normalized := Normalize(values...)
|
normalized := Normalize(values...)
|
||||||
assert.Len(normalized, 5)
|
assert.Len(normalized, 5)
|
||||||
assert.Equal(0.25, normalized[0])
|
assert.Equal(0.25, normalized[0])
|
||||||
assert.Equal(0.15, normalized[4])
|
assert.Equal(0.1499, normalized[4])
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
2
value.go
2
value.go
|
@ -32,7 +32,7 @@ func (vs Values) Normalize() []Value {
|
||||||
output[index] = Value{
|
output[index] = Value{
|
||||||
Style: v.Style,
|
Style: v.Style,
|
||||||
Label: v.Label,
|
Label: v.Label,
|
||||||
Value: RoundDown(v.Value/total, 0.00001),
|
Value: RoundDown(v.Value/total, 0.0001),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return output
|
return output
|
||||||
|
|
|
@ -45,8 +45,8 @@ func TestValuesValuesNormalized(t *testing.T) {
|
||||||
|
|
||||||
values := Values(vs).ValuesNormalized()
|
values := Values(vs).ValuesNormalized()
|
||||||
assert.Len(values, 7)
|
assert.Len(values, 7)
|
||||||
assert.Equal(0.212, values[0])
|
assert.Equal(0.2127, values[0])
|
||||||
assert.Equal(0.042, values[6])
|
assert.Equal(0.0425, values[6])
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestValuesNormalize(t *testing.T) {
|
func TestValuesNormalize(t *testing.T) {
|
||||||
|
@ -64,6 +64,6 @@ func TestValuesNormalize(t *testing.T) {
|
||||||
|
|
||||||
values := Values(vs).Normalize()
|
values := Values(vs).Normalize()
|
||||||
assert.Len(values, 7)
|
assert.Len(values, 7)
|
||||||
assert.Equal(0.212, values[0].Value)
|
assert.Equal(0.2127, values[0].Value)
|
||||||
assert.Equal(0.042, values[6].Value)
|
assert.Equal(0.0425, values[6].Value)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue