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

TypeError: Expected int, got numpy.ndarray when sampling OrdinalHyperparameter #338

Open
hury07 opened this issue Jul 28, 2023 · 4 comments · May be fixed by #346
Open

TypeError: Expected int, got numpy.ndarray when sampling OrdinalHyperparameter #338

hury07 opened this issue Jul 28, 2023 · 4 comments · May be fixed by #346

Comments

@hury07
Copy link

hury07 commented Jul 28, 2023

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

@eismont21
Copy link

Downgrade configspace to version 0.7.1. It has helped me

@eddiebergman
Copy link
Contributor

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.

@sarahec
Copy link

sarahec commented Apr 15, 2024

Matching Cython issue: cython/cython#5750

@eddiebergman
Copy link
Contributor

Hi,

Just want to report that this issue if fixed in PR #346 which removes Cython. Hopefully we can release sometime next week.

@eddiebergman eddiebergman linked a pull request Apr 16, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants