From e8349e3668ad83fc3e2f0655f0da9967e36d0ba2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20Kossovics?= Date: Mon, 28 Jan 2019 23:52:41 +0100 Subject: [PATCH] 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)`. --- gym/core.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gym/core.py b/gym/core.py index 7ea21433b..f65905145 100644 --- a/gym/core.py +++ b/gym/core.py @@ -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."""