-
Notifications
You must be signed in to change notification settings - Fork 0
/
imageutil_test.go
28 lines (26 loc) · 3.48 KB
/
imageutil_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
package main
import (
"fmt"
"testing"
)
func TestImageToQueryInput(t *testing.T) {
oneHotCorrect := []float64{0.999, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}
dataCorrect := []float64{0.6549019607843137, 0.6627450980392157, 0.6509803921568628, 0.6627450980392157, 0.6549019607843137, 0.6549019607843137, 0.6627450980392157, 0.6627450980392157, 0.6431372549019608, 0.6313725490196078, 0.611764705882353, 0.6235294117647059, 0.6392156862745098, 0.6196078431372549, 0.6274509803921569, 0.6470588235294118, 0.6392156862745098, 0.6235294117647059, 0.615686274509804, 0.611764705882353, 0.6274509803921569, 0.6431372549019608, 0.611764705882353, 0.6235294117647059, 0.6313725490196078, 0.6196078431372549, 0.6313725490196078, 0.6274509803921569, 0.6509803921568628, 0.6549019607843137, 0.6509803921568628, 0.6588235294117647, 0.6627450980392157, 0.6392156862745098, 0.6431372549019608, 0.6431372549019608, 0.6549019607843137, 0.6392156862745098, 0.6235294117647059, 0.6352941176470588, 0.6509803921568628, 0.6392156862745098, 0.6352941176470588, 0.6274509803921569, 0.6313725490196078, 0.6274509803921569, 0.615686274509804, 0.6078431372549019, 0.6196078431372549, 0.6392156862745098, 0.615686274509804, 0.6235294117647059, 0.6431372549019608, 0.6196078431372549, 0.611764705882353, 0.6196078431372549, 0.6470588235294118, 0.6352941176470588, 0.6470588235294118, 0.6509803921568628, 0.6470588235294118, 0.6313725490196078, 0.6352941176470588, 0.6470588235294118, 0.6549019607843137, 0.6549019607843137, 0.6274509803921569, 0.592156862745098, 0.6509803921568628, 0.6509803921568628, 0.6235294117647059, 0.6039215686274509, 0.611764705882353, 0.615686274509804, 0.6313725490196078, 0.6196078431372549, 0.6196078431372549, 0.6313725490196078, 0.6196078431372549, 0.6235294117647059, 0.615686274509804, 0.6078431372549019, 0.611764705882353, 0.615686274509804, 0.6588235294117647, 0.6509803921568628, 0.6509803921568628, 0.6392156862745098, 0.6274509803921569, 0.6313725490196078, 0.6431372549019608, 0.6392156862745098, 0.6274509803921569, 0.6313725490196078, 0.6313725490196078, 0.5882352941176471, 0.6235294117647059, 0.6196078431372549, 0.6078431372549019, 0.5843137254901961, 0.5843137254901961, 0.5607843137254902, 0.5607843137254902, 0.5686274509803921, 0.5725490196078431, 0.6, 0.615686274509804, 0.6196078431372549, 0.6235294117647059, 0.615686274509804, 0.6274509803921569, 0.6352941176470588, 0.6666666666666666, 0.6549019607843137, 0.6392156862745098, 0.6352941176470588, 0.6352941176470588, 0.6274509803921569, 0.6392156862745098, 0.6196078431372549, 0.615686274509804, 0.6274509803921569, 0.6235294117647059, 0.6, 0.611764705882353, 0.596078431372549, 0.5647058823529412, 0.5803921568627451, 0.5176470588235295, 0.4117647058823529, 0.3411764705882353, 0.30196078431372547, 0.3176470588235294, 0.3568627450980392, 0.5254901960784314, 0.615686274509804, 0.6274509803921569, 0.615686274509804, 0.615686274509804, 0.611764705882353, 0.6549019607843137}
data, oneHotLabel, label, err := ImageToQueryInput("./images/0.png")
if err != nil {
t.Error("ImageToQueryInput incorrectly returned an error: ", err)
}
if label != 0 {
t.Error("False label returned. Expected 0, got ", label)
}
for i, _ := range oneHotCorrect {
if oneHotLabel[i] != oneHotCorrect[i] {
t.Error(fmt.Sprintf("False one hot encoding. Expected %v, got %v", oneHotCorrect, oneHotLabel))
}
}
for i, _ := range dataCorrect {
if data[i] != dataCorrect[i] {
t.Error(fmt.Sprintf("False data readout at index %v. Expected %v, got %v", i, dataCorrect[i], data[i]))
}
}
}