9ff5e1e878a94c52944c03654242e11fd26deb6a,tests/samplers_tests/tpe_tests/test_sampler.py,,test_sample_relative_misc_arguments,#,147

Before Change




def test_sample_relative_misc_arguments() -> None:
    warnings.simplefilter("ignore", optuna.exceptions.ExperimentalWarning)

    study = optuna.create_study()
    dist = optuna.distributions.UniformDistribution(1.0, 100.0)
    past_trials = [frozen_trial_factory(i, dist=dist) for i in range(1, 40)]

After Change


        suggestion = sampler.sample_relative(study, trial, {"param-a": dist})

    // Test misc. parameters.
    with warnings.catch_warnings():
        warnings.simplefilter("ignore", optuna.exceptions.ExperimentalWarning)
        sampler = TPESampler(n_ei_candidates=13, n_startup_trials=5, seed=0, multivariate=True)
    with patch.object(study._storage, "get_all_trials", return_value=past_trials):
        assert sampler.sample_relative(study, trial, {"param-a": dist}) != suggestion

    with warnings.catch_warnings():
        warnings.simplefilter("ignore", optuna.exceptions.ExperimentalWarning)
        sampler = TPESampler(gamma=lambda _: 5, n_startup_trials=5, seed=0, multivariate=True)
    with patch.object(study._storage, "get_all_trials", return_value=past_trials):
        assert sampler.sample_relative(study, trial, {"param-a": dist}) != suggestion

    with warnings.catch_warnings():
        warnings.simplefilter("ignore", optuna.exceptions.ExperimentalWarning)
        sampler = TPESampler(
            weights=lambda n: np.asarray([i ** 2 + 1 for i in range(n)]),
            n_startup_trials=5,
            seed=0,
            multivariate=True,
        )
    with patch.object(study._storage, "get_all_trials", return_value=past_trials):
        assert sampler.sample_relative(study, trial, {"param-a": dist}) != suggestion

Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 14

Instances


Project Name: pfnet/optuna
Commit Name: 9ff5e1e878a94c52944c03654242e11fd26deb6a
Time: 2020-09-16
Author: imamura@ms.k.u-tokyo.ac.jp
File Name: tests/samplers_tests/tpe_tests/test_sampler.py
Class Name:
Method Name: test_sample_relative_misc_arguments


Project Name: pfnet/optuna
Commit Name: 9ff5e1e878a94c52944c03654242e11fd26deb6a
Time: 2020-09-16
Author: imamura@ms.k.u-tokyo.ac.jp
File Name: tests/samplers_tests/tpe_tests/test_sampler.py
Class Name:
Method Name: test_sample_relative_misc_arguments


Project Name: pfnet/optuna
Commit Name: 9ff5e1e878a94c52944c03654242e11fd26deb6a
Time: 2020-09-16
Author: imamura@ms.k.u-tokyo.ac.jp
File Name: tests/samplers_tests/tpe_tests/test_sampler.py
Class Name:
Method Name: test_sample_relative_seed_fix


Project Name: pfnet/optuna
Commit Name: 9ff5e1e878a94c52944c03654242e11fd26deb6a
Time: 2020-09-16
Author: imamura@ms.k.u-tokyo.ac.jp
File Name: tests/samplers_tests/tpe_tests/test_sampler.py
Class Name:
Method Name: test_sample_relative_prior