Skip to content

Commit

Permalink
Respond to PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
btracey committed May 9, 2018
1 parent ad260b3 commit 4cd0359
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion optimize/local.go
Expand Up @@ -197,7 +197,7 @@ func (l *localGlobal) getStartingLocation(operation chan<- GlobalTask, result <-
task.F = l.Settings.InitialValue
if task.Gradient != nil {
g := l.Settings.InitialGradient
if task.Gradient != nil && g == nil {
if g == nil {
panic("optimize: initial gradient is nil")
}
if len(g) != l.dim {
Expand Down
10 changes: 5 additions & 5 deletions optimize/unconstrained_test.go
Expand Up @@ -1182,19 +1182,19 @@ func testLocal(t *testing.T, tests []unconstrainedTest, method Method) {

result, err := Local(test.p, test.x, settings, method)
if err != nil {
t.Errorf("Cas %d: error finding minimum (%v) for:\n%v", cas, err, test)
t.Errorf("Case %d: error finding minimum (%v) for:\n%v", cas, err, test)
continue
}
if result == nil {
t.Errorf("Cas %d: nil result without error for:\n%v", cas, test)
t.Errorf("Case %d: nil result without error for:\n%v", cas, test)
continue
}

// Check that the function value at the found optimum location is
// equal to result.F.
optF := test.p.Func(result.X)
if optF != result.F {
t.Errorf("Cas %d: Function value at the optimum location %v not equal to the returned value %v for:\n%v",
t.Errorf("Case %d: Function value at the optimum location %v not equal to the returned value %v for:\n%v",
cas, optF, result.F, test)
}
if result.Gradient != nil {
Expand All @@ -1203,14 +1203,14 @@ func testLocal(t *testing.T, tests []unconstrainedTest, method Method) {
test.p.Grad(g, result.X)

if !floats.Equal(result.Gradient, g) {
t.Errorf("Cas %d: Gradient at the optimum location not equal to the returned value for:\n%v", cas, test)
t.Errorf("Case %d: Gradient at the optimum location not equal to the returned value for:\n%v", cas, test)
}

optNorm := floats.Norm(g, math.Inf(1))
// Check that the norm of the gradient at the found optimum location is
// smaller than the tolerance.
if optNorm >= settings.GradientThreshold {
t.Errorf("Cas %d: Norm of the gradient at the optimum location %v not smaller than tolerance %v for:\n%v",
t.Errorf("Case %d: Norm of the gradient at the optimum location %v not smaller than tolerance %v for:\n%v",
cas, optNorm, settings.GradientThreshold, test)
}
}
Expand Down

0 comments on commit 4cd0359

Please sign in to comment.