Skip to content

Commit 4973e46

Browse files
committed
BUG: Fix minimize(method='shgo', disp=True) not printing progress
Contrary to the rest of SciPy [?], `scipy.optimize.shgo(disp=True)` uses logging instead of printing to stdout. Supply our own `disp=True` printout like with other methods. Refs: #4
1 parent 7ddd1c2 commit 4973e46

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

sambo/_shgo.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,14 @@ def shgo(
144144
lb=.5, ub=np.inf)
145145
assert constraints is None or isinstance(constraints, NonlinearConstraint)
146146

147+
if disp:
148+
user_callback = callback
149+
150+
def callback(res):
151+
print(f"{__package__}: SHGO nfev:{res.nfev}, fun:{np.min(res.funv):.5g}")
152+
if user_callback:
153+
user_callback(res)
154+
147155
wrapper = func = _ObjectiveFunctionWrapper(
148156
func, args=args, max_nfev=max_iter,
149157
callback=callback, tol=tol, n_iter_no_change=n_iter_no_change)

0 commit comments

Comments
 (0)