Allow string comparison with ObservationSpaceSpec.
@@ -82,8 +82,9 @@ class ObservationSpaceSpec:
def __eq__(self, rhs) -> bool:
"""Equality check."""
- if not isinstance(rhs, ObservationSpaceSpec):
- return False
+ if isinstance(rhs, str):
+ return self.id == rhs
+ elif isinstance(rhs, ObservationSpaceSpec):
return (
self.id == rhs.id
and self.index == rhs.index
@@ -91,6 +92,7 @@ class ObservationSpaceSpec:
and self.platform_dependent == rhs.platform_dependent
and self.deterministic == rhs.deterministic
)
+ return False
@classmethod
def from_proto(cls, index: int, proto: ObservationSpace):
