Log messages improved (plural/singular)
This commit is contained in:
parent
99db53417c
commit
067267f4cf
@ -23,7 +23,7 @@ from skopt import Optimizer
|
||||
from skopt.space import Dimension
|
||||
|
||||
from freqtrade.data.history import get_timeframe, trim_dataframe
|
||||
from freqtrade.misc import round_dict
|
||||
from freqtrade.misc import plural, round_dict
|
||||
from freqtrade.optimize.backtesting import Backtesting
|
||||
# Import IHyperOpt and IHyperOptLoss to allow unpickling classes from these modules
|
||||
from freqtrade.optimize.hyperopt_interface import IHyperOpt # noqa: F4
|
||||
@ -140,11 +140,12 @@ class Hyperopt:
|
||||
"""
|
||||
num_trials = len(self.trials)
|
||||
if num_trials > self.num_trials_saved:
|
||||
logger.info(f"Saving {num_trials} epochs.")
|
||||
logger.info(f"Saving {num_trials} {plural(num_trials, 'epoch')}.")
|
||||
dump(self.trials, self.trials_file)
|
||||
self.num_trials_saved = num_trials
|
||||
if final:
|
||||
logger.info(f"{num_trials} epochs were saved to '{self.trials_file}'.")
|
||||
logger.info(f"{num_trials} {plural(num_trials, 'epoch')} "
|
||||
f"saved to '{self.trials_file}'.")
|
||||
|
||||
def read_trials(self) -> List:
|
||||
"""
|
||||
|
@ -384,10 +384,11 @@ def test_save_trials_saves_trials(mocker, hyperopt, testdatadir, caplog) -> None
|
||||
trials = create_trials(mocker, hyperopt, testdatadir)
|
||||
mock_dump = mocker.patch('freqtrade.optimize.hyperopt.dump', return_value=None)
|
||||
hyperopt.trials = trials
|
||||
hyperopt.save_trials()
|
||||
hyperopt.save_trials(final=True)
|
||||
|
||||
trials_file = testdatadir / 'optimize' / 'ut_trials.pickle'
|
||||
assert log_has("Saving 1 epochs.", caplog)
|
||||
assert log_has("Saving 1 epoch.", caplog)
|
||||
assert log_has(f"1 epoch saved to '{trials_file}'.", caplog)
|
||||
mock_dump.assert_called_once()
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user