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

Rename "rgb_array" to "rgb_array_list" and "single_rgb_array" to "rgb_array" #3040

Merged
merged 17 commits into from
Sep 1, 2022
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
8 changes: 4 additions & 4 deletions gym/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,11 @@ def render(self) -> Optional[Union[RenderFrame, List[RenderFrame]]]:
- None (default): no render is computed.
- human: render return None.
The environment is continuously rendered in the current display or terminal. Usually for human consumption.
- single_rgb_array: return a single frame representing the current state of the environment.
- rgb_array: return a single frame representing the current state of the environment.
A frame is a numpy.ndarray with shape (x, y, 3) representing RGB values for an x-by-y pixel image.
- rgb_array: return a list of frames representing the states of the environment since the last reset.
Each frame is a numpy.ndarray with shape (x, y, 3), as with single_rgb_array.
- ansi: Return a list of strings (str) or StringIO.StringIO containing a
- rgb_array_list: return a list of frames representing the states of the environment since the last reset.
Each frame is a numpy.ndarray with shape (x, y, 3), as with `rgb_array`.
- ansi: Return a strings (str) or StringIO.StringIO containing a
terminal-style text representation for each time step.
The text can include newlines and ANSI escape sequences (e.g. for colors).

Expand Down
4 changes: 2 additions & 2 deletions gym/envs/box2d/bipedal_walker.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ class BipedalWalker(gym.Env, EzPickle):
"""

metadata = {
"render_modes": ["human", "rgb_array", "single_rgb_array"],
"render_modes": ["human", "rgb_array", "rgb_array_list"],
"render_fps": FPS,
}

Expand Down Expand Up @@ -742,7 +742,7 @@ def _render(self, mode: str = "human"):
pygame.event.pump()
self.clock.tick(self.metadata["render_fps"])
pygame.display.flip()
elif mode in {"rgb_array", "single_rgb_array"}:
elif mode in {"rgb_array", "rgb_array_list"}:
return np.transpose(
np.array(pygame.surfarray.pixels3d(self.surf)), axes=(1, 0, 2)
)[:, -VIEWPORT_W:]
Expand Down
12 changes: 6 additions & 6 deletions gym/envs/box2d/car_racing.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,10 @@ class CarRacing(gym.Env, EzPickle):
metadata = {
"render_modes": [
"human",
"rgb_array_list",
"state_pixels_list",
"rgb_array",
"state_pixels",
"single_rgb_array",
"single_state_pixels",
],
"render_fps": FPS,
}
Expand Down Expand Up @@ -541,7 +541,7 @@ def step(self, action: Union[np.ndarray, int]):
self.world.Step(1.0 / FPS, 6 * 30, 2 * 30)
self.t += 1.0 / FPS

self.state = self._render("single_state_pixels")
self.state = self._render("state_pixels")

step_reward = 0
terminated = False
Expand Down Expand Up @@ -601,7 +601,7 @@ def _render(self, mode: str = "human"):
zoom,
trans,
angle,
mode not in ["state_pixels", "single_state_pixels"],
mode not in ["state_pixels_list", "state_pixels"],
)

self.surf = pygame.transform.flip(self.surf, False, True)
Expand All @@ -623,9 +623,9 @@ def _render(self, mode: str = "human"):
self.screen.blit(self.surf, (0, 0))
pygame.display.flip()

if mode in {"rgb_array", "single_rgb_array"}:
if mode in {"rgb_array", "rgb_array_list"}:
return self._create_image_array(self.surf, (VIDEO_W, VIDEO_H))
elif mode in {"state_pixels", "single_state_pixels"}:
elif mode in {"state_pixels_list", "state_pixels"}:
return self._create_image_array(self.surf, (STATE_W, STATE_H))
else:
return self.isopen
Expand Down
4 changes: 2 additions & 2 deletions gym/envs/box2d/lunar_lander.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ class LunarLander(gym.Env, EzPickle):
"""

metadata = {
"render_modes": ["human", "rgb_array", "single_rgb_array"],
"render_modes": ["human", "rgb_array", "rgb_array_list"],
"render_fps": FPS,
}

