From 2ad42f4132a928f1e39181f0da429d7407b02969 Mon Sep 17 00:00:00 2001 From: Dominik Roth Date: Sun, 11 Jun 2023 13:47:38 +0200 Subject: [PATCH] Fix: Minor bugs in time aware obs wrapper --- fancy_gym/utils/time_aware_observation.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fancy_gym/utils/time_aware_observation.py b/fancy_gym/utils/time_aware_observation.py index 12c3762..a042438 100644 --- a/fancy_gym/utils/time_aware_observation.py +++ b/fancy_gym/utils/time_aware_observation.py @@ -28,10 +28,10 @@ class TimeAwareObservation(gym.ObservationWrapper, gym.utils.RecordConstructorAr assert env.observation_space.__class__ in allowed_classes, str(env.observation_space)+' is not supported. Only Box or Dict' - low = np.append(env.observation_space.low, 0.0) - high = np.append(env.observation_space.high, 1.0) - if env.observation_space.__class__ in [Box, OldBox]: + low = np.append(env.observation_space.low, 0.0) + high = np.append(env.observation_space.high, 1.0) + self.observation_space = Box(low, high, dtype=dtype) else: import pdb @@ -49,7 +49,7 @@ class TimeAwareObservation(gym.ObservationWrapper, gym.utils.RecordConstructorAr Returns: The observation with the time step appended to (relative to total number of steps) """ - return np.append(observation, self.t / getattr(self.env, '_max_episode_steps')) + return np.append(observation, self.t / self.env.spec.max_episode_steps) def step(self, action): """Steps through the environment, incrementing the time step.