TypeError: UnitScaler() takes no arguments
Trying to run the Minimum Example, I am thrown this error. I am working with v1.2.1 installed using pip with python v3.9.
Detailed error message:
>>> from ConfigSpace import ConfigurationSpace
>>> cs = ConfigurationSpace({
... "myfloat": (0.1, 1.5), # Uniform Float
... "myint": (2, 10), # Uniform Integer
... "species": ["mouse", "cat", "dog"], # Categorical
... })
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "$HOME/.conda/envs/gpt/lib/python3.9/site-packages/ConfigSpace/configuration_space.py", line 205, in __init__
hyperparameters = list(_parse_hyperparameters_from_dict(space))
File "$HOME/.conda/envs/gpt/lib/python3.9/site-packages/ConfigSpace/configuration_space.py", line 103, in _parse_hyperparameters_from_dict
yield UniformFloatHyperparameter(name, lower, upper)
File "$HOME/.conda/envs/gpt/lib/python3.9/site-packages/ConfigSpace/hyperparameters/uniform_float.py", line 98, in __init__
scaler = UnitScaler(f64(self.lower), f64(self.upper), log=log, dtype=f64)
TypeError: UnitScaler() takes no arguments
This is my first time using ConfigSpace, so I apologize in advance in case there is any naive mistake from my end!
Any help to resolve this would be appreciated. Thanks!
I'm not sure why you're getting this error, I tried to reproduce it but it all works as intended:
~/code/repro » cat repro.py eddiebergman@mllap12-2
from ConfigSpace import ConfigurationSpace
cs = ConfigurationSpace(
name="myspace",
space={
"a": (0.1, 1.5), # UniformFloat
"b": (2, 10), # UniformInt
"c": ["mouse", "cat", "dog"], # Categorical
},
)
configs = cs.sample_configuration(2)
print(configs)
(repro) --------------------------------------------------------------------------------------------------------------------------------
~/code/repro » python repro.py eddiebergman@mllap12-2
[Configuration(values={
'a': 1.4472818725845,
'b': 7,
'c': np.str_('dog'),
}), Configuration(values={
'a': 0.1622273472625,
'b': 3,
'c': np.str_('dog'),
})]
(repro) --------------------------------------------------------------------------------------------------------------------------------
~/code/repro » uv pip list eddiebergman@mllap12-2
Package Version
----------------- -------
configspace 1.2.1
more-itertools 10.6.0
numpy 2.0.2
pyparsing 3.2.1
scipy 1.13.1
typing-extensions 4.12.2
Can you provide me with your OS as well?
Judging by the $HOME in the traceback, I'm assuming it's either Linux or Mac, both of which I've tested personally.
Can you run this in your environment for me?
python -c "from ConfigSpace.hyperparameters.hp_components import UnitScaler; print(UnitScaler(0, 1, dtype='blah'))"
You can also run it in a standalone file if you prefer.
If that doesn't work then:
- Create a clean new environment with nothing in it.
- Install
ConfigSpaceinto it. - Try again.
If the error persists, then I really have no clue why this would be happening.
You could also try:
git clone [email protected]:automl/ConfigSpace.git
pip install -e ConfigSpace
python -c "from ConfigSpace.hyperparameters.hp_components import UnitScaler; print(UnitScaler(0, 1, dtype='blah'))"
We would need more information to go on because that's a very odd error.
Hi eddie,
You are right about the OS, it was indeed Linux.
Although the error still persists in my environment, creating a clean new environment with nothing in it solved it for me. I now need to figure out what exactly was triggering the issue in my previous environment.
Thank you for the response and suggestions!
I see the same, reproducible on Ubuntu 20.04 with:
conda create -n cs-debug python=3.9.7
conda activate cs-debug
pip install ConfigSpace==1.2.1
python -c "from ConfigSpace.hyperparameters.hp_components import UnitScaler; print(UnitScaler(0, 1, dtype='blah'))"
fails with TypeError: UnitScaler() takes no arguments
EDIT: Works with Python 3.12.9
The installation error does not occur in a clean condo environment (Python 3.9.7) on Mac:
pip install ConfigSpace==1.2.1 Looking in indexes: https://pypi.org/simple, https://pypi.ngc.nvidia.com Collecting ConfigSpace==1.2.1 Downloading configspace-1.2.1.tar.gz (130 kB) Installing build dependencies ... done Getting requirements to build wheel ... done Preparing metadata (pyproject.toml) ... done Collecting numpy (from ConfigSpace==1.2.1) Downloading numpy-2.0.2-cp39-cp39-macosx_14_0_arm64.whl.metadata (60 kB) Collecting pyparsing (from ConfigSpace==1.2.1) Downloading pyparsing-3.2.3-py3-none-any.whl.metadata (5.0 kB) Collecting scipy (from ConfigSpace==1.2.1) Downloading scipy-1.13.1-cp39-cp39-macosx_12_0_arm64.whl.metadata (60 kB) Collecting typing_extensions (from ConfigSpace==1.2.1) Downloading typing_extensions-4.14.0-py3-none-any.whl.metadata (3.0 kB) Collecting more_itertools (from ConfigSpace==1.2.1) Downloading more_itertools-10.7.0-py3-none-any.whl.metadata (37 kB) Downloading more_itertools-10.7.0-py3-none-any.whl (65 kB) Downloading numpy-2.0.2-cp39-cp39-macosx_14_0_arm64.whl (5.3 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 5.3/5.3 MB 10.0 MB/s eta 0:00:00 Downloading pyparsing-3.2.3-py3-none-any.whl (111 kB) Downloading scipy-1.13.1-cp39-cp39-macosx_12_0_arm64.whl (30.3 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 30.3/30.3 MB 8.7 MB/s eta 0:00:00 Downloading typing_extensions-4.14.0-py3-none-any.whl (43 kB) Building wheels for collected packages: ConfigSpace Building wheel for ConfigSpace (pyproject.toml) ... done Created wheel for ConfigSpace: filename=configspace-1.2.1-py3-none-any.whl size=115990 sha256=8c9e8538c2c10546b39757f52654771a2f28e70c23eb9666c6b8e8eaf756a4e5 Stored in directory: /private/var/folders/78/9cl0kydx0g3cdzjyk28yzr7w0000gn/T/pip-ephem-wheel-cache-tcifq7o1/wheels/2e/10/2f/c867d717844bb822788821684b40c53e8763cd37d4dab7559d Successfully built ConfigSpace Installing collected packages: typing_extensions, pyparsing, numpy, more_itertools, scipy, ConfigSpace Successfully installed ConfigSpace-1.2.1 more_itertools-10.7.0 numpy-2.0.2 pyparsing-3.2.3 scipy-1.13.1 typing_extensions-4.14.0
However, when running in the Python interpreter: `Python 3.9.7 (default, Sep 16 2021, 23:53:23) [Clang 12.0.0 ] :: Anaconda, Inc. on darwin Type "help", "copyright", "credits" or "license" for more information.
from ConfigSpace.hyperparameters.hp_components import UnitScaler print(UnitScaler(0, 1, dtype='blah')) Traceback (most recent call last): File "
", line 1, in TypeError: UnitScaler() takes no arguments`
Closing this issue for the following reasons;
- As the error was only reproduced using Python 3.9; this is at the end of its lifetime cycle and will be deprecated from ConfigSpace in the near future.
- Solutions for the user were found
- Inactive thread
Happy to reopen if new information becomes available.