Skip to content

Commit

Permalink
log hyperopt progress to stdout instead to the logger
Browse files Browse the repository at this point in the history
  • Loading branch information
gcarq committed Mar 25, 2018
1 parent f374a06 commit 611bb52
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions freqtrade/optimize/hyperopt.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,13 +217,13 @@ def log_results(self, results) -> None:
"""
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()
Expand Down
5 changes: 3 additions & 2 deletions freqtrade/tests/optimize/test_hyperopt.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def test_loss_calculation_has_limited_profit() -> None:
assert under > correct


def test_log_results_if_loss_improves(caplog) -> None:
def test_log_results_if_loss_improves(capsys) -> None:
hyperopt = _HYPEROPT
hyperopt.current_best_loss = 2
hyperopt.log_results(
Expand All @@ -120,7 +120,8 @@ def test_log_results_if_loss_improves(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(caplog) -> None:
Expand Down

0 comments on commit 611bb52

Please sign in to comment.