smt
smt copied to clipboard
ConfigSpace error with Python 3.12 - TypeError: Expected float, got numpy.float64
Hi, I'm running into an error when running SMT in a python 3.12 environment, specifically within the design_space module. The following is a test script I'm using:
import numpy as np
from smt.surrogate_models import KRG
x = np.linspace(0, 10, 20).reshape(-1, 1)
y = x * np.sin(x)
model = KRG()
model.set_training_values(x, y)
model.train()
And the following is the resulting console output:
___________________________________________________________________________
Kriging
___________________________________________________________________________
Problem size
# training points. : 20
___________________________________________________________________________
Training
Training ...
Traceback (most recent call last):
File "/home/alec.house/local/CFDRC_tools/sage/scratch.py", line 9, in <module>
model.train()
File "/home/alec.house/local/mambaforge/envs/py312/lib/python3.12/site-packages/smt/surrogate_models/surrogate_model.py", line 275, in train
self._train()
File "/home/alec.house/local/mambaforge/envs/py312/lib/python3.12/site-packages/smt/surrogate_models/krg_based.py", line 529, in _train
self._new_train()
File "/home/alec.house/local/mambaforge/envs/py312/lib/python3.12/site-packages/smt/surrogate_models/krg_based.py", line 373, in _new_train
if is_acting is None and not self.is_continuous:
^^^^^^^^^^^^^^^^^^
File "/home/alec.house/local/mambaforge/envs/py312/lib/python3.12/site-packages/smt/surrogate_models/krg_based.py", line 260, in is_continuous
return self.design_space.is_all_cont
^^^^^^^^^^^^^^^^^
File "/home/alec.house/local/mambaforge/envs/py312/lib/python3.12/site-packages/smt/surrogate_models/krg_based.py", line 247, in design_space
self.options["design_space"] = ensure_design_space(
^^^^^^^^^^^^^^^^^^^^
File "/home/alec.house/local/mambaforge/envs/py312/lib/python3.12/site-packages/smt/utils/design_space.py", line 56, in ensure_design_space
return DesignSpace([[np.min(xt) - 0.99, np.max(xt) + 1e-4]] * xt.shape[1])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/alec.house/local/mambaforge/envs/py312/lib/python3.12/site-packages/smt/utils/design_space.py", line 746, in __init__
cs_vars[name] = UniformFloatHyperparameter(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "ConfigSpace/hyperparameters/uniform_float.pyx", line 62, in ConfigSpace.hyperparameters.uniform_float.UniformFloatHyperparameter.__init__
File "ConfigSpace/hyperparameters/uniform_float.pyx", line 124, in ConfigSpace.hyperparameters.uniform_float.UniformFloatHyperparameter.check_default
TypeError: Expected float, got numpy.float64
For reference, here are the packages currently installed in my environment, which do work with python 3.11.
Package Version
----------------------------- -----------
alabaster 0.7.16
astroid 3.2.2
attrs 23.2.0
babel 2.15.0
black 24.3.0
blinker 1.8.2
build 1.2.1
certifi 2024.6.2
charset-normalizer 3.3.2
click 8.1.7
configspace 0.7.1
contourpy 1.2.1
coverage 7.5.4
cycler 0.12.1
dill 0.3.8
docutils 0.21.2
filelock 3.15.4
flask 3.0.3
fonttools 4.53.0
fsspec 2024.6.1
h5py 3.11.0
idna 3.7
imagesize 1.4.1
iniconfig 2.0.0
isort 5.13.2
itsdangerous 2.2.0
jenn 1.0.6
jinja2 3.1.4
joblib 1.4.2
jsonpointer 3.0.0
jsonschema 4.22.0
jsonschema-specifications 2023.12.1
kaleido 0.2.1
kiwisolver 1.4.5
llvmlite 0.42.0
markupsafe 2.1.5
matplotlib 3.9.0
mccabe 0.7.0
more-itertools 10.3.0
mpmath 1.3.0
mypy 1.9.0
mypy-extensions 1.0.0
networkx 3.3
numba 0.59.1
numpy 1.26.4
orjson 3.10.5
packaging 24.1
pandas 2.2.2
pathspec 0.12.1
pillow 10.4.0
pip 24.0
platformdirs 4.2.2
plotly 5.22.0
pluggy 1.5.0
pooch 1.8.2
pydoe3 1.0.3
pygments 2.18.0
pylint 3.2.5
pyparsing 3.1.2
pyproject-hooks 1.1.0
pytest 8.2.2
pytest-cov 5.0.0
python-dateutil 2.9.0.post0
pytz 2024.1
pyvista 0.43.10
referencing 0.35.1
requests 2.32.3
rpds-py 0.18.1
ruamel-yaml 0.18.6
ruamel-yaml-clib 0.2.8
ruff 0.5.0
scikit-learn 1.5.0
scipy 1.14.0
scooby 0.10.0
setuptools 70.1.1
six 1.16.0
smt 2.6.2
snowballstemmer 2.2.0
sphinx 7.3.7
sphinx-pyreverse 0.0.18
sphinxcontrib-applehelp 1.0.8
sphinxcontrib-devhelp 1.0.6
sphinxcontrib-htmlhelp 2.0.5
sphinxcontrib-jsmath 1.0.1
sphinxcontrib-qthelp 1.0.7
sphinxcontrib-serializinghtml 1.1.10
sympy 1.12.1
tenacity 8.4.2
threadpoolctl 3.5.0
tomlkit 0.12.5
torch 2.3.1+cpu
tqdm 4.66.4
typing-extensions 4.12.2
tzdata 2024.1
urllib3 2.2.2
uv 0.2.18
vtk 9.3.1
werkzeug 3.0.3
wheel 0.43.0
Anything glaringly obvious? Thanks!
Yep, ConfigSpace is not ready for Python 3.12. See #575 . The workaround for now is to either uninstall ConfigSpace (but you loose hierachical variables handling feature) or use Python 3.11.
That got it.
Thank you for your help and the quick replies today!