@@ -41,37 +41,41 @@ func TestNew(t *testing.T) {
4141 }
4242}
4343
44- func TestApplyAV (t * testing.T ) {
45- mprof := []float64 {4 , 6 , 10 , 2 , 1 , 0 , 1 , 2 , 0 , 0 , 1 , 2 , 6 }
46-
44+ func TestApplyAVDefault (t * testing.T ) {
4745 testdata := []struct {
48- a []float64
49- w int
50- av av.AV
51- expectedMP []float64
46+ a []float64
47+ w int
5248 }{
53- {[]float64 {1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , 16 }, 4 , av . Default , mprof },
49+ {[]float64 {1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , 16 }, 4 },
5450 }
5551
56- var mp MatrixProfile
52+ var mp * MatrixProfile
5753 var err error
5854 var outab []float64
5955 for _ , d := range testdata {
60- newMP := make ([]float64 , len (mprof ))
61- copy (newMP , mprof )
62- mp = MatrixProfile {A : d .a , W : d .w , MP : newMP , AV : d .av }
56+ mp , err = New (d .a , nil , d .w )
57+ if err != nil {
58+ t .Errorf ("%v" , err )
59+ break
60+ }
61+ if err = mp .Compute (NewMPOpts ()); err != nil {
62+ t .Errorf ("%v" , err )
63+ break
64+ }
65+
66+ mp .AV = av .Default
6367 outab , _ , err = mp .ApplyAV ()
6468 if err != nil {
6569 t .Fatal (err )
6670 }
6771
68- if len (outab ) != len (d . expectedMP ) {
69- t .Errorf ("Expected %d elements, but got %d, %+v" , len (d . expectedMP ), len (outab ), d )
72+ if len (outab ) != len (mp . MP ) {
73+ t .Errorf ("Expected %d elements, but got %d, %+v" , len (mp . MP ), len (outab ), d )
7074 break
7175 }
7276 for i := 0 ; i < len (outab ); i ++ {
73- if math .Abs (float64 (outab [i ]- d . expectedMP [i ])) > 1e-7 {
74- t .Errorf ("Expected %v,\n but got\n %v for %+v" , d . expectedMP , outab , d )
77+ if math .Abs (float64 (outab [i ]- mp . MP [i ])) > 1e-7 {
78+ t .Errorf ("Expected %v,\n but got\n %v for %+v" , mp . MP , outab , d )
7579 break
7680 }
7781 }
@@ -775,7 +779,7 @@ func TestDiscoverDiscords(t *testing.T) {
775779 }
776780
777781 for _ , d := range testdata {
778- mp := MatrixProfile {A : a , B : a , W : w , MP : d .mp , AV : av .Default }
782+ mp := MatrixProfile {A : a , B : a , W : w , MP : d .mp , AV : av .Default , Opts : NewMPOpts () }
779783 discords , err := mp .DiscoverDiscords (d .k , d .exzone )
780784 if err != nil {
781785 t .Errorf ("Got error %v on %v" , err , d )
0 commit comments