stat: clean up lint
MODIFY
stat/cca_example_test.go
stat/cca_example_test.go
@@ -32,7 +32,7 @@ func (s symView) At(i, j int) float64 {
return s.sym.At(s.i+i, s.j+j)
}
-func (s symView) T() mat.Matrix { return mat.Transpose{s} }
+func (s symView) T() mat.Matrix { return mat.Transpose{Matrix: s} }
func ExampleCC() {
// This example is directly analogous to Example 3.5 on page 87 of

MODIFY
stat/distmv/normal.go
stat/distmv/normal.go
@@ -110,7 +110,10 @@ func NewNormalPrecision(mu []float64, prec *mat.SymDense, src rand.Source) (norm
return nil, false
}
var sigma mat.SymDense
- chol.InverseTo(&sigma)
+ err := chol.InverseTo(&sigma)
+ if err != nil {
+ return nil, false
+ }
return NewNormal(mu, &sigma, src)
}
@@ -341,7 +344,10 @@ func (n *Normal) ScoreInput(score, x []float64) []float64 {
copy(tmp, x)
floats.Sub(tmp, n.mu)
- n.chol.SolveVecTo(mat.NewVecDense(len(score), score), mat.NewVecDense(len(tmp), tmp))
+ err := n.chol.SolveVecTo(mat.NewVecDense(len(score), score), mat.NewVecDense(len(tmp), tmp))
+ if err != nil {
+ panic(err)
+ }
floats.Scale(-1, score)
return score
}

MODIFY
stat/distmv/normal_test.go
stat/distmv/normal_test.go
@@ -16,14 +16,6 @@ import (
"gonum.org/v1/gonum/stat"
)
-type mvTest struct {
- Mu []float64
- Sigma *mat.SymDense
- Loc []float64
- Logprob float64
- Prob float64
-}
-
func TestNormProbs(t *testing.T) {
dist1, ok := NewNormal([]float64{0, 0}, mat.NewSymDense(2, []float64{1, 0, 0, 1}), nil)
if !ok {

MODIFY
stat/distmv/statdist_test.go
stat/distmv/statdist_test.go
@@ -62,14 +62,14 @@ func TestBhattacharyyaUniform(t *testing.T) {
tol float64
}{
{
- a: NewUniform([]r1.Interval{{-3, 2}, {-5, 8}}, rnd),
- b: NewUniform([]r1.Interval{{-4, 1}, {-7, 10}}, rnd),
+ a: NewUniform([]r1.Interval{{Min: -3, Max: 2}, {Min: -5, Max: 8}}, rnd),
+ b: NewUniform([]r1.Interval{{Min: -4, Max: 1}, {Min: -7, Max: 10}}, rnd),
samples: 100000,
tol: 1e-2,
},
{
- a: NewUniform([]r1.Interval{{-3, 2}, {-5, 8}}, rnd),
- b: NewUniform([]r1.Interval{{-5, -4}, {-7, 10}}, rnd),
+ a: NewUniform([]r1.Interval{{Min: -3, Max: 2}, {Min: -5, Max: 8}}, rnd),
+ b: NewUniform([]r1.Interval{{Min: -5, Max: -4}, {Min: -7, Max: 10}}, rnd),
samples: 100000,
tol: 1e-2,
},
@@ -257,14 +257,14 @@ func TestKullbackLeiblerUniform(t *testing.T) {
tol float64
}{
{
- a: NewUniform([]r1.Interval{{-5, 2}, {-7, 12}}, rnd),
- b: NewUniform([]r1.Interval{{-4, 1}, {-7, 10}}, rnd),
+ a: NewUniform([]r1.Interval{{Min: -5, Max: 2}, {Min: -7, Max: 12}}, rnd),
+ b: NewUniform([]r1.Interval{{Min: -4, Max: 1}, {Min: -7, Max: 10}}, rnd),
samples: 100000,
tol: 1e-2,
},
{
- a: NewUniform([]r1.Interval{{-5, 2}, {-7, 12}}, rnd),
- b: NewUniform([]r1.Interval{{-9, -6}, {-7, 10}}, rnd),
+ a: NewUniform([]r1.Interval{{Min: -5, Max: 2}, {Min: -7, Max: 12}}, rnd),
+ b: NewUniform([]r1.Interval{{Min: -9, Max: -6}, {Min: -7, Max: 10}}, rnd),
samples: 100000,
tol: 1e-2,
},

MODIFY
stat/distmv/studentst_test.go
stat/distmv/studentst_test.go
@@ -206,7 +206,10 @@ func TestStudentsTConditional(t *testing.T) {
newMuVec := mat.NewVecDense(len(muUnob), newMu)
shiftVec := mat.NewVecDense(len(shift), shift)
var tmp mat.VecDense
- tmp.SolveVec(&sig22, shiftVec)
+ err := tmp.SolveVec(&sig22, shiftVec)
+ if err != nil {
+ t.Errorf("unexpected error from vector solve: %v", err)
+ }
newMuVec.MulVec(sig12, &tmp)
floats.Add(newMu, muUnob)
@@ -215,7 +218,10 @@ func TestStudentsTConditional(t *testing.T) {
}
var tmp2 mat.Dense
- tmp2.Solve(&sig22, sig12.T())
+ err = tmp2.Solve(&sig22, sig12.T())
+ if err != nil {
+ t.Errorf("unexpected error from dense solve: %v", err)
+ }
var tmp3 mat.Dense
tmp3.Mul(sig12, &tmp2)

MODIFY
stat/distmv/uniform_test.go
stat/distmv/uniform_test.go
@@ -17,11 +17,11 @@ func TestUniformEntropy(t *testing.T) {
Entropy float64
}{
{
- NewUniform([]r1.Interval{{0, 1}, {0, 1}}, nil),
+ NewUniform([]r1.Interval{{Min: 0, Max: 1}, {Min: 0, Max: 1}}, nil),
0,
},
{
- NewUniform([]r1.Interval{{-1, 3}, {2, 8}, {-5, -3}}, nil),
+ NewUniform([]r1.Interval{{Min: -1, Max: 3}, {Min: 2, Max: 8}, {Min: -5, Max: -3}}, nil),
math.Log(48),
},
} {

MODIFY
stat/sampleuv/example_rate_test.go
stat/sampleuv/example_rate_test.go
@@ -6,13 +6,6 @@ package sampleuv
import "gonum.org/v1/gonum/stat/distuv"
-func max(a, b int) int {
- if a < b {
- return b
- }
- return a
-}
-
func ExampleMetropolisHastings_samplingRate() {
// See Burnin example for a description of these quantities.
n := 1000

MODIFY
stat/spatial/spatial_areal_example_test.go
stat/spatial/spatial_areal_example_test.go
@@ -31,7 +31,7 @@ func (e Euclid) At(i, j int) float64 {
y := float64(j/e.x - i/e.x)
return 1 / math.Hypot(x, y)
}
-func (e Euclid) T() mat.Matrix { return mat.Transpose{e} }
+func (e Euclid) T() mat.Matrix { return mat.Transpose{Matrix: e} }
func ExampleGlobalMoransI_areal() {
locality := Euclid{10, 10}

stat: clean up lint