Skip to content

Commit

Permalink
fix(Configuration): contains now checks if value can be retrieved
Browse files Browse the repository at this point in the history
This is slightly slower but is the safest way to ensure that
the value of `__contains__` matches the functionality required.
  • Loading branch information
eddiebergman committed Jul 30, 2024
1 parent 6240021 commit 153731c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/ConfigSpace/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,11 @@ def __contains__(self, key: object) -> bool:
if not isinstance(key, str):
return False

return key in self.config_space
try:
self.__getitem__(key)
return True
except KeyError:
return False

def __setitem__(self, key: str, value: Any) -> None:
param = self.config_space[key]
Expand Down

0 comments on commit 153731c

Please sign in to comment.