Пример #1
0
def test_optimal_trajectories_lt_samples(setup_param_file):
    parameter_file = setup_param_file
    problem = read_param_file(parameter_file)

    samples = 10
    num_levels = 4

    with raises(ValueError):
        sample(problem, samples, num_levels, optimal_trajectories=samples)
Пример #2
0
def test_even_num_levels_no_warning(setup_param_file_with_groups):
    parameter_file = setup_param_file_with_groups
    problem = read_param_file(parameter_file)
    with warnings.catch_warnings(record=True) as w:
        # Cause all warnings to always be triggered.
        warnings.simplefilter("always")
        # Trigger a warning.
        sample(problem, 10, num_levels=4)
        # Verify some things
        assert len(w) == 0
Пример #3
0
def test_odd_num_levels_raises_warning(setup_param_file_with_groups):
    parameter_file = setup_param_file_with_groups
    problem = read_param_file(parameter_file)
    with warnings.catch_warnings(record=True) as w:
        # Cause all warnings to always be triggered.
        warnings.simplefilter("always")
        # Trigger a warning.
        sample(problem, 10, num_levels=3)
        # Verify some things
        assert len(w) == 1
        assert issubclass(w[-1].category, UserWarning)
        assert "num_levels should be an even number, sample may be biased" in str(
            w[-1].message)
Пример #4
0
def test_group_sample_fails_with_wrong_G_matrix():
    N = 6
    num_levels = 4

    problem = {'bounds': [[0., 1.], [0., 1.], [0., 1.], [0., 1.]],
               'num_vars': 4,
               'groups': list([1, 2, 3])}

    with raises(ValueError) as err:
        sample(problem, N, num_levels)

    assert "Number of entries in \'groups\' should be the same as in " \
           "\'names\'" in str(err.value)