From 3abd5d55afa9c43fe5f7da2b1a42f064c14127b0 Mon Sep 17 00:00:00 2001 From: J K Terry Date: Thu, 29 Jul 2021 17:51:02 -0400 Subject: [PATCH] remove wrapper deprication (#2273) --- gym/wrappers/atari_preprocessing.py | 4 ---- gym/wrappers/clip_action.py | 4 ---- gym/wrappers/filter_observation.py | 4 ---- gym/wrappers/flatten_observation.py | 4 ---- gym/wrappers/frame_stack.py | 4 ---- gym/wrappers/gray_scale_observation.py | 5 +---- gym/wrappers/pixel_observation.py | 5 ----- gym/wrappers/record_episode_statistics.py | 4 ---- gym/wrappers/rescale_action.py | 5 +---- gym/wrappers/resize_observation.py | 5 +---- gym/wrappers/time_aware_observation.py | 4 ---- gym/wrappers/time_limit.py | 4 ---- gym/wrappers/transform_observation.py | 4 ---- gym/wrappers/transform_reward.py | 4 ---- 14 files changed, 3 insertions(+), 57 deletions(-) diff --git a/gym/wrappers/atari_preprocessing.py b/gym/wrappers/atari_preprocessing.py index c0bce958686..1d4df5c8b2a 100644 --- a/gym/wrappers/atari_preprocessing.py +++ b/gym/wrappers/atari_preprocessing.py @@ -1,5 +1,4 @@ import numpy as np -import warnings import gym from gym.spaces import Box from gym.wrappers import TimeLimit @@ -67,9 +66,6 @@ def __init__( ) self.noop_max = noop_max assert env.unwrapped.get_action_meanings()[0] == "NOOP" - warnings.warn( - "Gym's internal preprocessing wrappers are now deprecated. While they will continue to work for the foreseeable future, we strongly recommend using SuperSuit instead: https://github.com/PettingZoo-Team/SuperSuit" - ) self.frame_skip = frame_skip self.screen_size = screen_size diff --git a/gym/wrappers/clip_action.py b/gym/wrappers/clip_action.py index bb096f13c3a..64227dcb108 100644 --- a/gym/wrappers/clip_action.py +++ b/gym/wrappers/clip_action.py @@ -1,5 +1,4 @@ import numpy as np -import warnings from gym import ActionWrapper from gym.spaces import Box @@ -9,9 +8,6 @@ class ClipAction(ActionWrapper): def __init__(self, env): assert isinstance(env.action_space, Box) - warnings.warn( - "Gym's internal preprocessing wrappers are now deprecated. While they will continue to work for the foreseeable future, we strongly recommend using SuperSuit instead: https://github.com/PettingZoo-Team/SuperSuit" - ) super(ClipAction, self).__init__(env) def action(self, action): diff --git a/gym/wrappers/filter_observation.py b/gym/wrappers/filter_observation.py index fb738e25ef1..0f52c04492b 100644 --- a/gym/wrappers/filter_observation.py +++ b/gym/wrappers/filter_observation.py @@ -1,5 +1,4 @@ import copy -import warnings from gym import spaces from gym import ObservationWrapper @@ -26,9 +25,6 @@ def __init__(self, env, filter_keys=None): assert isinstance( wrapped_observation_space, spaces.Dict ), "FilterObservationWrapper is only usable with dict observations." - warnings.warn( - "Gym's internal preprocessing wrappers are now deprecated. While they will continue to work for the foreseeable future, we strongly recommend using SuperSuit instead: https://github.com/PettingZoo-Team/SuperSuit" - ) observation_keys = wrapped_observation_space.spaces.keys() diff --git a/gym/wrappers/flatten_observation.py b/gym/wrappers/flatten_observation.py index b78cb424823..9dca4da256a 100644 --- a/gym/wrappers/flatten_observation.py +++ b/gym/wrappers/flatten_observation.py @@ -1,6 +1,5 @@ import gym.spaces as spaces from gym import ObservationWrapper -import warnings class FlattenObservation(ObservationWrapper): @@ -9,9 +8,6 @@ class FlattenObservation(ObservationWrapper): def __init__(self, env): super(FlattenObservation, self).__init__(env) self.observation_space = spaces.flatten_space(env.observation_space) - warnings.warn( - "Gym's internal preprocessing wrappers are now deprecated. While they will continue to work for the foreseeable future, we strongly recommend using SuperSuit instead: https://github.com/PettingZoo-Team/SuperSuit" - ) def observation(self, observation): return spaces.flatten(self.env.observation_space, observation) diff --git a/gym/wrappers/frame_stack.py b/gym/wrappers/frame_stack.py index d5fff0b1de5..637ade012ac 100644 --- a/gym/wrappers/frame_stack.py +++ b/gym/wrappers/frame_stack.py @@ -1,6 +1,5 @@ from collections import deque import numpy as np -import warnings from gym.spaces import Box from gym import Wrapper @@ -22,9 +21,6 @@ class LazyFrames(object): __slots__ = ("frame_shape", "dtype", "shape", "lz4_compress", "_frames") def __init__(self, frames, lz4_compress=False): - warnings.warn( - "Gym's internal preprocessing wrappers are now deprecated. While they will continue to work for the foreseeable future, we strongly recommend using SuperSuit instead: https://github.com/PettingZoo-Team/SuperSuit" - ) self.frame_shape = tuple(frames[0].shape) self.shape = (len(frames),) + self.frame_shape self.dtype = frames[0].dtype diff --git a/gym/wrappers/gray_scale_observation.py b/gym/wrappers/gray_scale_observation.py index 572008a6fa5..5e789ba94f4 100644 --- a/gym/wrappers/gray_scale_observation.py +++ b/gym/wrappers/gray_scale_observation.py @@ -1,5 +1,4 @@ import numpy as np -import warnings from gym.spaces import Box from gym import ObservationWrapper @@ -15,9 +14,7 @@ def __init__(self, env, keep_dim=False): len(env.observation_space.shape) == 3 and env.observation_space.shape[-1] == 3 ) - warnings.warn( - "Gym's internal preprocessing wrappers are now deprecated. While they will continue to work for the foreseeable future, we strongly recommend using SuperSuit instead: https://github.com/PettingZoo-Team/SuperSuit" - ) + obs_shape = self.observation_space.shape[:2] if self.keep_dim: self.observation_space = Box( diff --git a/gym/wrappers/pixel_observation.py b/gym/wrappers/pixel_observation.py index 7311c847c48..80c8d943f1c 100644 --- a/gym/wrappers/pixel_observation.py +++ b/gym/wrappers/pixel_observation.py @@ -1,7 +1,6 @@ import collections from collections.abc import MutableMapping import copy -import warnings import numpy as np from gym import spaces @@ -52,10 +51,6 @@ def __init__( assert render_mode == "rgb_array", render_mode render_kwargs[key]["mode"] = "rgb_array" - warnings.warn( - "Gym's internal preprocessing wrappers are now deprecated. While they will continue to work for the foreseeable future, we strongly recommend using SuperSuit instead: https://github.com/PettingZoo-Team/SuperSuit" - ) - wrapped_observation_space = env.observation_space if isinstance(wrapped_observation_space, spaces.Box): diff --git a/gym/wrappers/record_episode_statistics.py b/gym/wrappers/record_episode_statistics.py index 08b10a667f5..9ce1e7f086d 100644 --- a/gym/wrappers/record_episode_statistics.py +++ b/gym/wrappers/record_episode_statistics.py @@ -1,6 +1,5 @@ import time from collections import deque -import warnings import gym @@ -14,9 +13,6 @@ def __init__(self, env, deque_size=100): self.episode_length = 0 self.return_queue = deque(maxlen=deque_size) self.length_queue = deque(maxlen=deque_size) - warnings.warn( - "Gym's internal preprocessing wrappers are now deprecated. While they will continue to work for the foreseeable future, we strongly recommend using SuperSuit instead: https://github.com/PettingZoo-Team/SuperSuit" - ) def reset(self, **kwargs): observation = super(RecordEpisodeStatistics, self).reset(**kwargs) diff --git a/gym/wrappers/rescale_action.py b/gym/wrappers/rescale_action.py index a8743e65b9e..af41f4e8e1f 100644 --- a/gym/wrappers/rescale_action.py +++ b/gym/wrappers/rescale_action.py @@ -1,5 +1,4 @@ import numpy as np -import warnings import gym from gym import spaces @@ -19,9 +18,7 @@ def __init__(self, env, a, b): env.action_space, spaces.Box ), "expected Box action space, got {}".format(type(env.action_space)) assert np.less_equal(a, b).all(), (a, b) - warnings.warn( - "Gym's internal preprocessing wrappers are now deprecated. While they will continue to work for the foreseeable future, we strongly recommend using SuperSuit instead: https://github.com/PettingZoo-Team/SuperSuit" - ) + super(RescaleAction, self).__init__(env) self.a = np.zeros(env.action_space.shape, dtype=env.action_space.dtype) + a self.b = np.zeros(env.action_space.shape, dtype=env.action_space.dtype) + b diff --git a/gym/wrappers/resize_observation.py b/gym/wrappers/resize_observation.py index ba2fccede15..4227932e51e 100644 --- a/gym/wrappers/resize_observation.py +++ b/gym/wrappers/resize_observation.py @@ -1,5 +1,4 @@ import numpy as np -import warnings from gym.spaces import Box from gym import ObservationWrapper @@ -12,9 +11,7 @@ def __init__(self, env, shape): if isinstance(shape, int): shape = (shape, shape) assert all(x > 0 for x in shape), shape - warnings.warn( - "Gym's internal preprocessing wrappers are now deprecated. While they will continue to work for the foreseeable future, we strongly recommend using SuperSuit instead: https://github.com/PettingZoo-Team/SuperSuit" - ) + self.shape = tuple(shape) obs_shape = self.shape + self.observation_space.shape[2:] diff --git a/gym/wrappers/time_aware_observation.py b/gym/wrappers/time_aware_observation.py index f10e01b55df..71ec32f5bfc 100644 --- a/gym/wrappers/time_aware_observation.py +++ b/gym/wrappers/time_aware_observation.py @@ -1,5 +1,4 @@ import numpy as np -import warnings from gym.spaces import Box from gym import ObservationWrapper @@ -17,9 +16,6 @@ def __init__(self, env): super(TimeAwareObservation, self).__init__(env) assert isinstance(env.observation_space, Box) assert env.observation_space.dtype == np.float32 - warnings.warn( - "Gym's internal preprocessing wrappers are now deprecated. While they will continue to work for the foreseeable future, we strongly recommend using SuperSuit instead: https://github.com/PettingZoo-Team/SuperSuit" - ) low = np.append(self.observation_space.low, 0.0) high = np.append(self.observation_space.high, np.inf) self.observation_space = Box(low, high, dtype=np.float32) diff --git a/gym/wrappers/time_limit.py b/gym/wrappers/time_limit.py index 39a45ae157b..ee8cac96f4e 100644 --- a/gym/wrappers/time_limit.py +++ b/gym/wrappers/time_limit.py @@ -1,13 +1,9 @@ import gym -import warnings class TimeLimit(gym.Wrapper): def __init__(self, env, max_episode_steps=None): super(TimeLimit, self).__init__(env) - warnings.warn( - "Gym's internal preprocessing wrappers are now deprecated. While they will continue to work for the foreseeable future, we strongly recommend using SuperSuit instead: https://github.com/PettingZoo-Team/SuperSuit" - ) if max_episode_steps is None and self.env.spec is not None: max_episode_steps = env.spec.max_episode_steps if self.env.spec is not None: diff --git a/gym/wrappers/transform_observation.py b/gym/wrappers/transform_observation.py index 02f4eac2c5b..ade8f935779 100644 --- a/gym/wrappers/transform_observation.py +++ b/gym/wrappers/transform_observation.py @@ -1,5 +1,4 @@ from gym import ObservationWrapper -import warnings class TransformObservation(ObservationWrapper): @@ -22,9 +21,6 @@ class TransformObservation(ObservationWrapper): def __init__(self, env, f): super(TransformObservation, self).__init__(env) assert callable(f) - warnings.warn( - "Gym's internal preprocessing wrappers are now deprecated. While they will continue to work for the foreseeable future, we strongly recommend using SuperSuit instead: https://github.com/PettingZoo-Team/SuperSuit" - ) self.f = f def observation(self, observation): diff --git a/gym/wrappers/transform_reward.py b/gym/wrappers/transform_reward.py index 20dde050f47..cd90c5ebfa6 100644 --- a/gym/wrappers/transform_reward.py +++ b/gym/wrappers/transform_reward.py @@ -1,5 +1,4 @@ from gym import RewardWrapper -import warnings class TransformReward(RewardWrapper): @@ -24,9 +23,6 @@ class TransformReward(RewardWrapper): def __init__(self, env, f): super(TransformReward, self).__init__(env) assert callable(f) - warnings.warn( - "Gym's internal preprocessing wrappers are now deprecated. While they will continue to work for the foreseeable future, we strongly recommend using SuperSuit instead: https://github.com/PettingZoo-Team/SuperSuit" - ) self.f = f def reward(self, reward):