Skip to content

Commit 3ea00be

Browse files
committed
Bugfix: exit correctly when no Jacobian returned (e.g. initial objective value sufficiently small)
1 parent 21b2211 commit 3ea00be

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

dfols/solver.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,10 @@ def __str__(self):
7979
output += "Needed %g objective evaluations (at %g points)\n" % (self.nf, self.nx)
8080
if self.nruns > 1:
8181
output += "Did a total of %g runs\n" % self.nruns
82-
if np.size(self.jacobian) < 200:
82+
if self.jacobian is not None and np.size(self.jacobian) < 200:
8383
output += "Approximate Jacobian = %s\n" % str(self.jacobian)
84+
elif self.jacobian is None:
85+
output += "No Jacobian returned\n"
8486
else:
8587
output += "Not showing approximate Jacobian because it is too long; check self.jacobian\n"
8688
if self.diagnostic_info is not None:
@@ -985,7 +987,7 @@ def solve(objfun, x0, args=(), bounds=None, npt=None, rhobeg=None, rhoend=1e-8,
985987
exit_flag = exit_info.flag
986988
exit_msg = exit_info.message(with_stem=True)
987989
# Un-scale Jacobian
988-
if scaling_changes is not None:
990+
if scaling_changes is not None and jacmin is not None:
989991
for i in range(n):
990992
jacmin[:, i] = jacmin[:, i] / scaling_changes[1][i]
991993
results = OptimResults(remove_scaling(xmin, scaling_changes), rmin, fmin, jacmin, nf, nx, nruns, exit_flag, exit_msg)

0 commit comments

Comments
 (0)