go-ml.dev/pkg/base@v0.0.0-20200610162856-60c38abac71b/tests/batch_test.go (about) 1 package tests 2 3 import ( 4 "go-ml.dev/pkg/base/tables" 5 "gotest.tools/assert" 6 "testing" 7 ) 8 9 func Test_Batch1(t *testing.T) { 10 q := Iris. 11 Batch(10). 12 Transform(func(int) (tables.FeaturesMapper, error) { 13 return tables.LambdaMapper(func(t *tables.Table) (*tables.Table, error) { 14 q := t.Except("").With(tables.Col([]int{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}[0:t.Len()]), "Index") 15 return q, nil 16 }), nil 17 }). 18 Flat(). 19 LuckyCollect() 20 x := Iris.LuckyCollect() 21 assert.Assert(t, q.Len() == x.Len()) 22 for i := 0; i < q.Len(); i++ { 23 assert.Assert(t, q.Col("Feature1").Float(i) == x.Col("Feature1").Float(i)) 24 } 25 }