280c4fb338bbb4cc967adfcc9714f05a606c6acf,tests/storages_tests/test_storages.py,,test_set_trial_intermediate_value,#Any#,461
Before Change
def test_set_trial_intermediate_value(storage_init_func):
// type: (Callable[[], BaseStorage]) -> None
storage = storage_init_func()
// Setup test across multiple studies and trials.
study_id = storage.create_new_study()
trial_id_1 = storage.create_new_trial(study_id)
After Change
@pytest.mark.parametrize("storage_mode", STORAGE_MODES)
def test_set_trial_intermediate_value(storage_mode: str) -> None:
with StorageSupplier(storage_mode) as storage:
// Setup test across multiple studies and trials.
study_id = storage.create_new_study()
trial_id_1 = storage.create_new_trial(study_id)
trial_id_2 = storage.create_new_trial(study_id)
trial_id_3 = storage.create_new_trial(storage.create_new_study())
// Test setting new values.
assert storage.set_trial_intermediate_value(trial_id_1, 0, 0.3)
assert storage.set_trial_intermediate_value(trial_id_1, 2, 0.4)
assert storage.set_trial_intermediate_value(trial_id_3, 0, 0.1)
assert storage.set_trial_intermediate_value(trial_id_3, 1, 0.4)
assert storage.set_trial_intermediate_value(trial_id_3, 2, 0.5)
assert storage.get_trial(trial_id_1).intermediate_values == {0: 0.3, 2: 0.4}
assert storage.get_trial(trial_id_2).intermediate_values == {}
assert storage.get_trial(trial_id_3).intermediate_values == {0: 0.1, 1: 0.4, 2: 0.5}
// Test setting existing step.
assert not storage.set_trial_intermediate_value(trial_id_1, 0, 0.3)
non_existent_trial_id = max(trial_id_1, trial_id_2, trial_id_3) + 1
with pytest.raises(KeyError):
storage.set_trial_intermediate_value(non_existent_trial_id, 0, 0.2)
storage.set_trial_state(trial_id_1, TrialState.COMPLETE)
// Cannot change values of finished trials.
with pytest.raises(RuntimeError):
storage.set_trial_intermediate_value(trial_id_1, 0, 0.2)
@pytest.mark.parametrize("storage_mode", STORAGE_MODES)
def test_get_trial_user_attrs(storage_mode: str) -> None:
with StorageSupplier(storage_mode) as storage:
In pattern: SUPERPATTERN
Frequency: 4
Non-data size: 15
Instances
Project Name: pfnet/optuna
Commit Name: 280c4fb338bbb4cc967adfcc9714f05a606c6acf
Time: 2020-04-29
Author: ytsmiling@gmail.com
File Name: tests/storages_tests/test_storages.py
Class Name:
Method Name: test_set_trial_intermediate_value
Project Name: pfnet/optuna
Commit Name: 280c4fb338bbb4cc967adfcc9714f05a606c6acf
Time: 2020-04-29
Author: ytsmiling@gmail.com
File Name: tests/storages_tests/test_storages.py
Class Name:
Method Name: test_set_trial_user_attr
Project Name: pfnet/optuna
Commit Name: 754642db5ff35be98e4b6fc3a17823482881cb27
Time: 2020-04-29
Author: ytsmiling@gmail.com
File Name: tests/storages_tests/test_storages.py
Class Name:
Method Name: test_set_trial_user_attr
Project Name: pfnet/optuna
Commit Name: 280c4fb338bbb4cc967adfcc9714f05a606c6acf
Time: 2020-04-29
Author: ytsmiling@gmail.com
File Name: tests/storages_tests/test_storages.py
Class Name:
Method Name: test_set_trial_intermediate_value
Project Name: pfnet/optuna
Commit Name: 754642db5ff35be98e4b6fc3a17823482881cb27
Time: 2020-04-29
Author: ytsmiling@gmail.com
File Name: tests/storages_tests/test_storages.py
Class Name:
Method Name: test_set_trial_intermediate_value