ConfigSpace
ConfigSpace copied to clipboard
TypeError: Expected int, got numpy.ndarray when sampling OrdinalHyperparameter
Hello, It seems that there is an error to sample OrdinalHyperparameter. The code is given as follows to replicate the error.
from ConfigSpace import ConfigurationSpace, CategoricalHyperparameter, OrdinalHyperparameter
cs = ConfigurationSpace(
name="test",
seed=1234,
space={
"Oil_solvent": CategoricalHyperparameter("Oil_solvent", ["Squalene", "Mineral oil", "Paraffin liquid"]),
"Phospholipid_concentration": OrdinalHyperparameter("Phospholipid_concentration", [200, 300, 400, 500, 600]),
}
)
print(cs.sample_configuration())
Traceback (most recent call last):
File "/home/hury/Projects/AutoDOE/tests/decision_space.py", line 12, in <module>
print(cs.sample_configuration())
File "/home/hury/mambaforge/envs/autodoe/lib/python3.10/site-packages/ConfigSpace/configuration_space.py", line 880, in sample_configuration
vector[:, i] = hyperparameter._sample(self.random, missing)
File "ConfigSpace/hyperparameters/ordinal.pyx", line 241, in ConfigSpace.hyperparameters.ordinal.OrdinalHyperparameter._sample
TypeError: Expected int, got numpy.ndarray
ConfigSpace version: v0.7.2
Downgrade configspace to version 0.7.1. It has helped me
Hiyo, thanks for the note on downgrading. Turns out it seems to be an issue with a newer version of Cython and simply downgrading Cython seems to cause other issues.
We've removed 0.7.2 from PyPI for now.
Matching Cython issue: cython/cython#5750
Hi,
Just want to report that this issue if fixed in PR #346 which removes Cython. Hopefully we can release sometime next week.