mirror of
https://github.com/sjwhitworth/golearn.git
synced 2025-04-28 13:48:56 +08:00
40 lines
855 B
Go
40 lines
855 B
Go
![]() |
package base
|
||
|
|
||
|
import (
|
||
|
"github.com/gonum/matrix/mat64"
|
||
|
. "github.com/smartystreets/goconvey/convey"
|
||
|
"testing"
|
||
|
)
|
||
|
|
||
|
func TestInlineMat64Creation(t *testing.T) {
|
||
|
|
||
|
Convey("Given a literal array...", t, func() {
|
||
|
mat := mat64.NewDense(4, 3, []float64{
|
||
|
1, 0, 1,
|
||
|
0, 1, 1,
|
||
|
0, 0, 0,
|
||
|
1, 1, 0,
|
||
|
})
|
||
|
inst := InstancesFromMat64(4, 3, mat)
|
||
|
attrs := inst.AllAttributes()
|
||
|
Convey("Attributes should be well-defined...", func() {
|
||
|
So(len(attrs), ShouldEqual, 3)
|
||
|
})
|
||
|
|
||
|
Convey("No class variables set by default...", func() {
|
||
|
classAttrs := inst.AllClassAttributes()
|
||
|
So(len(classAttrs), ShouldEqual, 0)
|
||
|
})
|
||
|
|
||
|
Convey("Getting values should work...", func() {
|
||
|
as, err := inst.GetAttribute(attrs[0])
|
||
|
So(err, ShouldBeNil)
|
||
|
valBytes := inst.Get(as, 3)
|
||
|
val := UnpackBytesToFloat(valBytes)
|
||
|
So(val, ShouldAlmostEqual, 1.0)
|
||
|
})
|
||
|
|
||
|
})
|
||
|
|
||
|
}
|