log hyperopt progress to stdout instead to the logger
This commit is contained in:
parent
403f59ef45
commit
f4077a51c1
@ -217,13 +217,13 @@ class Hyperopt(Backtesting):
|
||||
"""
|
||||
if results['loss'] < self.current_best_loss:
|
||||
self.current_best_loss = results['loss']
|
||||
log_msg = '{:5d}/{}: {}. Loss {:.5f}'.format(
|
||||
log_msg = '\n{:5d}/{}: {}. Loss {:.5f}'.format(
|
||||
results['current_tries'],
|
||||
results['total_tries'],
|
||||
results['result'],
|
||||
results['loss']
|
||||
)
|
||||
logger.info(log_msg)
|
||||
print(log_msg)
|
||||
else:
|
||||
print('.', end='')
|
||||
sys.stdout.flush()
|
||||
|
@ -124,7 +124,7 @@ def test_loss_calculation_has_limited_profit(init_hyperopt) -> None:
|
||||
assert under > correct
|
||||
|
||||
|
||||
def test_log_results_if_loss_improves(init_hyperopt, caplog) -> None:
|
||||
def test_log_results_if_loss_improves(init_hyperopt, capsys) -> None:
|
||||
hyperopt = _HYPEROPT
|
||||
hyperopt.current_best_loss = 2
|
||||
hyperopt.log_results(
|
||||
@ -135,7 +135,8 @@ def test_log_results_if_loss_improves(init_hyperopt, caplog) -> None:
|
||||
'result': 'foo'
|
||||
}
|
||||
)
|
||||
assert log_has(' 1/2: foo. Loss 1.00000', caplog.record_tuples)
|
||||
out, err = capsys.readouterr()
|
||||
assert ' 1/2: foo. Loss 1.00000'in out
|
||||
|
||||
|
||||
def test_no_log_if_loss_does_not_improve(init_hyperopt, caplog) -> None:
|
||||
|
Loading…
Reference in New Issue
Block a user