Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert wrapper depreciation per #2259 #2273

Merged
merged 1 commit into from
Jul 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions gym/wrappers/atari_preprocessing.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import numpy as np
import warnings
import gym
from gym.spaces import Box
from gym.wrappers import TimeLimit
Expand Down Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions gym/wrappers/clip_action.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import numpy as np
import warnings
from gym import ActionWrapper
from gym.spaces import Box

Expand All @@ -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):
Expand Down
4 changes: 0 additions & 4 deletions gym/wrappers/filter_observation.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import copy
import warnings
from gym import spaces
from gym import ObservationWrapper

Expand All @@ -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()

Expand Down
4 changes: 0 additions & 4 deletions gym/wrappers/flatten_observation.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import gym.spaces as spaces
from gym import ObservationWrapper
import warnings


class FlattenObservation(ObservationWrapper):
Expand All @@ -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)
4 changes: 0 additions & 4 deletions gym/wrappers/frame_stack.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from collections import deque
import numpy as np
import warnings
from gym.spaces import Box
from gym import Wrapper

Expand All @@ -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
Expand Down
5 changes: 1 addition & 4 deletions gym/wrappers/gray_scale_observation.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import numpy as np
import warnings
from gym.spaces import Box
from gym import ObservationWrapper

Expand All @@ -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(
Expand Down
5 changes: 0 additions & 5 deletions gym/wrappers/pixel_observation.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import collections
from collections.abc import MutableMapping
import copy
import warnings
import numpy as np

from gym import spaces
Expand Down Expand Up @@ -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):
Expand Down
4 changes: 0 additions & 4 deletions gym/wrappers/record_episode_statistics.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import time
from collections import deque
import warnings
import gym


Expand All @@ -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)
Expand Down
5 changes: 1 addition & 4 deletions gym/wrappers/rescale_action.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import numpy as np
import warnings
import gym
from gym import spaces

Expand All @@ -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
Expand Down
5 changes: 1 addition & 4 deletions gym/wrappers/resize_observation.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import numpy as np
import warnings
from gym.spaces import Box
from gym import ObservationWrapper

Expand All @@ -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:]
Expand Down
4 changes: 0 additions & 4 deletions gym/wrappers/time_aware_observation.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import numpy as np
import warnings
from gym.spaces import Box
from gym import ObservationWrapper

Expand All @@ -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)
Expand Down
4 changes: 0 additions & 4 deletions gym/wrappers/time_limit.py
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
4 changes: 0 additions & 4 deletions gym/wrappers/transform_observation.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from gym import ObservationWrapper
import warnings


class TransformObservation(ObservationWrapper):
Expand All @@ -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):
Expand Down
4 changes: 0 additions & 4 deletions gym/wrappers/transform_reward.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from gym import RewardWrapper
import warnings


class TransformReward(RewardWrapper):
Expand All @@ -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):
Expand Down