From b9417de408f48c6a1315a5e7bdb90a646ef51e31 Mon Sep 17 00:00:00 2001 From: Simon Blanke Date: Sat, 20 Apr 2024 13:17:41 +0200 Subject: [PATCH] fix imports in multiple tests --- tests/test_all_test_functions.py | 6 ++-- tests/test_arrays_input.py | 62 -------------------------------- tests/test_optimization.py | 2 +- 3 files changed, 4 insertions(+), 66 deletions(-) delete mode 100644 tests/test_arrays_input.py diff --git a/tests/test_all_test_functions.py b/tests/test_all_test_functions.py index cf631b4..d0ec4fc 100644 --- a/tests/test_all_test_functions.py +++ b/tests/test_all_test_functions.py @@ -3,7 +3,7 @@ from hyperactive import Hyperactive from gradient_free_optimizers import RandomSearchOptimizer -from surfaces import mathematical_functions, machine_learning_functions +from surfaces.test_functions import mathematical_functions, machine_learning_functions mathematical_functions_d = ( @@ -27,7 +27,7 @@ def test_all_mathematical_functions(test_function): objective_function = test_function_.objective_function search_space = test_function_.search_space(value_types="array") - n_iter = 20 + n_iter = 100 opt = RandomSearchOptimizer(search_space) opt.search(objective_function, n_iter=n_iter) @@ -39,7 +39,7 @@ def test_all_machine_learning_functions(test_function): objective_function = test_function_.objective_function search_space = test_function_.search_space() - n_iter = 20 + n_iter = 3 hyper = Hyperactive() hyper.add_search( diff --git a/tests/test_arrays_input.py b/tests/test_arrays_input.py deleted file mode 100644 index 62ec524..0000000 --- a/tests/test_arrays_input.py +++ /dev/null @@ -1,62 +0,0 @@ -import pytest -import numpy as np -from gradient_free_optimizers import RandomSearchOptimizer - - -from surfaces.mathematical_functions import ( - SphereFunction, - RastriginFunction, - AckleyFunction, - RosenbrockFunction, - BealeFunction, - HimmelblausFunction, - HölderTableFunction, - CrossInTrayFunction, - SimionescuFunction, - EasomFunction, - BoothFunction, - GoldsteinPriceFunction, - StyblinskiTangFunction, -) - -sphere_function = SphereFunction(2, input_type="arrays") -rastrigin_function = RastriginFunction(2, input_type="arrays") -ackley_function = AckleyFunction(input_type="arrays") -rosenbrock_function = RosenbrockFunction(2, input_type="arrays") -beale_function = BealeFunction(input_type="arrays") -himmelblaus_function = HimmelblausFunction(input_type="arrays") -hölder_table_function = HölderTableFunction(input_type="arrays") -cross_in_tray_function = CrossInTrayFunction(input_type="arrays") -simionescu_function = SimionescuFunction(input_type="arrays") -easom_function = EasomFunction(input_type="arrays") -booth_function = BoothFunction(input_type="arrays") -goldstein_price_function = GoldsteinPriceFunction(input_type="arrays") -styblinski_tang_function = StyblinskiTangFunction(2, input_type="arrays") - - -test_function_para_2D = ( - "test_function", - [ - (sphere_function), - (rastrigin_function), - (ackley_function), - (rosenbrock_function), - (beale_function), - (himmelblaus_function), - (hölder_table_function), - (cross_in_tray_function), - (simionescu_function), - (easom_function), - (booth_function), - (goldstein_price_function), - (styblinski_tang_function), - ], -) - -a = np.array([1, 2, 3, 4, 5]) -b = np.array([1, 2, 3, 4, 5]) - - -@pytest.mark.parametrize(*test_function_para_2D) -def test_array_input(test_function): - test_function.objective_function(a, b) diff --git a/tests/test_optimization.py b/tests/test_optimization.py index 9fa94e6..310a144 100644 --- a/tests/test_optimization.py +++ b/tests/test_optimization.py @@ -2,7 +2,7 @@ import numpy as np from gradient_free_optimizers import RandomSearchOptimizer -from surfaces.mathematical_functions import ( +from surfaces.test_functions.mathematical import ( SphereFunction, RastriginFunction, AckleyFunction,