From 068cccd7c116c2acf98a8112695e44ec15f746b3 Mon Sep 17 00:00:00 2001 From: relf Date: Thu, 23 Nov 2023 17:18:16 +0100 Subject: [PATCH 1/5] Add tests with minimal installation --- .github/workflows/tests.yml | 2 -- .github/workflows/tests_minimal.yml | 30 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/tests_minimal.yml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 91e8fa507..65279aaf1 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -19,8 +19,6 @@ jobs: python-version: "3.10" - os: ubuntu-latest python-version: "3.9" - - os: ubuntu-latest - python-version: "3.8" steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/tests_minimal.yml b/.github/workflows/tests_minimal.yml new file mode 100644 index 000000000..a908bc53e --- /dev/null +++ b/.github/workflows/tests_minimal.yml @@ -0,0 +1,30 @@ +name: Tests Minimal + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up python + uses: actions/setup-python@v4 + with: + python-version: "3.8" + + - name: Install dependencies + run: | + pip install --upgrade pip + pip install numpy cython + pip install -e . + + - name: Test with pytest + run: | + pip install pytest + pytest smt + + From 2e0d1ef0184c0c0f55149ccf1d3dfa39f5c5c2f1 Mon Sep 17 00:00:00 2001 From: relf Date: Thu, 23 Nov 2023 17:18:54 +0100 Subject: [PATCH 2/5] Fix import problem when ConfigSpace not installed --- smt/utils/design_space.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/smt/utils/design_space.py b/smt/utils/design_space.py index 33ea4c9df..b03ee0e0b 100644 --- a/smt/utils/design_space.py +++ b/smt/utils/design_space.py @@ -31,6 +31,9 @@ except ImportError: HAS_CONFIG_SPACE = False + class Configuration: + pass + class ConfigurationSpace: pass From 69c1cac1cd3fcb56c9b6af33fa1fdf6692a01356 Mon Sep 17 00:00:00 2001 From: relf Date: Thu, 23 Nov 2023 17:43:38 +0100 Subject: [PATCH 3/5] matplotlib required by GENN, to be fixed --- .github/workflows/tests_minimal.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests_minimal.yml b/.github/workflows/tests_minimal.yml index a908bc53e..6721ba16b 100644 --- a/.github/workflows/tests_minimal.yml +++ b/.github/workflows/tests_minimal.yml @@ -19,7 +19,8 @@ jobs: - name: Install dependencies run: | pip install --upgrade pip - pip install numpy cython + pip install numpy cython + pip install matplotlib # required by GENN atm, to be fixed pip install -e . - name: Test with pytest From 649b0c2feee7f2726fe1050424f823db16d46a22 Mon Sep 17 00:00:00 2001 From: relf Date: Thu, 23 Nov 2023 18:04:47 +0100 Subject: [PATCH 4/5] Exclude test using ConfigSpace --- smt/applications/tests/test_mixed_integer.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/smt/applications/tests/test_mixed_integer.py b/smt/applications/tests/test_mixed_integer.py index abfaf972b..f8c1d689f 100644 --- a/smt/applications/tests/test_mixed_integer.py +++ b/smt/applications/tests/test_mixed_integer.py @@ -23,6 +23,8 @@ OrdinalVariable, CategoricalVariable, ) +import smt.utils.design_space as ds + from smt.sampling_methods import LHS from smt.surrogate_models import ( KRG, @@ -300,7 +302,8 @@ def test_examples(self): self.run_mixed_integer_context_example() self.run_hierarchical_variables_Goldstein() self.run_mixed_discrete_design_space_example() - self.run_hierarchical_design_space_example() + if ds.HAS_CONFIG_SPACE: + self.run_hierarchical_design_space_example() # works only with config space impl def run_mixed_integer_lhs_example(self): import numpy as np From 4cc4631fe2a248952dfbd8627a7a43e5c0953cb7 Mon Sep 17 00:00:00 2001 From: relf Date: Fri, 24 Nov 2023 09:44:11 +0100 Subject: [PATCH 5/5] Fix test values when ConfigSpace not installed --- smt/applications/tests/test_ego.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/smt/applications/tests/test_ego.py b/smt/applications/tests/test_ego.py index b0af816df..a2a7e7d9c 100644 --- a/smt/applications/tests/test_ego.py +++ b/smt/applications/tests/test_ego.py @@ -37,6 +37,7 @@ MixedIntegerContext, MixedIntegerSamplingMethod, ) +import smt.utils.design_space as ds # This implementation only works with Python > 3.3 @@ -892,7 +893,7 @@ def _evaluate(self, x, kx): return ego, fun - def test_sampling_consistency(self): + def test_ego_seeding(self): def f_obj(X): """ s01 objective @@ -997,8 +998,12 @@ def f_obj(X): n_start=15, ) x_opt, y_opt, dnk, x_data, y_data = ego.optimize(fun=f_obj) - self.assertAlmostEqual(np.sum(y_data), 2.7639515433083854, delta=1e-4) - self.assertAlmostEqual(np.sum(x_data), 32.11001423996299, delta=1e-4) + if ds.HAS_CONFIG_SPACE: # results differs wrt config_space impl + self.assertAlmostEqual(np.sum(y_data), 2.7639515433083854, delta=1e-4) + self.assertAlmostEqual(np.sum(x_data), 32.11001423996299, delta=1e-4) + else: + self.assertAlmostEqual(np.sum(y_data), 2.03831406306514, delta=1e-4) + self.assertAlmostEqual(np.sum(x_data), 33.56885202767958, delta=1e-4) def test_ego_gek(self): ego, fun = self.initialize_ego_gek()