Skip to content

Commit

Permalink
fix(Configuration): __contains__ doesn't recurse (#378)
Browse files Browse the repository at this point in the history
  • Loading branch information
eddiebergman committed Jul 19, 2024
1 parent b7e62e3 commit ebb89f4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/ConfigSpace/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
3 changes: 3 additions & 0 deletions test/test_configuration_space.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit ebb89f4

Please sign in to comment.