Skip to content

Commit

Permalink
Merge pull request #33 from hill-a/spaces_rewards
Browse files Browse the repository at this point in the history
Equality methods for gym spaces
  • Loading branch information
hill-a committed Sep 22, 2018
2 parents b409b36 + 554842a commit 6b75236
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
8 changes: 8 additions & 0 deletions docs/misc/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ Changelog

For download links, please look at `Github release page <https://github.com/hill-a/stable-baselines/releases>`_.

Pre Release 2.0.1.a0 (WIP)
---------------------------

**logging and bug fixes**

- added patch fix for equal function using `gym.spaces.MultiDiscrete` and `gym.spaces.MultiBinary`


Release 2.0.0 (2018-09-18)
--------------------------

Expand Down
20 changes: 19 additions & 1 deletion stable_baselines/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import gym
import numpy as np

from stable_baselines.a2c import A2C
from stable_baselines.acer import ACER
from stable_baselines.acktr import ACKTR
Expand All @@ -8,4 +11,19 @@
from stable_baselines.ppo2 import PPO2
from stable_baselines.trpo_mpi import TRPO

__version__ = "2.0.0"
__version__ = "2.0.1.a0"


# patch Gym spaces to add equality functions, if not implemented
# See https://github.com/openai/gym/issues/1171
if gym.spaces.MultiBinary.__eq__ == object.__eq__: # by default, all classes have the __eq__ function from object.
def _eq(self, other):
return self.n == other.n

gym.spaces.MultiBinary.__eq__ = _eq

if gym.spaces.MultiDiscrete.__eq__ == object.__eq__:
def _eq(self, other):
return np.all(self.nvec == other.nvec)

gym.spaces.MultiDiscrete.__eq__ = _eq

0 comments on commit 6b75236

Please sign in to comment.