|
|
@ -37,6 +37,12 @@ func TestSubset(t *testing.T) {
|
|
|
|
m := make(map[interface{}]int)
|
|
|
|
m := make(map[interface{}]int)
|
|
|
|
for i := 0; i < 1000; i++ {
|
|
|
|
for i := 0; i < 1000; i++ {
|
|
|
|
set := subset(append([]string(nil), vals...), test.sub)
|
|
|
|
set := subset(append([]string(nil), vals...), test.sub)
|
|
|
|
|
|
|
|
if test.sub < test.set {
|
|
|
|
|
|
|
|
assert.Equal(t, test.sub, len(set))
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
assert.Equal(t, test.set, len(set))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for _, val := range set {
|
|
|
|
for _, val := range set {
|
|
|
|
m[val]++
|
|
|
|
m[val]++
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -46,20 +52,3 @@ func TestSubset(t *testing.T) {
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func TestSubsetLess(t *testing.T) {
|
|
|
|
|
|
|
|
var vals []string
|
|
|
|
|
|
|
|
for i := 0; i < 100; i++ {
|
|
|
|
|
|
|
|
vals = append(vals, strconv.Itoa(i))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m := make(map[interface{}]int)
|
|
|
|
|
|
|
|
for i := 0; i < 1000; i++ {
|
|
|
|
|
|
|
|
set := subset(append([]string(nil), vals...), 200)
|
|
|
|
|
|
|
|
for _, val := range set {
|
|
|
|
|
|
|
|
m[val]++
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assert.True(t, mathx.CalcEntropy(m) > 0.95)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|