Skip to content

Commit 9fc18f8

Browse files
crazy25000Benouare
authored andcommitted
ENH: Add tqdm to skopt optimization (kernc#282)
* ENH: Add tqdm to skopt * MNT: Format long line * ENH: Pass max_tries as total len, update desc wording * ENH: Replace skopt class with variable * ENH: Pass single skopt callback directly instead of in a list * ENH: Check if tqdm object has update attr * MNT: Update tqdm description text * FMT: Use single quotes * MNT: Refactor pbar to use iter * MNT: Refactor to meet max line length * bikeshedding Fixes kernc#280
1 parent 44b8d54 commit 9fc18f8

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

backtesting/backtesting.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1357,7 +1357,8 @@ def _batch(seq):
13571357
with ProcessPoolExecutor() as executor:
13581358
futures = [executor.submit(Backtest._mp_task, backtest_uuid, i)
13591359
for i in range(len(param_batches))]
1360-
for future in _tqdm(as_completed(futures), total=len(futures)):
1360+
for future in _tqdm(as_completed(futures), total=len(futures),
1361+
desc='Backtest.optimize'):
13611362
batch_index, values = future.result()
13621363
for value, params in zip(values, param_batches[batch_index]):
13631364
heatmap[tuple(params.values())] = value
@@ -1425,9 +1426,11 @@ def _optimize_skopt() -> Union[pd.Series,
14251426

14261427
# np.inf/np.nan breaks sklearn, np.finfo(float).max breaks skopt.plots.plot_objective
14271428
INVALID = 1e300
1429+
progress = iter(_tqdm(repeat(None), total=max_tries, desc='Backtest.optimize'))
14281430

14291431
@use_named_args(dimensions=dimensions)
14301432
def objective_function(**params):
1433+
next(progress)
14311434
# Check constraints
14321435
# TODO: Adjust after https://github.com/scikit-optimize/scikit-optimize/pull/971
14331436
if not constraint(AttrDict(params)):

0 commit comments

Comments
 (0)