def test_define_problem_with_groups_exception(self): """ Checks if the function raises an exception when the user makes an inconsistent definition of groups, i.e, only define groups for some variables. """ problem = { 'num_vars': 8, 'names': ['x1', 'x2', 'x3', 'x4', 'x5', 'x6', 'x7', 'x8'], 'groups': ['G1', 'G1', 'G1', 'G2', 'G2', 'G2'] } with raises(ValueError): _define_problem_with_groups(problem)
def test_find_optimum_trajectories(setup_input, expected_sample): N = 6 problem = {'num_vars': 2, 'names': ['x1', 'x2'], 'groups': None} k_choices = 4 problem = _define_problem_with_groups(problem) output = _compute_optimised_trajectories(problem, setup_input, N, k_choices) expected = expected_sample np.testing.assert_equal(output, expected)
def test_define_problem_with_groups_all_ok(self): """ Checks if the function works when the user defines different groups for each variable. """ problem = { 'num_vars': 8, 'names': ['x1', 'x2', 'x3', 'x4', 'x5', 'x6', 'x7', 'x8'], 'groups': ['G1', 'G1', 'G1', 'G2', 'G2', 'G2', 'G3', 'G3'] } expected = problem result = _define_problem_with_groups(problem) assert expected == result
def test_define_problem_with_groups_no_group_definition(self): """ Checks if the function works when the user doesn't define groups at all. """ problem = { 'num_vars': 8, 'names': ['x1', 'x2', 'x3', 'x4', 'x5', 'x6', 'x7', 'x8'] } expected = { 'num_vars': 8, 'names': ['x1', 'x2', 'x3', 'x4', 'x5', 'x6', 'x7', 'x8'], 'groups': ['x1', 'x2', 'x3', 'x4', 'x5', 'x6', 'x7', 'x8'] } result = _define_problem_with_groups(problem) assert expected == result