Expand Down Expand Up @@ -698,7 +698,7 @@ def _render(self, mode="human"):
pygame.event.pump()
self.clock.tick(self.metadata["render_fps"])
pygame.display.flip()
elif mode in {"rgb_array", "single_rgb_array"}:
elif mode in {"rgb_array", "rgb_array_list"}:
return np.transpose(
np.array(pygame.surfarray.pixels3d(self.surf)), axes=(1, 0, 2)
)
Expand Down
6 changes: 3 additions & 3 deletions gym/envs/classic_control/acrobot.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class AcrobotEnv(core.Env):
"""

metadata = {
"render_modes": ["human", "rgb_array", "single_rgb_array"],
"render_modes": ["human", "rgb_array", "rgb_array_list"],
"render_fps": 15,
}

Expand Down Expand Up @@ -297,7 +297,7 @@ def _render(self, mode="human"):
self.screen = pygame.display.set_mode(
(self.SCREEN_DIM, self.SCREEN_DIM)
)
else: # mode in {"rgb_array", "single_rgb_array"}
else: # mode in {"rgb_array", "rgb_array_list"}
self.screen = pygame.Surface((self.SCREEN_DIM, self.SCREEN_DIM))
if self.clock is None:
self.clock = pygame.time.Clock()
Expand Down Expand Up @@ -358,7 +358,7 @@ def _render(self, mode="human"):
self.clock.tick(self.metadata["render_fps"])
pygame.display.flip()

elif mode in {"rgb_array", "single_rgb_array"}:
elif mode in {"rgb_array", "rgb_array_list"}:
return np.transpose(
np.array(pygame.surfarray.pixels3d(self.screen)), axes=(1, 0, 2)
)
Expand Down
6 changes: 3 additions & 3 deletions gym/envs/classic_control/cartpole.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class CartPoleEnv(gym.Env[np.ndarray, Union[int, np.ndarray]]):
"""

metadata = {
"render_modes": ["human", "rgb_array", "single_rgb_array"],
"render_modes": ["human", "rgb_array", "rgb_array_list"],
"render_fps": 50,
}

Expand Down Expand Up @@ -226,7 +226,7 @@ def _render(self, mode="human"):
self.screen = pygame.display.set_mode(
(self.screen_width, self.screen_height)
)
else: # mode in {"rgb_array", "single_rgb_array"}
else: # mode in {"rgb_array", "rgb_array_list"}
self.screen = pygame.Surface((self.screen_width, self.screen_height))
if self.clock is None:
self.clock = pygame.time.Clock()
Expand Down Expand Up @@ -294,7 +294,7 @@ def _render(self, mode="human"):
self.clock.tick(self.metadata["render_fps"])
pygame.display.flip()

elif mode in {"rgb_array", "single_rgb_array"}:
elif mode in {"rgb_array", "rgb_array_list"}:
return np.transpose(
np.array(pygame.surfarray.pixels3d(self.screen)), axes=(1, 0, 2)
)
Expand Down
6 changes: 3 additions & 3 deletions gym/envs/classic_control/continuous_mountain_car.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class Continuous_MountainCarEnv(gym.Env):
"""

metadata = {
"render_modes": ["human", "rgb_array", "single_rgb_array"],
"render_modes": ["human", "rgb_array", "rgb_array_list"],
"render_fps": 30,
}

Expand Down Expand Up @@ -208,7 +208,7 @@ def _render(self, mode="human"):
self.screen = pygame.display.set_mode(
(self.screen_width, self.screen_height)
)
else: # mode in {"rgb_array", "single_rgb_array"}
else: # mode in {"rgb_array", "rgb_array_list"}
self.screen = pygame.Surface((self.screen_width, self.screen_height))
if self.clock is None:
self.clock = pygame.time.Clock()
Expand Down Expand Up @@ -282,7 +282,7 @@ def _render(self, mode="human"):
self.clock.tick(self.metadata["render_fps"])
pygame.display.flip()

elif mode in {"rgb_array", "single_rgb_array"}:
elif mode in {"rgb_array", "rgb_array_list"}:
return np.transpose(
np.array(pygame.surfarray.pixels3d(self.screen)), axes=(1, 0, 2)
)
Expand Down
6 changes: 3 additions & 3 deletions gym/envs/classic_control/mountain_car.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class MountainCarEnv(gym.Env):
"""

