From 7af70dd79622dbf392b22c083cfbb2fde4372442 Mon Sep 17 00:00:00 2001 From: kortschak Date: Sat, 17 Jun 2017 20:50:09 +0930 Subject: [PATCH] all: fix many go vet errors --- graph/community/bisect_test.go | 8 ++++---- graph/graphs/gen/small_world_test.go | 2 +- graph/internal/set/set_test.go | 14 +++++++------- graph/path/a_star_test.go | 6 +++--- graph/path/bellman_ford_moore_test.go | 2 +- graph/path/dijkstra_test.go | 2 +- graph/path/dynamic/dstarlite_test.go | 2 +- graph/topo/bron_kerbosch_test.go | 4 ++-- lapack/testlapack/dgebal.go | 4 ++-- lapack/testlapack/dgeev.go | 2 +- lapack/testlapack/dhseqr.go | 2 +- lapack/testlapack/dlaexc.go | 2 +- lapack/testlapack/dlaqp2.go | 2 +- lapack/testlapack/dlaqps.go | 2 +- lapack/testlapack/dlaqr23.go | 4 ++-- lapack/testlapack/dlaset.go | 6 +++--- lapack/testlapack/dlatrs.go | 4 ++-- mat/cholesky_example_test.go | 2 +- mat/hogsvd_example_test.go | 2 +- mat/io_test.go | 4 ++-- mat/symmetric_test.go | 2 +- optimize/convex/lp/simplex_test.go | 3 --- optimize/linesearcher_test.go | 4 ++-- optimize/local.go | 1 - stat/pca_example_test.go | 2 +- stat/sampleuv/weighted_test.go | 10 +++++----- 26 files changed, 47 insertions(+), 51 deletions(-) diff --git a/graph/community/bisect_test.go b/graph/community/bisect_test.go index 210ab7f2..4c2498ee 100644 --- a/graph/community/bisect_test.go +++ b/graph/community/bisect_test.go @@ -154,7 +154,7 @@ func TestProfileUndirected(t *testing.T) { t.Errorf("%s: failed to recover low end score: got: %v want: %v", test.name, score, d.Score) } if i != 0 && d.Score >= p[i-1].Score { - t.Errorf("%s: not monotonically decreasing: ", test.name, p[i-1], d) + t.Errorf("%s: not monotonically decreasing: %v -> %v", test.name, p[i-1], d) } } } @@ -192,7 +192,7 @@ func TestProfileDirected(t *testing.T) { t.Errorf("%s: failed to recover low end score: got: %v want: %v", test.name, score, d.Score) } if i != 0 && d.Score >= p[i-1].Score { - t.Errorf("%s: not monotonically decreasing: ", test.name, p[i-1], d) + t.Errorf("%s: not monotonically decreasing: %v -> %v", test.name, p[i-1], d) } } } @@ -227,7 +227,7 @@ func TestProfileUndirectedMultiplex(t *testing.T) { t.Errorf("%s: failed to recover low end score: got: %v want: %v", test.name, score, d.Score) } if i != 0 && d.Score >= p[i-1].Score { - t.Errorf("%s: not monotonically decreasing: ", test.name, p[i-1], d) + t.Errorf("%s: not monotonically decreasing: %v -> %v", test.name, p[i-1], d) } } } @@ -262,7 +262,7 @@ func TestProfileDirectedMultiplex(t *testing.T) { t.Errorf("%s: failed to recover low end score: got: %v want: %v", test.name, score, d.Score) } if i != 0 && d.Score >= p[i-1].Score { - t.Errorf("%s: not monotonically decreasing: ", test.name, p[i-1], d) + t.Errorf("%s: not monotonically decreasing: %v -> %v", test.name, p[i-1], d) } } } diff --git a/graph/graphs/gen/small_world_test.go b/graph/graphs/gen/small_world_test.go index 8caa1787..dd413a76 100644 --- a/graph/graphs/gen/small_world_test.go +++ b/graph/graphs/gen/small_world_test.go @@ -58,7 +58,7 @@ func TestNavigableSmallWorldDirected(t *testing.T) { n *= d } if err != nil { - t.Fatalf("unexpected error: dims=%v n=%d, p=%d, q=%d, r=%v, r=%v: %v", dims, n, p, q, r, err) + t.Fatalf("unexpected error: dims=%v n=%d, p=%d, q=%d, r=%v: %v", dims, n, p, q, r, err) } if g.addSelfLoop { t.Errorf("unexpected self edge: dims=%v n=%d, p=%d, q=%d, r=%v", dims, n, p, q, r) diff --git a/graph/internal/set/set_test.go b/graph/internal/set/set_test.go index bc8de46f..13984e14 100644 --- a/graph/internal/set/set_test.go +++ b/graph/internal/set/set_test.go @@ -85,7 +85,7 @@ func TestAdd(t *testing.T) { for e, n := range s { if e != n.ID() { - t.Error("Element ID did not match key: %d != %d", e, n.ID()) + t.Errorf("Element ID did not match key: %d != %d", e, n.ID()) } } } @@ -229,7 +229,7 @@ func TestUnionSame(t *testing.T) { for i, s := range []Nodes{a, b, c} { for e, n := range s { if e != n.ID() { - t.Error("Element ID did not match key in s%d: %d != %d", i+1, e, n.ID()) + t.Errorf("Element ID did not match key in s%d: %d != %d", i+1, e, n.ID()) } } } @@ -266,7 +266,7 @@ func TestUnionDiff(t *testing.T) { for i, s := range []Nodes{a, b, c} { for e, n := range s { if e != n.ID() { - t.Error("Element ID did not match key in s%d: %d != %d", i+1, e, n.ID()) + t.Errorf("Element ID did not match key in s%d: %d != %d", i+1, e, n.ID()) } } } @@ -304,7 +304,7 @@ func TestUnionOverlapping(t *testing.T) { for i, s := range []Nodes{a, b, c} { for e, n := range s { if e != n.ID() { - t.Error("Element ID did not match key in s%d: %d != %d", i+1, e, n.ID()) + t.Errorf("Element ID did not match key in s%d: %d != %d", i+1, e, n.ID()) } } } @@ -334,7 +334,7 @@ func TestIntersectSame(t *testing.T) { for i, s := range []Nodes{a, b, c} { for e, n := range s { if e != n.ID() { - t.Error("Element ID did not match key in s%d: %d != %d", i+1, e, n.ID()) + t.Errorf("Element ID did not match key in s%d: %d != %d", i+1, e, n.ID()) } } } @@ -368,7 +368,7 @@ func TestIntersectDiff(t *testing.T) { for i, s := range []Nodes{a, b, c} { for e, n := range s { if e != n.ID() { - t.Error("Element ID did not match key in s%d: %d != %d", i+1, e, n.ID()) + t.Errorf("Element ID did not match key in s%d: %d != %d", i+1, e, n.ID()) } } } @@ -406,7 +406,7 @@ func TestIntersectOverlapping(t *testing.T) { for i, s := range []Nodes{a, b, c} { for e, n := range s { if e != n.ID() { - t.Error("Element ID did not match key in s%d: %d != %d", i+1, e, n.ID()) + t.Errorf("Element ID did not match key in s%d: %d != %d", i+1, e, n.ID()) } } } diff --git a/graph/path/a_star_test.go b/graph/path/a_star_test.go index 315dc8a8..2d28c54f 100644 --- a/graph/path/a_star_test.go +++ b/graph/path/a_star_test.go @@ -132,7 +132,7 @@ func TestAStar(t *testing.T) { p, cost := pt.To(simple.Node(test.t)) if !topo.IsPathIn(test.g, p) { - t.Error("got path that is not path in input graph for %q", test.name) + t.Errorf("got path that is not path in input graph for %q", test.name) } bfp, ok := BellmanFordFrom(simple.Node(test.s), test.g) @@ -199,7 +199,7 @@ func TestExhaustiveAStar(t *testing.T) { gotPath, gotWeight := pt.To(goal) wantPath, wantWeight, _ := ps.Between(start, goal) if gotWeight != wantWeight { - t.Errorf("unexpected path weight from %v to %v result: got:%s want:%s", + t.Errorf("unexpected path weight from %v to %v result: got:%f want:%f", start, goal, gotWeight, wantWeight) } if !reflect.DeepEqual(gotPath, wantPath) { @@ -272,7 +272,7 @@ func TestAStarNullHeuristic(t *testing.T) { } if pt.From().ID() != test.Query.From().ID() { - t.Fatalf("%q: unexpected from node ID: got:%d want:%d", pt.From().ID(), test.Query.From().ID()) + t.Fatalf("%q: unexpected from node ID: got:%d want:%d", test.Name, pt.From().ID(), test.Query.From().ID()) } p, weight := pt.To(test.Query.To()) diff --git a/graph/path/bellman_ford_moore_test.go b/graph/path/bellman_ford_moore_test.go index 69307d6c..62401811 100644 --- a/graph/path/bellman_ford_moore_test.go +++ b/graph/path/bellman_ford_moore_test.go @@ -32,7 +32,7 @@ func TestBellmanFordFrom(t *testing.T) { } if pt.From().ID() != test.Query.From().ID() { - t.Fatalf("%q: unexpected from node ID: got:%d want:%d", pt.From().ID(), test.Query.From().ID()) + t.Fatalf("%q: unexpected from node ID: got:%d want:%d", test.Name, pt.From().ID(), test.Query.From().ID()) } p, weight := pt.To(test.Query.To()) diff --git a/graph/path/dijkstra_test.go b/graph/path/dijkstra_test.go index f971aa39..0206f4a5 100644 --- a/graph/path/dijkstra_test.go +++ b/graph/path/dijkstra_test.go @@ -44,7 +44,7 @@ func TestDijkstraFrom(t *testing.T) { } if pt.From().ID() != test.Query.From().ID() { - t.Fatalf("%q: unexpected from node ID: got:%d want:%d", pt.From().ID(), test.Query.From().ID()) + t.Fatalf("%q: unexpected from node ID: got:%d want:%d", test.Name, pt.From().ID(), test.Query.From().ID()) } p, weight := pt.To(test.Query.To()) diff --git a/graph/path/dynamic/dstarlite_test.go b/graph/path/dynamic/dstarlite_test.go index 48356da2..1fdd675a 100644 --- a/graph/path/dynamic/dstarlite_test.go +++ b/graph/path/dynamic/dstarlite_test.go @@ -62,7 +62,7 @@ func TestDStarLiteNullHeuristic(t *testing.T) { p, weight := d.Path() if !math.IsInf(weight, 1) && p[0].ID() != test.Query.From().ID() { - t.Fatalf("%q: unexpected from node ID: got:%d want:%d", p[0].ID(), test.Query.From().ID()) + t.Fatalf("%q: unexpected from node ID: got:%d want:%d", test.Name, p[0].ID(), test.Query.From().ID()) } if weight != test.Weight { t.Errorf("%q: unexpected weight from Between: got:%f want:%f", diff --git a/graph/topo/bron_kerbosch_test.go b/graph/topo/bron_kerbosch_test.go index a83b8db8..2acfb42c 100644 --- a/graph/topo/bron_kerbosch_test.go +++ b/graph/topo/bron_kerbosch_test.go @@ -74,7 +74,7 @@ func TestVertexOrdering(t *testing.T) { } sort.Ints(got) if !reflect.DeepEqual(got, want) { - t.Errorf("unexpected %d-core for test %d:\ngot: %v\nwant:%v", got, test.wantCore) + t.Errorf("unexpected %d-core for test %d:\ngot: %v\nwant:%v", k, i, got, test.wantCore) } for j, n := range core[k] { @@ -82,7 +82,7 @@ func TestVertexOrdering(t *testing.T) { } sort.Ints(got) if !reflect.DeepEqual(got, want) { - t.Errorf("unexpected %d-core for test %d:\ngot: %v\nwant:%v", got, test.wantCore) + t.Errorf("unexpected %d-core for test %d:\ngot: %v\nwant:%v", k, i, got, test.wantCore) } offset += len(want) } diff --git a/lapack/testlapack/dgebal.go b/lapack/testlapack/dgebal.go index eecd6914..b07ababf 100644 --- a/lapack/testlapack/dgebal.go +++ b/lapack/testlapack/dgebal.go @@ -56,10 +56,10 @@ func testDgebal(t *testing.T, impl Dgebaler, job lapack.Job, a blas64.General) { if n == 0 { if ilo != 0 { - t.Errorf("%v: unexpected ilo when n=0. Want 0, got %v", prefix, n, ilo) + t.Errorf("%v: unexpected ilo when n=0. Want 0, got %v", prefix, ilo) } if ihi != -1 { - t.Errorf("%v: unexpected ihi when n=0. Want -1, got %v", prefix, n, ihi) + t.Errorf("%v: unexpected ihi when n=0. Want -1, got %v", prefix, ihi) } return } diff --git a/lapack/testlapack/dgeev.go b/lapack/testlapack/dgeev.go index 9b3d8fc1..3ad86c1e 100644 --- a/lapack/testlapack/dgeev.go +++ b/lapack/testlapack/dgeev.go @@ -606,7 +606,7 @@ func testDgeev(t *testing.T, impl Dgeever, tc string, test dgeevTest, jobvl lapa } if first > 0 { - t.Log("%v: all eigenvalues haven't been computed, first=%v", prefix, first) + t.Logf("%v: all eigenvalues haven't been computed, first=%v", prefix, first) } // Check that conjugate pair eigevalues are ordered correctly. diff --git a/lapack/testlapack/dhseqr.go b/lapack/testlapack/dhseqr.go index a12102b4..85ae5234 100644 --- a/lapack/testlapack/dhseqr.go +++ b/lapack/testlapack/dhseqr.go @@ -78,7 +78,7 @@ func testDhseqr(t *testing.T, impl Dhseqrer, i int, test dhseqrTest, job lapack. prefix := fmt.Sprintf("Case %v: job=%v, compz=%v, n=%v, ilo=%v, ihi=%v, extra=%v, optwk=%v", i, job, compz, n, ilo, ihi, extra, optwork) if unconverged > 0 { - t.Log("%v: Dhseqr did not compute all eigenvalues. unconverged=%v", prefix, unconverged) + t.Logf("%v: Dhseqr did not compute all eigenvalues. unconverged=%v", prefix, unconverged) if unconverged <= ilo { t.Fatalf("%v: 0 < unconverged <= ilo", prefix) } diff --git a/lapack/testlapack/dlaexc.go b/lapack/testlapack/dlaexc.go index 23ac3303..e69f41d8 100644 --- a/lapack/testlapack/dlaexc.go +++ b/lapack/testlapack/dlaexc.go @@ -90,7 +90,7 @@ func testDlaexc(t *testing.T, impl Dlaexcer, wantq bool, n, j1, n1, n2, extra in if n1 == 1 && n2 == 1 { t.Errorf("%v: unexpected failure", prefix) } else { - t.Logf("%v: Dlaexc returned false") + t.Logf("%v: Dlaexc returned false", prefix) } } diff --git a/lapack/testlapack/dlaqp2.go b/lapack/testlapack/dlaqp2.go index 5ccfe996..230b2ecc 100644 --- a/lapack/testlapack/dlaqp2.go +++ b/lapack/testlapack/dlaqp2.go @@ -63,7 +63,7 @@ func Dlaqp2Test(t *testing.T, impl Dlaqp2er) { impl.Dlaqp2(m, n, test.offset, a.Data, a.Stride, jpiv, tau, vn1, vn2, work) - prefix := fmt.Sprintf("Case %v (offset=%t,m=%v,n=%v,extra=%v)", ti, test.offset, m, n, extra) + prefix := fmt.Sprintf("Case %v (offset=%d,m=%v,n=%v,extra=%v)", ti, test.offset, m, n, extra) if !generalOutsideAllNaN(a) { t.Errorf("%v: out-of-range write to A", prefix) } diff --git a/lapack/testlapack/dlaqps.go b/lapack/testlapack/dlaqps.go index edf19378..7bb4800b 100644 --- a/lapack/testlapack/dlaqps.go +++ b/lapack/testlapack/dlaqps.go @@ -59,7 +59,7 @@ func DlaqpsTest(t *testing.T, impl Dlaqpser) { kb := impl.Dlaqps(m, n, test.offset, test.nb, a.Data, a.Stride, jpiv, tau, vn1, vn2, auxv, f.Data, f.Stride) - prefix := fmt.Sprintf("Case %v (offset=%t,m=%v,n=%v,extra=%v)", ti, test.offset, m, n, extra) + prefix := fmt.Sprintf("Case %v (offset=%d,m=%v,n=%v,extra=%v)", ti, test.offset, m, n, extra) if !generalOutsideAllNaN(a) { t.Errorf("%v: out-of-range write to A", prefix) } diff --git a/lapack/testlapack/dlaqr23.go b/lapack/testlapack/dlaqr23.go index 236b3519..e55d2bc0 100644 --- a/lapack/testlapack/dlaqr23.go +++ b/lapack/testlapack/dlaqr23.go @@ -282,10 +282,10 @@ func testDlaqr23(t *testing.T, impl Dlaqr23er, test dlaqr23Test, opt bool, recur t.Errorf("%v: out-of-range write to WV\n%v", prefix, wv.Data) } if !isAllNaN(sr[:kbot-nd-ns+1]) || !isAllNaN(sr[kbot+1:]) { - t.Errorf("%v: out-of-range write to sr") + t.Errorf("%v: out-of-range write to sr", prefix) } if !isAllNaN(si[:kbot-nd-ns+1]) || !isAllNaN(si[kbot+1:]) { - t.Errorf("%v: out-of-range write to si") + t.Errorf("%v: out-of-range write to si", prefix) } if !isUpperHessenberg(h) { diff --git a/lapack/testlapack/dlaset.go b/lapack/testlapack/dlaset.go index 2b70b7af..f0af77f5 100644 --- a/lapack/testlapack/dlaset.go +++ b/lapack/testlapack/dlaset.go @@ -49,14 +49,14 @@ func DlasetTest(t *testing.T, impl Dlaseter) { } for i := 0; i < min(m, n); i++ { if a.Data[i*a.Stride+i] != beta { - t.Errorf("%v: unexpected diagonal of A") + t.Errorf("%v: unexpected diagonal of A", prefix) } } if uplo == blas.Upper || uplo == blas.All { for i := 0; i < m; i++ { for j := i + 1; j < n; j++ { if a.Data[i*a.Stride+j] != alpha { - t.Errorf("%v: unexpected upper triangle of A") + t.Errorf("%v: unexpected upper triangle of A", prefix) } } } @@ -65,7 +65,7 @@ func DlasetTest(t *testing.T, impl Dlaseter) { for i := 1; i < m; i++ { for j := 0; j < min(i, n); j++ { if a.Data[i*a.Stride+j] != alpha { - t.Errorf("%v: unexpected lower triangle of A") + t.Errorf("%v: unexpected lower triangle of A", prefix) } } } diff --git a/lapack/testlapack/dlatrs.go b/lapack/testlapack/dlatrs.go index b6800895..d2d77897 100644 --- a/lapack/testlapack/dlatrs.go +++ b/lapack/testlapack/dlatrs.go @@ -68,7 +68,7 @@ func testDlatrs(t *testing.T, impl Dlatrser, imat int, uplo blas.Uplo, trans bla if hasNaN { t.Errorf("%v: unexpected NaN (scale=%v,normin=false)", prefix, scale) } else if resid > tol { - t.Errorf("%v: residual %v too large (scale=%v,normin=false)", prefix, scale) + t.Errorf("%v: residual %v too large (scale=%v,normin=false)", prefix, resid, scale) } // Call Dlatrs with normin=true because cnorm has been filled. @@ -78,7 +78,7 @@ func testDlatrs(t *testing.T, impl Dlatrser, imat int, uplo blas.Uplo, trans bla if hasNaN { t.Errorf("%v: unexpected NaN (scale=%v,normin=true)", prefix, scale) } else if resid > tol { - t.Errorf("%v: residual %v too large (scale=%v,normin=true)", prefix, scale) + t.Errorf("%v: residual %v too large (scale=%v,normin=true)", prefix, resid, scale) } } diff --git a/mat/cholesky_example_test.go b/mat/cholesky_example_test.go index 7bbaf5af..8cf35504 100644 --- a/mat/cholesky_example_test.go +++ b/mat/cholesky_example_test.go @@ -69,7 +69,7 @@ func ExampleCholesky() { // ⎣-16 -24 17 73⎦ } -func ExampleCholeskySymRankOne() { +func ExampleCholesky_SymRankOne() { a := mat.NewSymDense(4, []float64{ 1, 1, 1, 1, 0, 2, 3, 4, diff --git a/mat/hogsvd_example_test.go b/mat/hogsvd_example_test.go index fd07e085..a1651448 100644 --- a/mat/hogsvd_example_test.go +++ b/mat/hogsvd_example_test.go @@ -20,7 +20,7 @@ func ExampleHOGSVD() { var gsvd mat.HOGSVD ok := gsvd.Factorize(FAO.Africa, FAO.Asia, FAO.LatinAmericaCaribbean, FAO.Oceania) if !ok { - log.Fatal("HOGSVD factorization failed: %v", gsvd.Err()) + log.Fatalf("HOGSVD factorization failed: %v", gsvd.Err()) } for i, n := range []string{"Africa", "Asia", "Latin America/Caribbean", "Oceania"} { diff --git a/mat/io_test.go b/mat/io_test.go index faec239b..25ffbdef 100644 --- a/mat/io_test.go +++ b/mat/io_test.go @@ -271,7 +271,7 @@ func TestDenseIORoundTrip(t *testing.T) { } if !bytes.Equal(buf, wbuf.Bytes()) { - t.Errorf("encoding via MarshalBinary and MarshalBinaryTo differ:\nwith-stream: %q\n no-stream: %q\n", + t.Errorf("r/w test #%d encoding via MarshalBinary and MarshalBinaryTo differ:\nwith-stream: %q\n no-stream: %q\n", i, wbuf.Bytes(), buf, ) } @@ -532,7 +532,7 @@ func TestVectorIORoundTrip(t *testing.T) { } if !bytes.Equal(buf, wbuf.Bytes()) { - t.Errorf("encoding via MarshalBinary and MarshalBinaryTo differ:\nwith-stream: %q\n no-stream: %q\n", + t.Errorf("test #%d encoding via MarshalBinary and MarshalBinaryTo differ:\nwith-stream: %q\n no-stream: %q\n", i, wbuf.Bytes(), buf, ) } diff --git a/mat/symmetric_test.go b/mat/symmetric_test.go index e1d8b697..0a43dc5a 100644 --- a/mat/symmetric_test.go +++ b/mat/symmetric_test.go @@ -687,7 +687,7 @@ func TestPowPSD(t *testing.T) { dense.Pow(&mat, pow) if !EqualApprox(&sym, &dense, 1e-10) { - t.Errorf("Dim %d: pow mismatch") + t.Errorf("Dim %d: pow mismatch", dim) } } } diff --git a/optimize/convex/lp/simplex_test.go b/optimize/convex/lp/simplex_test.go index 33f84551..1538b036 100644 --- a/optimize/convex/lp/simplex_test.go +++ b/optimize/convex/lp/simplex_test.go @@ -5,7 +5,6 @@ package lp import ( - "fmt" "math/rand" "testing" @@ -241,8 +240,6 @@ func testSimplex(t *testing.T, initialBasic []int, c []float64, a mat.Matrix, b // b^T *nu instead of maximizing -b^T*nu), so flip it back. if errPrimal == nil { if errDual != nil { - fmt.Println("errDual", errDual) - panic("here") t.Errorf("Primal feasible but dual errored: %s", errDual) } dualOpt *= -1 diff --git a/optimize/linesearcher_test.go b/optimize/linesearcher_test.go index e1693108..f1def408 100644 --- a/optimize/linesearcher_test.go +++ b/optimize/linesearcher_test.go @@ -84,7 +84,7 @@ func testLinesearcher(t *testing.T, ls Linesearcher, decrease, curvature float64 op := ls.Init(f0, g0, initStep) if !op.isEvaluation() { - t.Errorf("%v: Linesearcher.Init returned non-evaluating operation %v", op) + t.Errorf("%v: Linesearcher.Init returned non-evaluating operation %v", prefix, op) continue } @@ -115,7 +115,7 @@ func testLinesearcher(t *testing.T, ls Linesearcher, decrease, curvature float64 f = prob.f(step) g = prob.g(step) default: - t.Errorf("%v: Linesearcher returned an invalid operation %v", op) + t.Errorf("%v: Linesearcher returned an invalid operation %v", prefix, op) break loop } diff --git a/optimize/local.go b/optimize/local.go index 706229db..241e80fe 100644 --- a/optimize/local.go +++ b/optimize/local.go @@ -162,7 +162,6 @@ func minimize(p *Problem, method Method, settings *Settings, stats *Stats, optLo return } } - panic("optimize: unreachable") } func getDefaultMethod(p *Problem) Method { diff --git a/stat/pca_example_test.go b/stat/pca_example_test.go index 45341317..1d38b111 100644 --- a/stat/pca_example_test.go +++ b/stat/pca_example_test.go @@ -11,7 +11,7 @@ import ( "gonum.org/v1/gonum/stat" ) -func ExamplePrincipalComponents() { +func ExamplePC() { // iris is a truncated sample of the Fisher's Iris dataset. n := 10 d := 4 diff --git a/stat/sampleuv/weighted_test.go b/stat/sampleuv/weighted_test.go index 24ed9555..ddaf6400 100644 --- a/stat/sampleuv/weighted_test.go +++ b/stat/sampleuv/weighted_test.go @@ -162,11 +162,11 @@ func TestWeightZero(t *testing.T) { t.Errorf("unexpected selection rate for zero-weighted item: got: %v want:%v", f[6], 0) } if reflect.DeepEqual(f[:6], obt[:6]) { - t.Fatal("unexpected selection: too few elements chosen in range:\ngot: %v\nwant:%v", + t.Fatalf("unexpected selection: too few elements chosen in range:\ngot: %v\nwant:%v", f[:6], obt[:6]) } if reflect.DeepEqual(f[7:], obt[7:]) { - t.Fatal("unexpected selection: too few elements chosen in range:\ngot: %v\nwant:%v", + t.Fatalf("unexpected selection: too few elements chosen in range:\ngot: %v\nwant:%v", f[7:], obt[7:]) } } @@ -217,11 +217,11 @@ func TestWeightIncrease(t *testing.T) { t.Errorf("unexpected selection rate for re-weighted item: got: %v want:%v", f[6], f[9]) } if reflect.DeepEqual(f[:6], obt[:6]) { - t.Fatal("unexpected selection: too many elements chosen in range:\ngot: %v\nwant:%v", + t.Fatalf("unexpected selection: too many elements chosen in range:\ngot: %v\nwant:%v", f[:6], obt[:6]) } if reflect.DeepEqual(f[7:], obt[7:]) { - t.Fatal("unexpected selection: too many elements chosen in range:\ngot: %v\nwant:%v", + t.Fatalf("unexpected selection: too many elements chosen in range:\ngot: %v\nwant:%v", f[7:], obt[7:]) } } @@ -253,7 +253,7 @@ func TestWeightedNoResample(t *testing.T) { item, ok := ts.Take() if !ok { if c != n { - t.Errorf("unexpected number of items: got: %d want: %d", c, n) + t.Errorf("unexpected number of items: got: %d want: %d", c, int(n)) } break }