Skip to content

Commit

Permalink
adapt all tests to new API
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonBlanke committed Mar 16, 2024
1 parent d2a2368 commit a08285f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions tests/test_all_test_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def test_all_mathematical_functions(test_function):

hyper = Hyperactive()
hyper.add_search(
test_function_,
test_function_.objective_function,
test_function_.create_n_dim_search_space(value_types="list"),
n_iter=15,
)
Expand All @@ -38,7 +38,7 @@ def test_all_machine_learning_functions(test_function):

hyper = Hyperactive()
hyper.add_search(
test_function_,
test_function_.objective_function,
test_function_.search_space,
n_iter=15,
)
Expand Down
10 changes: 5 additions & 5 deletions tests/test_arrays_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
styblinski_tang_function = StyblinskiTangFunction(2, input_type="arrays")


objective_function_para_2D = (
"objective_function",
test_function_para_2D = (
"test_function",
[
(sphere_function),
(rastrigin_function),
Expand All @@ -57,6 +57,6 @@
b = np.array([1, 2, 3, 4, 5])


@pytest.mark.parametrize(*objective_function_para_2D)
def test_array_input(objective_function):
objective_function(a, b)
@pytest.mark.parametrize(*test_function_para_2D)
def test_array_input(test_function):
test_function.objective_function(a, b)
18 changes: 9 additions & 9 deletions tests/test_optimization.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@


objective_function_para_2D = (
"objective_function",
"test_function",
[
(sphere_function),
(rastrigin_function),
Expand All @@ -57,14 +57,14 @@


@pytest.mark.parametrize(*objective_function_para_2D)
def test_optimization_2D(objective_function):
def test_optimization_2D(test_function):
search_space = {
"x0": np.arange(0, 100, 1),
"x1": np.arange(0, 100, 1),
}

opt = RandomSearchOptimizer(search_space)
opt.search(objective_function, n_iter=30)
opt.search(test_function.objective_function, n_iter=30)


############################################################
Expand All @@ -75,7 +75,7 @@ def test_optimization_2D(objective_function):


objective_function_para_3D = (
"objective_function",
"test_function",
[
(sphere_function),
(rastrigin_function),
Expand All @@ -85,15 +85,15 @@ def test_optimization_2D(objective_function):


@pytest.mark.parametrize(*objective_function_para_3D)
def test_optimization_3D(objective_function):
def test_optimization_3D(test_function):
search_space = {
"x0": np.arange(0, 100, 1),
"x1": np.arange(0, 100, 1),
"x2": np.arange(0, 100, 1),
}

opt = RandomSearchOptimizer(search_space)
opt.search(objective_function, n_iter=30)
opt.search(test_function.objective_function, n_iter=30)


############################################################
Expand All @@ -104,7 +104,7 @@ def test_optimization_3D(objective_function):


objective_function_para_4D = (
"objective_function",
"test_function",
[
(sphere_function),
(rastrigin_function),
Expand All @@ -114,7 +114,7 @@ def test_optimization_3D(objective_function):


@pytest.mark.parametrize(*objective_function_para_4D)
def test_optimization_4D(objective_function):
def test_optimization_4D(test_function):
search_space = {
"x0": np.arange(0, 100, 1),
"x1": np.arange(0, 100, 1),
Expand All @@ -123,4 +123,4 @@ def test_optimization_4D(objective_function):
}

opt = RandomSearchOptimizer(search_space)
opt.search(objective_function, n_iter=30)
opt.search(test_function.objective_function, n_iter=30)

0 comments on commit a08285f

Please sign in to comment.