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

[Bug] UniformFloatHyperparameter Typing check bug #342

Closed
junhongmit opened this issue Nov 28, 2023 · 3 comments · Fixed by #346
Closed

[Bug] UniformFloatHyperparameter Typing check bug #342

junhongmit opened this issue Nov 28, 2023 · 3 comments · Fixed by #346

Comments

@junhongmit
Copy link

I noticed there was a bug in the typing check when I tried to install it in a ppc64le architecture supercomputer. The ConfigSpace version I am using is 0.7.2. When running the following example code,

import ConfigSpace.hyperparameters as CSH
u = CSH.UniformIntegerHyperparameter("u", 1, 10, default_value=1)

An error will be given:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[7], line 2
      1 import ConfigSpace.hyperparameters as CSH
----> 2 u = CSH.UniformIntegerHyperparameter("u", 1, 10, default_value=int(1))

File /nobackup/users/junhong/anaconda3/envs/pytorch1.12/lib/python3.9/site-packages/ConfigSpace-0.7.2-py3.9-linux-ppc64le.egg/ConfigSpace/hyperparameters/uniform_integer.pyx:82, in ConfigSpace.hyperparameters.uniform_integer.UniformIntegerHyperparameter.__init__()

File /nobackup/users/junhong/anaconda3/envs/pytorch1.12/lib/python3.9/site-packages/ConfigSpace-0.7.2-py3.9-linux-ppc64le.egg/ConfigSpace/hyperparameters/uniform_float.pyx:62, in ConfigSpace.hyperparameters.uniform_float.UniformFloatHyperparameter.__init__()

TypeError: Argument 'default_value' has incorrect type (expected float, got int)

I tried to reproduce it on my personal laptop with x86/x64 architecture, but it didn't show up. After a deep dive into the code, I found that line 62 in uniform_float.pyx is a default value checking: self.default_value = self.check_default(default_value). At line 14, we can see that the default value could be both integer or float value: default_value: Union[int, float, None] = None. But the type checking function def check_default(self, default_value: Optional[float]) -> float: only allow float value parameter.

I eventually fixed this by changing the definition to def check_default(self, default_value: Optional[Union[int, float]]) -> float:. I think there might be similar issues in the other place in the codebase.

@eddiebergman
Copy link
Contributor

Hiyo, sorry for not replying. This was a cythonization issue but #346 removed Cython entirely. Hopefully this gets released next week :)

@JusciAvelino
Copy link

Hi, I encountered the same problem described here and wanted to ask if it has been fixed.

@eddiebergman
Copy link
Contributor

Hi @JusciAvelino, not yet. Almost finished with the PR at #346. Just documentation setup left

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.

3 participants