This repository has been archived by the owner on Feb 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
goTWED_test.go
88 lines (86 loc) · 1.75 KB
/
goTWED_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
81
82
83
84
85
86
87
88
package gotwed
import "testing"
func TestTWED(t *testing.T) {
type args struct {
ta []float64
tsa []float64
tb []float64
tsb []float64
nu float64
lambda float64
degree int32
}
tests := []struct {
name string
args args
wantDistance float64
}{
{"Basic Test", args{
[]float64{0, 0, 1, 1, 2, 3, 5, 2, 0, 1, -0.1},
[]float64{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
[]float64{0, 1, 1, 1, 2, 3, 5, 2, 0, 1, -0.1},
[]float64{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
1.1,
2.2,
1,
}, 2,
},
{"Time Series ta too short", args{
[]float64{0, 1},
[]float64{4, 5, 6, 7, 8},
[]float64{0, 1, 1, 1, 1, 3},
[]float64{0, 1, 2, 3, 4, 5},
1.2,
2.3,
2,
}, -1,
},
{"Time Series tb too short", args{
[]float64{0, 0, 1, 1, 2, 3, 5, 7, 0, 1},
[]float64{0, 1, 2, 3, 4, 5, 6, 7, 8, 9},
[]float64{20, 12, 13},
[]float64{3, 4, 5, 6, 7, 8, 9, 10},
1.3,
2.4,
3,
}, -1,
},
{"Time Series tsa too short", args{
[]float64{5, 2, 0, 1},
[]float64{1, 2},
[]float64{23, 26, 28, 29, 27},
[]float64{5, 6, 7, 8, 9},
1.4,
2.5,
4,
}, -1,
},
{"Time Series tsb too short", args{
[]float64{12, 15, 16, 18, 17},
[]float64{0, 1, 2, 3, 4},
[]float64{50, 100, 200},
[]float64{0, 1},
1.5,
2.6,
5,
}, -1,
},
{"Parameter degree negative", args{
[]float64{0, 1},
[]float64{0, 1},
[]float64{0, 1},
[]float64{0, 1},
1.1,
2.2,
-1,
}, -1,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if gotDistance := TWED(tt.args.ta, tt.args.tsa, tt.args.tb, tt.args.tsb, tt.args.nu, tt.args.lambda, tt.args.degree); gotDistance != tt.wantDistance {
t.Errorf("TWED() = %v, want %v", gotDistance, tt.wantDistance)
}
})
}
}