Debian Codegraph @

dstream/lagchunk_test.go

raw symbols SCIP
1 package dstream
2
3 import "testing"
4
5 func datal1() (Dstream, Dstream) {
6 x1 := []interface{}{
7 []float64{0, 0, 0, 0, 0, 0},
8 []float64{1, 1, 1, 2, 3, 4},
9 []float64{2, 4, 6, 8, 10, 12},
10 }
11 x2 := []interface{}{
12 []float64{0, 0, 1, 2, 3, 4},
13 []float64{1, 2, 2, 2, 2, 1},
14 []float64{3, 3, 3, 3, 3, 3},
15 }
16 x3 := []interface{}{
17 []float64{1, 2, 3, 4, 5, 6},
18 []float64{4, 5, 6, 7, 8, 9},
19 []float64{7, 8, 9, 10, 11, 12},
20 }
21 x4 := []interface{}{
22 []string{"a", "b", "c", "d", "e", "f"},
23 []string{"d", "e", "f", "g", "h", "i"},
24 []string{"g", "h", "i", "j", "k", "l"},
25 }
26 dat := [][]interface{}{x1, x2, x3, x4}
27 na := []string{"x1", "x2", "x3", "x4"}
28 da := NewFromArrays(dat, na)
29
30 x1_0 := []interface{}{
31 []float64{0, 0, 0, 0},
32 []float64{1, 2, 3, 4},
33 []float64{6, 8, 10, 12},
34 }
35 x1_1 := []interface{}{
36 []float64{0, 0, 0, 0},
37 []float64{1, 1, 2, 3},
38 []float64{4, 6, 8, 10},
39 }
40 x2_0 := []interface{}{
41 []float64{1, 2, 3, 4},
42 []float64{2, 2, 2, 1},
43 []float64{3, 3, 3, 3},
44 }
45 x2_1 := []interface{}{
46 []float64{0, 1, 2, 3},
47 []float64{2, 2, 2, 2},
48 []float64{3, 3, 3, 3},
49 }
50 x2_2 := []interface{}{
51 []float64{0, 0, 1, 2},
52 []float64{1, 2, 2, 2},
53 []float64{3, 3, 3, 3},
54 }
55 x3 = []interface{}{
56 []float64{3, 4, 5, 6},
57 []float64{6, 7, 8, 9},
58 []float64{9, 10, 11, 12},
59 }
60 x4 = []interface{}{
61 []string{"c", "d", "e", "f"},
62 []string{"f", "g", "h", "i"},
63 []string{"i", "j", "k", "l"},
64 }
65 dat = [][]interface{}{x1_0, x1_1, x2_0, x2_1, x2_2, x3, x4}
66 na = []string{"x1[0]", "x1[-1]", "x2[0]", "x2[-1]", "x2[-2]", "x3", "x4"}
67 dm := NewFromArrays(dat, na)
68
69 return da, dm
70 }
71
72 func TestLag1(t *testing.T) {
73
74 da, dm := datal1()
75 dx := LagChunk(da, map[string]int{"x1": 1, "x2": 2})
76
77 if !Equal(dm, dx) {
78 t.Fail()
79 }
80 }