1
0
mirror of https://github.com/gryf/coach.git synced 2025-12-17 19:20:19 +01:00

make sure that for now observation spaces all include an observation key

This commit is contained in:
Zach Dwiel
2018-02-20 11:51:27 -05:00
parent 0740ebcdac
commit ec68bd4959

View File

@@ -70,6 +70,18 @@ class GymEnvironmentWrapper(EnvironmentWrapper):
scale = 2
self.renderer.create_screen(image.shape[1]*scale, image.shape[0]*scale)
if isinstance(self.env.observation_space, gym.spaces.Dict):
if 'observation' not in self.env.observation_space:
raise ValueError((
'The gym environment provided {env_id} does not contain '
'"observation" in its observation space. For now this is '
'required. The environment does include the following '
'keys in its observation space: {keys}'
).format(
env_id=self.env_id,
keys=self.env.observation_space.keys(),
))
# TODO: collect and store this as observation space instead
self.is_state_type_image = len(self.state['observation'].shape) > 1
if self.is_state_type_image: