Skip to content

Commit

Permalink
Revert "ENH: allow metadata["render_modes"] to be a set" (openai#251)
Browse files Browse the repository at this point in the history
  • Loading branch information
pseudo-rnd-thoughts authored Jan 9, 2023
1 parent 3413b04 commit 1dfdf45
Show file tree
Hide file tree
Showing 57 changed files with 103 additions and 103 deletions.
3 changes: 2 additions & 1 deletion docs/tutorials/environment_creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@


class GridWorldEnv(gym.Env):
metadata = {"render_modes": {"human", "rgb_array"}, "render_fps": 4}
metadata = {"render_modes": ["human", "rgb_array"], "render_fps": 4}

def __init__(self, render_mode=None, size=5):
self.size = size # The size of the square grid
Expand Down Expand Up @@ -130,6 +130,7 @@ def __init__(self, render_mode=None, size=5):
3: np.array([0, -1]),
}

assert render_mode is None or render_mode in self.metadata["render_modes"]
self.render_mode = render_mode

"""
Expand Down
2 changes: 1 addition & 1 deletion gymnasium/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class Env(Generic[ObsType, ActType]):
"""

# Set this in SOME subclasses
metadata: dict[str, Any] = {"render_modes": {}}
metadata: dict[str, Any] = {"render_modes": []}
# define render_mode if your environment supports rendering
render_mode: str | None = None
reward_range = (-float("inf"), float("inf"))
Expand Down
2 changes: 1 addition & 1 deletion gymnasium/envs/box2d/bipedal_walker.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ class BipedalWalker(gym.Env, EzPickle):
"""

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

Expand Down
4 changes: 2 additions & 2 deletions gymnasium/envs/box2d/car_racing.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,11 @@ class CarRacing(gym.Env, EzPickle):
"""

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

Expand Down
2 changes: 1 addition & 1 deletion gymnasium/envs/box2d/lunar_lander.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ class LunarLander(gym.Env, EzPickle):
"""

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

Expand Down
2 changes: 1 addition & 1 deletion gymnasium/envs/classic_control/acrobot.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class AcrobotEnv(Env):
"""

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

Expand Down
2 changes: 1 addition & 1 deletion gymnasium/envs/classic_control/cartpole.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class CartPoleEnv(gym.Env[np.ndarray, Union[int, np.ndarray]]):
"""

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

Expand Down
2 changes: 1 addition & 1 deletion gymnasium/envs/classic_control/continuous_mountain_car.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class Continuous_MountainCarEnv(gym.Env):
"""

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

Expand Down
2 changes: 1 addition & 1 deletion gymnasium/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"},
"render_modes": ["human", "rgb_array"],
"render_fps": 30,
}

Expand Down
2 changes: 1 addition & 1 deletion gymnasium/envs/classic_control/pendulum.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class PendulumEnv(gym.Env):
"""

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

Expand Down
4 changes: 2 additions & 2 deletions gymnasium/envs/mujoco/ant.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

class AntEnv(MuJocoPyEnv, utils.EzPickle):
metadata = {
"render_modes": {
"render_modes": [
"human",
"rgb_array",
"depth_array",
},
],
"render_fps": 20,
}

Expand Down
4 changes: 2 additions & 2 deletions gymnasium/envs/mujoco/ant_v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@

class AntEnv(MuJocoPyEnv, utils.EzPickle):
metadata = {
"render_modes": {
"render_modes": [
"human",
"rgb_array",
"depth_array",
},
],
"render_fps": 20,
}

Expand Down
4 changes: 2 additions & 2 deletions gymnasium/envs/mujoco/ant_v4.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,11 @@ class AntEnv(MujocoEnv, utils.EzPickle):
"""

metadata = {
"render_modes": {
"render_modes": [
"human",
"rgb_array",
"depth_array",
},
],
"render_fps": 20,
}

Expand Down
4 changes: 2 additions & 2 deletions gymnasium/envs/mujoco/half_cheetah.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

class HalfCheetahEnv(MuJocoPyEnv, utils.EzPickle):
metadata = {
"render_modes": {
"render_modes": [
"human",
"rgb_array",
"depth_array",
},
],
"render_fps": 20,
}

Expand Down
4 changes: 2 additions & 2 deletions gymnasium/envs/mujoco/half_cheetah_v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@

class HalfCheetahEnv(MuJocoPyEnv, utils.EzPickle):
metadata = {
"render_modes": {
"render_modes": [
"human",
"rgb_array",
"depth_array",
},
],
"render_fps": 20,
}

Expand Down
4 changes: 2 additions & 2 deletions gymnasium/envs/mujoco/half_cheetah_v4.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,11 @@ class HalfCheetahEnv(MujocoEnv, utils.EzPickle):
"""

metadata = {
"render_modes": {
"render_modes": [
"human",
"rgb_array",
"depth_array",
},
],
"render_fps": 20,
}

Expand Down
4 changes: 2 additions & 2 deletions gymnasium/envs/mujoco/hopper.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

class HopperEnv(MuJocoPyEnv, utils.EzPickle):
metadata = {
"render_modes": {
"render_modes": [
"human",
"rgb_array",
"depth_array",
},
],
"render_fps": 125,
}

Expand Down
4 changes: 2 additions & 2 deletions gymnasium/envs/mujoco/hopper_v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@

class HopperEnv(MuJocoPyEnv, utils.EzPickle):
metadata = {
"render_modes": {
"render_modes": [
"human",
"rgb_array",
"depth_array",
},
],
"render_fps": 125,
}

Expand Down
4 changes: 2 additions & 2 deletions gymnasium/envs/mujoco/hopper_v4.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,11 @@ class HopperEnv(MujocoEnv, utils.EzPickle):
"""

