diff --git a/src/ConfigSpace/configuration.py b/src/ConfigSpace/configuration.py index 4874287a..34ab7892 100644 --- a/src/ConfigSpace/configuration.py +++ b/src/ConfigSpace/configuration.py @@ -173,11 +173,11 @@ def get_array(self) -> Array[f64]: """ return self._vector - def __contains__(self, item: object) -> bool: - if not isinstance(item, str): + def __contains__(self, key: object) -> bool: + if not isinstance(key, str): return False - return item in self + return key in self.config_space def __setitem__(self, key: str, value: Any) -> None: param = self.config_space[key] diff --git a/test/test_configuration_space.py b/test/test_configuration_space.py index 830fca17..22796387 100644 --- a/test/test_configuration_space.py +++ b/test/test_configuration_space.py @@ -1233,6 +1233,9 @@ def test_configuration_acts_as_mapping(simple_cs: ConfigurationSpace): # Test indexing assert config["parent"] == values_dict["parent"] assert config["child"] == values_dict["child"] + for name in names: + assert name in config + assert "mouse" not in config # Test dict methods assert set(config.keys()) == set(names)