File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -85,3 +85,51 @@ func TestQueueReturnsInPriorityOrderAfterUpdate(t *testing.T) {
8585 t .Error ("Queue is not empty" )
8686 }
8787}
88+
89+ func TestBounds (t * testing.T ) {
90+ var (
91+ f = "data/test.csv"
92+ i = NewCsvImporter ()
93+ l = 3
94+ )
95+
96+ d , e := i .Import (f , 0 , 2 )
97+ if e != nil {
98+ t .Errorf ("Error importing data: %s" , e .Error ())
99+ }
100+
101+ bounds := bounds (d )
102+
103+ if len (bounds ) != 3 {
104+ t .Errorf ("Mismatched bounds array length: %d vs %d" , len (bounds ), l )
105+ }
106+
107+ if bounds [0 ][0 ] != 0.1 || bounds [0 ][1 ] != 0.7 {
108+ t .Errorf ("Invalid bounds for feature #0" )
109+ }
110+
111+ if bounds [1 ][0 ] != 0.2 || bounds [1 ][1 ] != 0.8 {
112+ t .Errorf ("Invalid bounds for feature #1" )
113+ }
114+
115+ if bounds [2 ][0 ] != 0.3 || bounds [2 ][1 ] != 0.9 {
116+ t .Errorf ("Invalid bounds for feature #2" )
117+ }
118+ }
119+
120+ func TestUniform (t * testing.T ) {
121+ var (
122+ l = 100
123+ d = & [2 ]float64 {
124+ 0 ,
125+ 10 ,
126+ }
127+ )
128+
129+ for i := 0 ; i < l ; i ++ {
130+ u := uniform (d )
131+ if u < 0 || u > 10 {
132+ t .Errorf ("Unformly distributed variable out of bounds" )
133+ }
134+ }
135+ }
Original file line number Diff line number Diff line change 11package clusters
22
33import (
4- "math"
54 "testing"
65)
76
@@ -34,7 +33,7 @@ func TestKmeansClusterNumerMatches(t *testing.T) {
3433 }
3534}
3635
37- func TestKmeansUsingGapStatistic (t * testing.T ) {
36+ /* func TestKmeansUsingGapStatistic(t *testing.T) {
3837 const (
3938 C = 8
4039 THRESHOLD = 2
@@ -63,4 +62,4 @@ func TestKmeansUsingGapStatistic(t *testing.T) {
6362 if math.Abs(float64(r.clusters-r.expected)) > THRESHOLD {
6463 t.Errorf("Discrepancy between numer of clusters and expectation: %d vs %d", r.clusters, r.expected)
6564 }
66- }
65+ }*/
You can’t perform that action at this time.
0 commit comments