metadata = {
"render_modes": {
"render_modes": [
"human",
"rgb_array",
"depth_array",
},
],
"render_fps": 125,
}

Expand Down
4 changes: 2 additions & 2 deletions gymnasium/envs/mujoco/humanoid.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ def mass_center(model, sim):

class HumanoidEnv(MuJocoPyEnv, utils.EzPickle):
metadata = {
"render_modes": {
"render_modes": [
"human",
"rgb_array",
"depth_array",
},
],
"render_fps": 67,
}

Expand Down
4 changes: 2 additions & 2 deletions gymnasium/envs/mujoco/humanoid_v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ def mass_center(model, sim):

class HumanoidEnv(MuJocoPyEnv, utils.EzPickle):
metadata = {
"render_modes": {
"render_modes": [
"human",
"rgb_array",
"depth_array",
},
],
"render_fps": 67,
}

Expand Down
4 changes: 2 additions & 2 deletions gymnasium/envs/mujoco/humanoid_v4.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,11 @@ class HumanoidEnv(MujocoEnv, utils.EzPickle):
"""

metadata = {
"render_modes": {
"render_modes": [
"human",
"rgb_array",
"depth_array",
},
],
"render_fps": 67,
}

Expand Down
4 changes: 2 additions & 2 deletions gymnasium/envs/mujoco/humanoidstandup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

class HumanoidStandupEnv(MuJocoPyEnv, utils.EzPickle):
metadata = {
"render_modes": {
"render_modes": [
"human",
"rgb_array",
"depth_array",
},
],
"render_fps": 67,
}

Expand Down
4 changes: 2 additions & 2 deletions gymnasium/envs/mujoco/humanoidstandup_v4.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,11 @@ class HumanoidStandupEnv(MujocoEnv, utils.EzPickle):
"""

metadata = {
"render_modes": {
"render_modes": [
"human",
"rgb_array",
"depth_array",
},
],
"render_fps": 67,
}

Expand Down
4 changes: 2 additions & 2 deletions gymnasium/envs/mujoco/inverted_double_pendulum.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

class InvertedDoublePendulumEnv(MuJocoPyEnv, utils.EzPickle):
metadata = {
"render_modes": {
"render_modes": [
"human",
"rgb_array",
"depth_array",
},
],
"render_fps": 20,
}

Expand Down
4 changes: 2 additions & 2 deletions gymnasium/envs/mujoco/inverted_double_pendulum_v4.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,11 @@ class InvertedDoublePendulumEnv(MujocoEnv, utils.EzPickle):
"""

metadata = {
"render_modes": {
"render_modes": [
"human",
"rgb_array",
"depth_array",
},
],
"render_fps": 20,
}

Expand Down
4 changes: 2 additions & 2 deletions gymnasium/envs/mujoco/inverted_pendulum.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

class InvertedPendulumEnv(MuJocoPyEnv, utils.EzPickle):
metadata = {
"render_modes": {
"render_modes": [
"human",
"rgb_array",
"depth_array",
},
],
"render_fps": 25,
}

Expand Down
4 changes: 2 additions & 2 deletions gymnasium/envs/mujoco/inverted_pendulum_v4.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ class InvertedPendulumEnv(MujocoEnv, utils.EzPickle):
"""

metadata = {
"render_modes": {
"render_modes": [
"human",
"rgb_array",
"depth_array",
},
],
"render_fps": 25,
}

Expand Down
4 changes: 2 additions & 2 deletions gymnasium/envs/mujoco/mujoco_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ def __init__(

self.frame_skip = frame_skip

assert self.metadata["render_modes"] == {
assert self.metadata["render_modes"] == [
"human",
"rgb_array",
"depth_array",
}, self.metadata["render_modes"]
], self.metadata["render_modes"]
assert (
int(np.round(1.0 / self.dt)) == self.metadata["render_fps"]
), f'Expected value: {int(np.round(1.0 / self.dt))}, Actual value: {self.metadata["render_fps"]}'
Expand Down
4 changes: 2 additions & 2 deletions gymnasium/envs/mujoco/pusher.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

class PusherEnv(MuJocoPyEnv, utils.EzPickle):
metadata = {
"render_modes": {
"render_modes": [
"human",
"rgb_array",
"depth_array",
},
],
"render_fps": 20,
}

Expand Down
4 changes: 2 additions & 2 deletions gymnasium/envs/mujoco/pusher_v4.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,11 @@ class PusherEnv(MujocoEnv, utils.EzPickle):
"""

metadata = {
"render_modes": {
"render_modes": [
"human",
"rgb_array",
"depth_array",
},
],
"render_fps": 20,
}

Expand Down
Loading

0 comments on commit 1dfdf45

Please sign in to comment.