mirror of
https://github.com/Farama-Foundation/Gymnasium.git
synced 2025-08-17 20:39:12 +00:00
Fix in keyword with Spaces (#1261)
Binding `__contains__` to the Space class' contains method this way prevents overriding it in subclasses, which leads to `NotImplementedException`s when trying to do things like `2 in gym.spaces.Discrete(2)`.
This commit is contained in:
committed by
pzhokhov
parent
12e8b763d5
commit
e8349e3668
@@ -215,7 +215,8 @@ class Space(object):
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
__contains__ = contains
|
||||
def __contains__(self, x):
|
||||
return self.contains(x)
|
||||
|
||||
def to_jsonable(self, sample_n):
|
||||
"""Convert a batch of samples from this space to a JSONable data type."""
|
||||
|
Reference in New Issue
Block a user