metadata = {
"render_modes": ["human", "rgb_array", "single_rgb_array"],
"render_modes": ["human", "rgb_array", "rgb_array_list"],
"render_fps": 30,
}

Expand Down Expand Up @@ -186,7 +186,7 @@ def _render(self, mode="human"):
self.screen = pygame.display.set_mode(
(self.screen_width, self.screen_height)
)
else: # mode in {"rgb_array", "single_rgb_array"}
else: # mode in {"rgb_array", "rgb_array_list"}
self.screen = pygame.Surface((self.screen_width, self.screen_height))
if self.clock is None:
self.clock = pygame.time.Clock()
Expand Down Expand Up @@ -260,7 +260,7 @@ def _render(self, mode="human"):
self.clock.tick(self.metadata["render_fps"])
pygame.display.flip()

elif mode in {"rgb_array", "single_rgb_array"}:
elif mode in {"rgb_array", "rgb_array_list"}:
return np.transpose(
np.array(pygame.surfarray.pixels3d(self.screen)), axes=(1, 0, 2)
)
Expand Down
6 changes: 3 additions & 3 deletions gym/envs/classic_control/pendulum.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class PendulumEnv(gym.Env):
"""

metadata = {
"render_modes": ["human", "rgb_array", "single_rgb_array"],
"render_modes": ["human", "rgb_array", "rgb_array_list"],
"render_fps": 30,
}

Expand Down Expand Up @@ -182,7 +182,7 @@ def _render(self, mode="human"):
self.screen = pygame.display.set_mode(
(self.screen_dim, self.screen_dim)
)
else: # mode in {"rgb_array", "single_rgb_array"}
else: # mode in {"rgb_array", "rgb_array_list"}
self.screen = pygame.Surface((self.screen_dim, self.screen_dim))
if self.clock is None:
self.clock = pygame.time.Clock()
Expand Down Expand Up @@ -249,7 +249,7 @@ def _render(self, mode="human"):
self.clock.tick(self.metadata["render_fps"])
pygame.display.flip()

else: # mode == "rgb_array":
else: # mode == "rgb_array_list":
return np.transpose(
np.array(pygame.surfarray.pixels3d(self.screen)), axes=(1, 0, 2)
)
Expand Down
4 changes: 2 additions & 2 deletions gym/envs/mujoco/ant.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ class AntEnv(MuJocoPyEnv, utils.EzPickle):
"render_modes": [
"human",
"rgb_array",
"rgb_array_list",
"depth_array",
"single_rgb_array",
"single_depth_array",
"depth_array_list",
],
"render_fps": 20,
}
Expand Down
4 changes: 2 additions & 2 deletions gym/envs/mujoco/ant_v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ class AntEnv(MuJocoPyEnv, utils.EzPickle):
"render_modes": [
"human",
"rgb_array",
"rgb_array_list",
"depth_array",
"single_rgb_array",
"single_depth_array",
"depth_array_list",
],
"render_fps": 20,
}
Expand Down
4 changes: 2 additions & 2 deletions gym/envs/mujoco/ant_v4.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,9 @@ class AntEnv(MujocoEnv, utils.EzPickle):
"render_modes": [
"human",
"rgb_array",
"rgb_array_list",
"depth_array",
"single_rgb_array",
"single_depth_array",
"depth_array_list",
],
"render_fps": 20,
}
Expand Down
4 changes: 2 additions & 2 deletions gym/envs/mujoco/half_cheetah.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ class HalfCheetahEnv(MuJocoPyEnv, utils.EzPickle):
"render_modes": [
"human",
"rgb_array",
"rgb_array_list",
"depth_array",
"single_rgb_array",
"single_depth_array",
"depth_array_list",
],
"render_fps": 20,
}
Expand Down
4 changes: 2 additions & 2 deletions gym/envs/mujoco/half_cheetah_v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ class HalfCheetahEnv(MuJocoPyEnv, utils.EzPickle):
"render_modes": [
"human",
"rgb_array",
"rgb_array_list",
"depth_array",
"single_rgb_array",
"single_depth_array",
"depth_array_list",
],
"render_fps": 20,
}
Expand Down
4 changes: 2 additions & 2 deletions gym/envs/mujoco/half_cheetah_v4.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,9 @@ class HalfCheetahEnv(MujocoEnv, utils.EzPickle):
"render_modes": [
"human",
"rgb_array",
"rgb_array_list",
"depth_array",
"single_rgb_array",
"single_depth_array",
"depth_array_list",
],
"render_fps": 20,
}
Expand Down
4 changes: 2 additions & 2 deletions gym/envs/mujoco/hopper.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ class HopperEnv(MuJocoPyEnv, utils.EzPickle):
"render_modes": [
"human",
"rgb_array",
"rgb_array_list",
"depth_array",
"single_rgb_array",
"single_depth_array",
"depth_array_list",
],
"render_fps": 125,
}
Expand Down
4 changes: 2 additions & 2 deletions gym/envs/mujoco/hopper_v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ class HopperEnv(MuJocoPyEnv, utils.EzPickle):
"render_modes": [
"human",
"rgb_array",
"rgb_array_list",
"depth_array",
"single_rgb_array",
"single_depth_array",
"depth_array_list",
],
"render_fps": 125,
}
Expand Down
4 changes: 2 additions & 2 deletions gym/envs/mujoco/hopper_v4.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@ class HopperEnv(MujocoEnv, utils.EzPickle):
"render_modes": [
"human",
"rgb_array",
"rgb_array_list",
"depth_array",
"single_rgb_array",
"single_depth_array",
"depth_array_list",
],
"render_fps": 125,
}
Expand Down
4 changes: 2 additions & 2 deletions gym/envs/mujoco/humanoid.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ class HumanoidEnv(MuJocoPyEnv, utils.EzPickle):
"render_modes": [
"human",
"rgb_array",
"rgb_array_list",
"depth_array",
"single_rgb_array",
"single_depth_array",
"depth_array_list",
],
"render_fps": 67,
}
Expand Down
4 changes: 2 additions & 2 deletions gym/envs/mujoco/humanoid_v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ class HumanoidEnv(MuJocoPyEnv, utils.EzPickle):
"render_modes": [
"human",
"rgb_array",
"rgb_array_list",
"depth_array",
"single_rgb_array",
"single_depth_array",
"depth_array_list",
],
"render_fps": 67,
}
Expand Down
4 changes: 2 additions & 2 deletions gym/envs/mujoco/humanoid_v4.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,9 @@ class HumanoidEnv(MujocoEnv, utils.EzPickle):
"render_modes": [
"human",
"rgb_array",
"rgb_array_list",
"depth_array",
"single_rgb_array",
"single_depth_array",
"depth_array_list",
],
"render_fps": 67,
}
Expand Down
4 changes: 2 additions & 2 deletions gym/envs/mujoco/humanoidstandup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ class HumanoidStandupEnv(MuJocoPyEnv, utils.EzPickle):
"render_modes": [
"human",
"rgb_array",
"rgb_array_list",
"depth_array",
"single_rgb_array",
"single_depth_array",
"depth_array_list",
],
"render_fps": 67,
}
Expand Down
4 changes: 2 additions & 2 deletions gym/envs/mujoco/humanoidstandup_v4.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,9 @@ class HumanoidStandupEnv(MujocoEnv, utils.EzPickle):
"render_modes": [
"human",
"rgb_array",
"rgb_array_list",
"depth_array",
"single_rgb_array",
"single_depth_array",
"depth_array_list",
],
"render_fps": 67,
}
Expand Down
Loading