Skip to content

Commit f26753b

Browse files
authored
ENH: Add tqdm to skopt optimization (#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 #280
1 parent 2c47212 commit f26753b

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

backtesting/backtesting.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1352,7 +1352,8 @@ def _batch(seq):
13521352
with ProcessPoolExecutor() as executor:
13531353
futures = [executor.submit(Backtest._mp_task, backtest_uuid, i)
13541354
for i in range(len(param_batches))]
1355-
for future in _tqdm(as_completed(futures), total=len(futures)):
1355+
for future in _tqdm(as_completed(futures), total=len(futures),
1356+
desc='Backtest.optimize'):
13561357
batch_index, values = future.result()
13571358
for value, params in zip(values, param_batches[batch_index]):
13581359
heatmap[tuple(params.values())] = value
@@ -1420,9 +1421,11 @@ def _optimize_skopt() -> Union[pd.Series,
14201421

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

14241426
@use_named_args(dimensions=dimensions)
14251427
def objective_function(**params):
1428+
next(progress)
14261429
# Check constraints
14271430
# TODO: Adjust after https://github.com/scikit-optimize/scikit-optimize/pull/971
14281431
if not constraint(AttrDict(params)):

0 commit comments

Comments
 (0)