all: quieten vet for unkeyed composite literals in test code

This commit is contained in:
Dan Kortschak
2018-09-01 22:40:25 +09:30
committed by Dan Kortschak
parent 3f94af49e6
commit 70492dcef1
6 changed files with 28 additions and 28 deletions

View File

@@ -741,7 +741,7 @@ var encodeTests = []struct {
}, },
{ {
g: directedNodeAttrGraphFrom(powerMethodGraph, [][]encoding.Attribute{ g: directedNodeAttrGraphFrom(powerMethodGraph, [][]encoding.Attribute{
2: {{"fontsize", "16"}, {"shape", "ellipse"}}, 2: {{Key: "fontsize", Value: "16"}, {Key: "shape", Value: "ellipse"}},
4: {}, 4: {},
}), }),
@@ -768,7 +768,7 @@ var encodeTests = []struct {
}, },
{ {
g: undirectedNodeAttrGraphFrom(powerMethodGraph, [][]encoding.Attribute{ g: undirectedNodeAttrGraphFrom(powerMethodGraph, [][]encoding.Attribute{
2: {{"fontsize", "16"}, {"shape", "ellipse"}}, 2: {{Key: "fontsize", Value: "16"}, {Key: "shape", Value: "ellipse"}},
4: {}, 4: {},
}), }),
@@ -795,7 +795,7 @@ var encodeTests = []struct {
}, },
{ {
g: directedNamedIDNodeAttrGraphFrom(powerMethodGraph, [][]encoding.Attribute{ g: directedNamedIDNodeAttrGraphFrom(powerMethodGraph, [][]encoding.Attribute{
2: {{"fontsize", "16"}, {"shape", "ellipse"}}, 2: {{Key: "fontsize", Value: "16"}, {Key: "shape", Value: "ellipse"}},
4: {}, 4: {},
}), }),
@@ -824,7 +824,7 @@ var encodeTests = []struct {
g: undirectedNamedIDNodeAttrGraphFrom(powerMethodGraph, [][]encoding.Attribute{ g: undirectedNamedIDNodeAttrGraphFrom(powerMethodGraph, [][]encoding.Attribute{
0: nil, 0: nil,
1: nil, 1: nil,
2: {{"fontsize", "16"}, {"shape", "ellipse"}}, 2: {{Key: "fontsize", Value: "16"}, {Key: "shape", Value: "ellipse"}},
3: nil, 3: nil,
4: {}, 4: {},
}), }),
@@ -896,9 +896,9 @@ var encodeTests = []struct {
}, },
{ {
g: directedEdgeAttrGraphFrom(powerMethodGraph, map[edge][]encoding.Attribute{ g: directedEdgeAttrGraphFrom(powerMethodGraph, map[edge][]encoding.Attribute{
{from: 0, to: 2}: {{"label", `"???"`}, {"style", "dashed"}}, {from: 0, to: 2}: {{Key: "label", Value: `"???"`}, {Key: "style", Value: "dashed"}},
{from: 2, to: 4}: {}, {from: 2, to: 4}: {},
{from: 3, to: 4}: {{"color", "red"}}, {from: 3, to: 4}: {{Key: "color", Value: "red"}},
}), }),
want: `digraph { want: `digraph {
@@ -924,9 +924,9 @@ var encodeTests = []struct {
}, },
{ {
g: undirectedEdgeAttrGraphFrom(powerMethodGraph, map[edge][]encoding.Attribute{ g: undirectedEdgeAttrGraphFrom(powerMethodGraph, map[edge][]encoding.Attribute{
{from: 0, to: 2}: {{"label", `"???"`}, {"style", "dashed"}}, {from: 0, to: 2}: {{Key: "label", Value: `"???"`}, {Key: "style", Value: "dashed"}},
{from: 2, to: 4}: {}, {from: 2, to: 4}: {},
{from: 3, to: 4}: {{"color", "red"}}, {from: 3, to: 4}: {{Key: "color", Value: "red"}},
}), }),
want: `graph { want: `graph {
@@ -997,8 +997,8 @@ var encodeTests = []struct {
{ {
g: directedPortedAttrGraphFrom(powerMethodGraph, g: directedPortedAttrGraphFrom(powerMethodGraph,
[][]encoding.Attribute{ [][]encoding.Attribute{
2: {{"shape", "record"}, {"label", `"<Two>English|<Zwei>German"`}}, 2: {{Key: "shape", Value: "record"}, {Key: "label", Value: `"<Two>English|<Zwei>German"`}},
4: {{"shape", "record"}, {"label", `"<Four>English|<Vier>German"`}}, 4: {{Key: "shape", Value: "record"}, {Key: "label", Value: `"<Four>English|<Vier>German"`}},
}, },
map[edge]portedEdge{ map[edge]portedEdge{
{from: 0, to: 1}: {fromCompass: "s"}, {from: 0, to: 1}: {fromCompass: "s"},
@@ -1037,8 +1037,8 @@ var encodeTests = []struct {
{ {
g: undirectedPortedAttrGraphFrom(powerMethodGraph, g: undirectedPortedAttrGraphFrom(powerMethodGraph,
[][]encoding.Attribute{ [][]encoding.Attribute{
2: {{"shape", "record"}, {"label", `"<Two>English|<Zwei>German"`}}, 2: {{Key: "shape", Value: "record"}, {Key: "label", Value: `"<Two>English|<Zwei>German"`}},
4: {{"shape", "record"}, {"label", `"<Four>English|<Vier>German"`}}, 4: {{Key: "shape", Value: "record"}, {Key: "label", Value: `"<Four>English|<Vier>German"`}},
}, },
map[edge]portedEdge{ map[edge]portedEdge{
{from: 0, to: 1}: {fromCompass: "s"}, {from: 0, to: 1}: {fromCompass: "s"},
@@ -1078,9 +1078,9 @@ var encodeTests = []struct {
// Handling graph attributes. // Handling graph attributes.
{ {
g: graphAttributer{Graph: undirectedEdgeAttrGraphFrom(powerMethodGraph, map[edge][]encoding.Attribute{ g: graphAttributer{Graph: undirectedEdgeAttrGraphFrom(powerMethodGraph, map[edge][]encoding.Attribute{
{from: 0, to: 2}: {{"label", `"???"`}, {"style", "dashed"}}, {from: 0, to: 2}: {{Key: "label", Value: `"???"`}, {Key: "style", Value: "dashed"}},
{from: 2, to: 4}: {}, {from: 2, to: 4}: {},
{from: 3, to: 4}: {{"color", "red"}}, {from: 3, to: 4}: {{Key: "color", Value: "red"}},
})}, })},
want: `graph { want: `graph {
@@ -1106,12 +1106,12 @@ var encodeTests = []struct {
}, },
{ {
g: graphAttributer{Graph: undirectedEdgeAttrGraphFrom(powerMethodGraph, map[edge][]encoding.Attribute{ g: graphAttributer{Graph: undirectedEdgeAttrGraphFrom(powerMethodGraph, map[edge][]encoding.Attribute{
{from: 0, to: 2}: {{"label", `"???"`}, {"style", "dashed"}}, {from: 0, to: 2}: {{Key: "label", Value: `"???"`}, {Key: "style", Value: "dashed"}},
{from: 2, to: 4}: {}, {from: 2, to: 4}: {},
{from: 3, to: 4}: {{"color", "red"}}, {from: 3, to: 4}: {{Key: "color", Value: "red"}},
}), }),
graph: []encoding.Attribute{{"rankdir", `"LR"`}}, graph: []encoding.Attribute{{Key: "rankdir", Value: `"LR"`}},
node: []encoding.Attribute{{"fontsize", "16"}, {"shape", "ellipse"}}, node: []encoding.Attribute{{Key: "fontsize", Value: "16"}, {Key: "shape", Value: "ellipse"}},
}, },
want: `graph { want: `graph {

View File

@@ -27,7 +27,7 @@ func (e *edgeWithPorts) ToPort() (string, string) {
func ExamplePorter() { func ExamplePorter() {
g := simple.NewUndirectedGraph() g := simple.NewUndirectedGraph()
g.SetEdge(&edgeWithPorts{ g.SetEdge(&edgeWithPorts{
Edge: simple.Edge{simple.Node(1), simple.Node(0)}, Edge: simple.Edge{F: simple.Node(1), T: simple.Node(0)},
fromPort: "p1", fromPort: "p1",
toPort: "p2", toPort: "p2",
}) })

View File

@@ -193,7 +193,7 @@ func (e *edge) SetLabel(l string) {
} }
func (e *edge) Attributes() []encoding.Attribute { func (e *edge) Attributes() []encoding.Attribute {
return []encoding.Attribute{{"label", e.label}} return []encoding.Attribute{{Key: "label", Value: e.label}}
} }
type attributes map[string]encoding.Attribute type attributes map[string]encoding.Attribute

View File

@@ -131,8 +131,8 @@ func twoSat(r io.Reader) (state map[string]bool, ok bool) {
} }
// Add implications to the graph. // Add implications to the graph.
g.SetEdge(simple.Edge{variables[0].negated(), variables[1]}) g.SetEdge(simple.Edge{F: variables[0].negated(), T: variables[1]})
g.SetEdge(simple.Edge{variables[1].negated(), variables[0]}) g.SetEdge(simple.Edge{F: variables[1].negated(), T: variables[0]})
} }
// Find implication inconsistencies. // Find implication inconsistencies.

View File

@@ -68,10 +68,10 @@ func testLinesearcher(t *testing.T, ls Linesearcher, decrease, curvature float64
for i, prob := range []linesearcherTest{ for i, prob := range []linesearcherTest{
newLinesearcherTest("Concave-to-the-right function", functions.ConcaveRight{}), newLinesearcherTest("Concave-to-the-right function", functions.ConcaveRight{}),
newLinesearcherTest("Concave-to-the-left function", functions.ConcaveLeft{}), newLinesearcherTest("Concave-to-the-left function", functions.ConcaveLeft{}),
newLinesearcherTest("Plassmann wiggly function (l=39, beta=0.01)", functions.Plassmann{39, 0.01}), newLinesearcherTest("Plassmann wiggly function (l=39, beta=0.01)", functions.Plassmann{L: 39, Beta: 0.01}),
newLinesearcherTest("Yanai-Ozawa-Kaneko function (beta1=0.001, beta2=0.001)", functions.YanaiOzawaKaneko{0.001, 0.001}), newLinesearcherTest("Yanai-Ozawa-Kaneko function (beta1=0.001, beta2=0.001)", functions.YanaiOzawaKaneko{Beta1: 0.001, Beta2: 0.001}),
newLinesearcherTest("Yanai-Ozawa-Kaneko function (beta1=0.01, beta2=0.001)", functions.YanaiOzawaKaneko{0.01, 0.001}), newLinesearcherTest("Yanai-Ozawa-Kaneko function (beta1=0.01, beta2=0.001)", functions.YanaiOzawaKaneko{Beta1: 0.01, Beta2: 0.001}),
newLinesearcherTest("Yanai-Ozawa-Kaneko function (beta1=0.001, beta2=0.01)", functions.YanaiOzawaKaneko{0.001, 0.01}), newLinesearcherTest("Yanai-Ozawa-Kaneko function (beta1=0.001, beta2=0.01)", functions.YanaiOzawaKaneko{Beta1: 0.001, Beta2: 0.01}),
} { } {
for _, initStep := range []float64{0.001, 0.1, 1, 10, 1000} { for _, initStep := range []float64{0.001, 0.1, 1, 10, 1000} {
prefix := fmt.Sprintf("test %d (%v started from %v)", i, prob.name, initStep) prefix := fmt.Sprintf("test %d (%v started from %v)", i, prob.name, initStep)

View File

@@ -26,8 +26,8 @@ func TestLatinHypercube(t *testing.T) {
src := rand.New(rand.NewSource(1)) src := rand.New(rand.NewSource(1))
for _, nSamples := range []int{1, 2, 5, 10, 20} { for _, nSamples := range []int{1, 2, 5, 10, 20} {
for _, dist := range []lhDist{ for _, dist := range []lhDist{
distmv.NewUniform([]distmv.Bound{{0, 3}}, src), distmv.NewUniform([]distmv.Bound{{Min: 0, Max: 3}}, src),
distmv.NewUniform([]distmv.Bound{{0, 3}, {-1, 5}, {-4, -1}}, src), distmv.NewUniform([]distmv.Bound{{Min: 0, Max: 3}, {Min: -1, Max: 5}, {Min: -4, Max: -1}}, src),
} { } {
dim := dist.Dim() dim := dist.Dim()
batch := mat.NewDense(nSamples, dim, nil) batch := mat.NewDense(nSamples, dim, nil)