def test_bayesian_save_reload(tmp_dir):
    hps = hp_module.HyperParameters()
    hps.Choice('a', [1, 2], default=1)
    hps.Choice('b', [3, 4], default=3)
    hps.Choice('c', [5, 6], default=5)
    hps.Choice('d', [7, 8], default=7)
    hps.Choice('e', [9, 0], default=9)
    oracle = bo_module.BayesianOptimizationOracle(objective=kt.Objective('score', 'max'), max_trials=20, hyperparameters=hps)
    oracle._set_project_dir(tmp_dir, 'untitled')
    for _ in range(3):
        trial = oracle.create_trial('tuner_id')
        oracle.update_trial(trial.trial_id, {'score': 1.0})
        oracle.end_trial(trial.trial_id, 'COMPLETED')
    oracle.save()
    oracle = bo_module.BayesianOptimizationOracle(objective=kt.Objective('score', 'max'), max_trials=20, hyperparameters=hps)
    oracle._set_project_dir(tmp_dir, 'untitled')
    oracle.reload()
    for trial_id in range(3):
        trial = oracle.create_trial('tuner_id')
        oracle.update_trial(trial.trial_id, {'score': 1.0})
        oracle.end_trial(trial.trial_id, 'COMPLETED')
    assert (len(oracle.trials) == 6)
def test_bayesian_save_reload(tmp_dir):
    hps = hp_module.HyperParameters()
    hps.Choice('a', [1, 2], default=1)
    hps.Choice('b', [3, 4], default=3)
    hps.Choice('c', [5, 6], default=5)
    hps.Choice('d', [7, 8], default=7)
    hps.Choice('e', [9, 0], default=9)
    oracle = bo_module.BayesianOptimizationOracle(objective=kt.Objective('score', 'max'), max_trials=20, hyperparameters=hps)
    oracle._set_project_dir(tmp_dir, 'untitled')
    for _ in range(3):
        trial = oracle.create_trial('tuner_id')
        oracle.update_trial(trial.trial_id, {'score': 1.0})
        oracle.end_trial(trial.trial_id, 'COMPLETED')
    oracle.save()
    oracle = bo_module.BayesianOptimizationOracle(objective=kt.Objective('score', 'max'), max_trials=20, hyperparameters=hps)
    oracle._set_project_dir(tmp_dir, 'untitled')
    oracle.reload()
    for trial_id in range(3):
        trial = oracle.create_trial('tuner_id')
        oracle.update_trial(trial.trial_id, {'score': 1.0})
        oracle.end_trial(trial.trial_id, 'COMPLETED')
    assert (len(oracle.trials) == 6)