ConfigSpace
ConfigSpace copied to clipboard
`Configuration.get()` always return None if key is not in CS regardless of the provided default value
Configuration.get()
always returns None if key is not in CS regardless of the provided default value.
I have to use config.get_dictionary.get()
to perform the expected behavior.
ConfigSpace version: 0.4.20, 0.4.21, 0.5.0.
Code:
import ConfigSpace
from ConfigSpace import ConfigurationSpace, UniformIntegerHyperparameter
print(ConfigSpace.__version__)
cs = ConfigurationSpace()
a = UniformIntegerHyperparameter("a", lower=0, upper=1000)
cs.add_hyperparameter(a)
conf = cs.sample_configuration()
print(conf)
print(conf.get('x')) # None
print(conf.get('x', 123)) # None !!!
print(conf['x']) # None
Thank you very much for reporting this. I can confirm this issue. I just tried to fix it, however, this results in an endless loop when requesting new neighbors from a configuration, which I don't understand yet. As you currently have a workaround, we'll get back to you when we have taken care of the open pull requests.
This has been fixed in #321