all: fix many go vet errors

This commit is contained in:
kortschak
2017-06-17 20:50:09 +09:30
committed by Dan Kortschak
parent f990fc84b6
commit 7af70dd796
26 changed files with 47 additions and 51 deletions

View File

@@ -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)
}
}
}

View File

@@ -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)

View File

@@ -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())
}
}
}

View File

@@ -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())

View File

@@ -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())

View File

@@ -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())

View File

@@ -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",

View File

@@ -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)
}

View File

@@ -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
}

View File

@@ -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.

View File

@@ -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)
}

View File

@@ -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)
}
}

View File

@@ -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)
}

View File

@@ -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)
}

View File

@@ -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) {

View File

@@ -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)
}
}
}

View File

@@ -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)
}
}

View File

@@ -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,

View File

@@ -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"} {

View File

@@ -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,
)
}

View File

@@ -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)
}
}
}

View File

@@ -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

View File

@@ -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
}

View File

@@ -162,7 +162,6 @@ func minimize(p *Problem, method Method, settings *Settings, stats *Stats, optLo
return
}
}
panic("optimize: unreachable")
}
func getDefaultMethod(p *Problem) Method {

View File

@@ -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

View File

@@ -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
}