-
Notifications
You must be signed in to change notification settings - Fork 2
/
exp_window_test.go
55 lines (52 loc) · 965 Bytes
/
exp_window_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
package series
import (
"testing"
)
func TestExpWindow_Mean(t *testing.T) {
type fields struct {
data Data
atype AlphaType
param DType
adjust bool
ignoreNA bool
}
tests := []struct {
name string
fields fields
want Data
}{
{
"simple",
fields{
data: MakeData(
1,
[]int64{1, 2, 3, 4, 5},
[]DType{0, 1, 2, NaN, 4},
),
atype: AlphaCom,
param: 0.5,
adjust: true,
ignoreNA: false,
},
MakeData(
1,
[]int64{1, 2, 3, 4, 5},
[]DType{0, 0.6923077, 1.575, 1.575, 3.198347},
),
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
w := ExpWindow{
data: tt.fields.data,
atype: tt.fields.atype,
param: tt.fields.param,
adjust: tt.fields.adjust,
ignoreNA: tt.fields.ignoreNA,
}
if got := w.Mean(); !got.Equals(tt.want, 10e-4) {
t.Errorf("ExpWindow.Mean() = %v, want %v", got, tt.want)
}
})
}
}