-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconcat_test.go
80 lines (70 loc) · 2.24 KB
/
concat_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package dataframe
import (
"testing"
u "github.com/rom1mouret/ml-essentials/utils"
)
func TestRowConcat(t *testing.T) {
builder := DataBuilder{RawData: NewRawData()}
builder.AddInts("col", 1, 2, 3)
df1 := fillBlanks(builder)
df1.SetMaxCPU(1)
builder = DataBuilder{RawData: NewRawData()}
builder.AddInts("col", 4, 5, 6)
df2 := fillBlanks(builder)
df2.SetMaxCPU(1)
df, err := RowConcat(df1, df2)
if u.AssertTrue("error", err == nil, t) {
df.CheckConsistency(t)
u.AssertIntEquals("MaxCPU", df.ActualMaxCPU(), 1, t)
data := df.ints["col"]
u.AssertIntSliceEquals("data", data, []int{1, 2, 3, 4, 5, 6}, t)
}
}
func TestColumnCopyConcat(t *testing.T) {
builder := DataBuilder{RawData: NewRawData()}
builder.AddInts("col1", 1, 2, 3)
df1 := builder.ToDataFrame()
builder = DataBuilder{RawData: NewRawData()}
builder.AddInts("col2", 4, 5, 6)
df2 := builder.ToDataFrame()
df1.SetMaxCPU(1)
df2.SetMaxCPU(1)
df, err := ColumnCopyConcat(df1, df2)
if u.AssertTrue("error", err == nil, t) {
df.CheckConsistency(t)
u.AssertIntEquals("MaxCPU", df.ActualMaxCPU(), 1, t)
data1 := df.ints["col1"]
u.AssertIntSliceEquals("data", data1, []int{1, 2, 3}, t)
data2 := df.ints["col2"]
u.AssertIntSliceEquals("data", data2, []int{4, 5, 6}, t)
}
}
func Test1ColumnConcatView(t *testing.T) {
builder := DataBuilder{RawData: NewRawData()}
builder.AddInts("col1", 1, 2, 3)
df1 := builder.ToDataFrame()
builder = DataBuilder{RawData: NewRawData()}
builder.AddInts("col2", 4, 5, 6)
df2 := builder.ToDataFrame()
df1.SetMaxCPU(1)
df2.SetMaxCPU(1)
df1 = df1.SliceView(-1, -2)
df2 = df2.SliceView(-1, -2)
df, err := ColumnConcatView(df1, df2)
if u.AssertTrue("error", err == nil, t) {
df.CheckConsistency(t)
u.AssertIntEquals("MaxCPU", df.ActualMaxCPU(), 1, t)
}
}
func Test2ColumnConcatView(t *testing.T) {
builder := DataBuilder{RawData: NewRawData()}
builder.AddInts("col1", 1, 2, 3)
df1 := builder.ToDataFrame()
builder = DataBuilder{RawData: NewRawData()}
builder.AddInts("col2", 4, 5, 6)
df2 := builder.ToDataFrame()
df1 = df1.IndexView([]int{0, 0, 0, 0})
df2 = df2.IndexView([]int{1, 1, 1, 1})
_, err := ColumnConcatView(df1, df2)
u.AssertTrue("error", err != nil, t)
}