Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix import error when ConfigSpace not installed #478

Merged
merged 5 commits into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
31 changes: 31 additions & 0 deletions .github/workflows/tests_minimal.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
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 matplotlib # required by GENN atm, to be fixed
pip install -e .

- name: Test with pytest
run: |
pip install pytest
pytest smt


11 changes: 8 additions & 3 deletions smt/applications/tests/test_ego.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
MixedIntegerContext,
MixedIntegerSamplingMethod,
)
import smt.utils.design_space as ds


# This implementation only works with Python > 3.3
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down
5 changes: 4 additions & 1 deletion smt/applications/tests/test_mixed_integer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions smt/utils/design_space.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
except ImportError:
HAS_CONFIG_SPACE = False

class Configuration:
pass

class ConfigurationSpace:
pass

Expand Down