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

Cannot create Integer parameter #369

Closed
mdorier opened this issue Jul 11, 2024 · 2 comments
Closed

Cannot create Integer parameter #369

mdorier opened this issue Jul 11, 2024 · 2 comments

Comments

@mdorier
Copy link
Contributor

mdorier commented Jul 11, 2024

This is with ConfigSpace 0.7.1, which is the latest one installable with pip, so my apology if this was fixed already.

It seems I just cannot create an Integer parameter:

>>> from ConfigSpace import Integer
>>> Integer("x", (1, 42))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/ubuntu/Code/spack/var/spack/environments/bedrock-env/.spack-env/view/lib/python3.11/site-packages/ConfigSpace/api/types/integer.py", line 159, in Integer
    return UniformIntegerHyperparameter(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "ConfigSpace/hyperparameters/uniform_integer.pyx", line 48, in ConfigSpace.hyperparameters.uniform_integer.UniformIntegerHyperparameter.__init__
TypeError: Argument 'default_value' has incorrect type (expected int, got NoneType)
>>> Integer("x", (1, 42), default=1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/ubuntu/Code/spack/var/spack/environments/bedrock-env/.spack-env/view/lib/python3.11/site-packages/ConfigSpace/api/types/integer.py", line 159, in Integer
    return UniformIntegerHyperparameter(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "ConfigSpace/hyperparameters/uniform_integer.pyx", line 82, in ConfigSpace.hyperparameters.uniform_integer.UniformIntegerHyperparameter.__init__
  File "ConfigSpace/hyperparameters/uniform_float.pyx", line 62, in ConfigSpace.hyperparameters.uniform_float.UniformFloatHyperparameter.__init__
TypeError: Argument 'default_value' has incorrect type (expected float, got int)
>>> Integer("x", (1, 42), default=1.0)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/ubuntu/Code/spack/var/spack/environments/bedrock-env/.spack-env/view/lib/python3.11/site-packages/ConfigSpace/api/types/integer.py", line 159, in Integer
    return UniformIntegerHyperparameter(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "ConfigSpace/hyperparameters/uniform_integer.pyx", line 48, in ConfigSpace.hyperparameters.uniform_integer.UniformIntegerHyperparameter.__init__
TypeError: Argument 'default_value' has incorrect type (expected int, got float)

Not specifying the default? It complains that default_value isn't provided. Passing default=1? It complains that it wants a float. Passing default=1.0? It complains that it wants an int.

If this was corrected already, could you publish version 0.7.2 to pypi?

@mdorier
Copy link
Contributor Author

mdorier commented Jul 11, 2024

I tried several versions as well as the main branch and figured out that it's caused by the version of cython used. I had Cython 3.0.10. When I switched to Cython 0.29.36, these kind of type conversion bug disappeared.

I think Cython became more strict about type conversions in version 3+, you might want to go through the code and test it with Cython 3. I tried adding the missing conversion in uniform_integer.pyx but ended up with another conversion error (from float to a numpy float or something like that) later down the line.

@eddiebergman
Copy link
Contributor

Closed as of #346

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

No branches or pull requests

2 participants