diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index ffe5ea193..9388e767b 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -14,4 +14,4 @@ jobs:
--build-arg PYTHON_VERSION=${{ matrix.python-version }} \
--tag gym-docker .
- name: Run tests
- run: docker run gym-docker pytest
+ run: docker run gymnasium-docker pytest
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 1359be7a9..60f5df1c2 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -15,7 +15,7 @@ repos:
hooks:
- id: flake8
args:
- - '--per-file-ignores=*/__init__.py:F401 gym/envs/registration.py:E704'
+ - '--per-file-ignores=*/__init__.py:F401 gymnasium/envs/registration.py:E704'
- --ignore=E203,W503,E741
- --max-complexity=30
- --max-line-length=456
@@ -30,7 +30,7 @@ repos:
rev: 6.1.1 # pick a git hash / tag to point to
hooks:
- id: pydocstyle
- exclude: ^(gym/version.py)|(gym/envs/)|(tests/)
+ exclude: ^(gymnasium/version.py)|(gymnasium/envs/)|(tests/)
args:
- --source
- --explain
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 640a82f61..1b7161052 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -1,21 +1,15 @@
-# Gym Contribution Guidelines
+# Gymnasium Contribution Guidelines
At this time we are currently accepting the current forms of contributions:
- Bug reports (keep in mind that changing environment behavior should be minimized as that requires releasing a new version of the environment and makes results hard to compare across versions)
- Pull requests for bug fixes
- Documentation improvements
+- Features
Notably, we are not accepting these forms of contributions:
- New environments
-- New features
-
-This may change in the future.
-If you wish to make a Gym environment, follow the instructions in [Creating Environments](https://github.com/openai/gym/blob/master/docs/creating_environments.md). When your environment works, you can make a PR to add it to the bottom of the [List of Environments](https://github.com/openai/gym/blob/master/docs/third_party_environments.md).
-
-
-Edit July 27, 2021: Please see https://github.com/openai/gym/issues/2259 for new contributing standards
# Development
This section contains technical instructions & hints for the contributors.
diff --git a/README.md b/README.md
index 33e591692..116b39635 100644
--- a/README.md
+++ b/README.md
@@ -25,13 +25,13 @@ We support Python 3.7, 3.8, 3.9 and 3.10 on Linux and macOS. We will accept PRs
The Gym API's API models environments as simple Python `env` classes. Creating environment instances and interacting with them is very simple- here's an example using the "CartPole-v1" environment:
```python
-import gym
+import gymnasium as gym
env = gym.make("CartPole-v1")
observation, info = env.reset(seed=42)
for _ in range(1000):
action = env.action_space.sample()
- observation, reward, terminated, truncarted, info = env.step(action)
+ observation, reward, terminated, truncated, info = env.step(action)
if terminated or truncated:
observation, info = env.reset()
@@ -43,7 +43,7 @@ env.close()
* [Stable Baselines 3](https://github.com/DLR-RM/stable-baselines3) is a learning library based on the Gym API. It is designed to cater to complete beginners in the field who want to start learning things quickly.
* [RL Baselines3 Zoo](https://github.com/DLR-RM/rl-baselines3-zoo) builds upon SB3, containing optimal hyperparameters for Gym environments as well as code to easily find new ones.
* [Tianshou](https://github.com/thu-ml/tianshou) is a learning library that's geared towards very experienced users and is design to allow for ease in complex algorithm modifications.
-* [RLlib](https://docs.ray.io/en/latest/rllib/index.html) is a learning library that allows for distributed training and inferencing and supports an extraordinarily large number of features throughout the reinforcement learning space.
+* [RLlib](https://docs.ray.io/en/latest/rllib/index.html) is a learning library that allows for distributed training and inference and supports an extraordinarily large number of features throughout the reinforcement learning space.
* [PettingZoo](https://github.com/Farama-Foundation/PettingZoo) is like Gym, but for environments with multiple agents.
## Environment Versioning
@@ -70,4 +70,4 @@ A whitepaper from when Gym just came out is available https://arxiv.org/pdf/1606
## Release Notes
-There used to be release notes for all the new Gym versions here. New release notes are being moved to [releases page](https://github.com/openai/gym/releases) on GitHub, like most other libraries do. Old notes can be viewed [here](https://github.com/openai/gym/blob/31be35ecd460f670f0c4b653a14c9996b7facc6c/README.rst).
+There used to be release notes for all the new Gym versions here. New release notes are being moved to [releases page](https://github.com/Farama-Foundation/Gymnasium/releases) on GitHub, like most other libraries do.
diff --git a/gym/envs/box2d/__init__.py b/gym/envs/box2d/__init__.py
deleted file mode 100644
index e702010b6..000000000
--- a/gym/envs/box2d/__init__.py
+++ /dev/null
@@ -1,3 +0,0 @@
-from gym.envs.box2d.bipedal_walker import BipedalWalker, BipedalWalkerHardcore
-from gym.envs.box2d.car_racing import CarRacing
-from gym.envs.box2d.lunar_lander import LunarLander, LunarLanderContinuous
diff --git a/gym/envs/classic_control/__init__.py b/gym/envs/classic_control/__init__.py
deleted file mode 100644
index 308185f39..000000000
--- a/gym/envs/classic_control/__init__.py
+++ /dev/null
@@ -1,5 +0,0 @@
-from gym.envs.classic_control.acrobot import AcrobotEnv
-from gym.envs.classic_control.cartpole import CartPoleEnv
-from gym.envs.classic_control.continuous_mountain_car import Continuous_MountainCarEnv
-from gym.envs.classic_control.mountain_car import MountainCarEnv
-from gym.envs.classic_control.pendulum import PendulumEnv
diff --git a/gym/envs/mujoco/__init__.py b/gym/envs/mujoco/__init__.py
deleted file mode 100644
index b31265ae5..000000000
--- a/gym/envs/mujoco/__init__.py
+++ /dev/null
@@ -1,19 +0,0 @@
-from gym.envs.mujoco.mujoco_env import MujocoEnv, MuJocoPyEnv # isort:skip
-from gym.envs.mujoco.mujoco_rendering import ( # isort:skip
- RenderContextOffscreen,
- Viewer,
-)
-
-# ^^^^^ so that user gets the correct error
-# message if mujoco is not installed correctly
-from gym.envs.mujoco.ant import AntEnv
-from gym.envs.mujoco.half_cheetah import HalfCheetahEnv
-from gym.envs.mujoco.hopper import HopperEnv
-from gym.envs.mujoco.humanoid import HumanoidEnv
-from gym.envs.mujoco.humanoidstandup import HumanoidStandupEnv
-from gym.envs.mujoco.inverted_double_pendulum import InvertedDoublePendulumEnv
-from gym.envs.mujoco.inverted_pendulum import InvertedPendulumEnv
-from gym.envs.mujoco.pusher import PusherEnv
-from gym.envs.mujoco.reacher import ReacherEnv
-from gym.envs.mujoco.swimmer import SwimmerEnv
-from gym.envs.mujoco.walker2d import Walker2dEnv
diff --git a/gym/envs/toy_text/__init__.py b/gym/envs/toy_text/__init__.py
deleted file mode 100644
index 36e120795..000000000
--- a/gym/envs/toy_text/__init__.py
+++ /dev/null
@@ -1,4 +0,0 @@
-from gym.envs.toy_text.blackjack import BlackjackEnv
-from gym.envs.toy_text.cliffwalking import CliffWalkingEnv
-from gym.envs.toy_text.frozen_lake import FrozenLakeEnv
-from gym.envs.toy_text.taxi import TaxiEnv
diff --git a/gym/vector/utils/__init__.py b/gym/vector/utils/__init__.py
deleted file mode 100644
index c03f85335..000000000
--- a/gym/vector/utils/__init__.py
+++ /dev/null
@@ -1,23 +0,0 @@
-"""Module for gym vector utils."""
-from gym.vector.utils.misc import CloudpickleWrapper, clear_mpi_env_vars
-from gym.vector.utils.numpy_utils import concatenate, create_empty_array
-from gym.vector.utils.shared_memory import (
- create_shared_memory,
- read_from_shared_memory,
- write_to_shared_memory,
-)
-from gym.vector.utils.spaces import _BaseGymSpaces # pyright: reportPrivateUsage=false
-from gym.vector.utils.spaces import BaseGymSpaces, batch_space, iterate
-
-__all__ = [
- "CloudpickleWrapper",
- "clear_mpi_env_vars",
- "concatenate",
- "create_empty_array",
- "create_shared_memory",
- "read_from_shared_memory",
- "write_to_shared_memory",
- "BaseGymSpaces",
- "batch_space",
- "iterate",
-]
diff --git a/gym/wrappers/__init__.py b/gym/wrappers/__init__.py
deleted file mode 100644
index fdf2de530..000000000
--- a/gym/wrappers/__init__.py
+++ /dev/null
@@ -1,23 +0,0 @@
-"""Module of wrapper classes."""
-from gym import error
-from gym.wrappers.atari_preprocessing import AtariPreprocessing
-from gym.wrappers.autoreset import AutoResetWrapper
-from gym.wrappers.clip_action import ClipAction
-from gym.wrappers.filter_observation import FilterObservation
-from gym.wrappers.flatten_observation import FlattenObservation
-from gym.wrappers.frame_stack import FrameStack, LazyFrames
-from gym.wrappers.gray_scale_observation import GrayScaleObservation
-from gym.wrappers.human_rendering import HumanRendering
-from gym.wrappers.normalize import NormalizeObservation, NormalizeReward
-from gym.wrappers.order_enforcing import OrderEnforcing
-from gym.wrappers.record_episode_statistics import RecordEpisodeStatistics
-from gym.wrappers.record_video import RecordVideo, capped_cubic_video_schedule
-from gym.wrappers.render_collection import RenderCollection
-from gym.wrappers.rescale_action import RescaleAction
-from gym.wrappers.resize_observation import ResizeObservation
-from gym.wrappers.step_api_compatibility import StepAPICompatibility
-from gym.wrappers.time_aware_observation import TimeAwareObservation
-from gym.wrappers.time_limit import TimeLimit
-from gym.wrappers.transform_observation import TransformObservation
-from gym.wrappers.transform_reward import TransformReward
-from gym.wrappers.vector_list_info import VectorListInfo
diff --git a/gym/__init__.py b/gymnasium/__init__.py
similarity index 70%
rename from gym/__init__.py
rename to gymnasium/__init__.py
index 185f064ff..14ee8ddf5 100644
--- a/gym/__init__.py
+++ b/gymnasium/__init__.py
@@ -1,21 +1,21 @@
-"""Root __init__ of the gym module setting the __all__ of gym modules."""
+"""Root __init__ of the gymnasium module setting the __all__ of gymnasium modules."""
# isort: skip_file
-from gym import error
-from gym.version import VERSION as __version__
+from gymnasium import error
+from gymnasium.version import VERSION as __version__
-from gym.core import (
+from gymnasium.core import (
Env,
Wrapper,
ObservationWrapper,
ActionWrapper,
RewardWrapper,
)
-from gym.spaces import Space
-from gym.envs import make, spec, register
-from gym import logger
-from gym import vector
-from gym import wrappers
+from gymnasium.spaces import Space
+from gymnasium.envs import make, spec, register
+from gymnasium import logger
+from gymnasium import vector
+from gymnasium import wrappers
import os
import sys
diff --git a/gym/core.py b/gymnasium/core.py
similarity index 97%
rename from gym/core.py
rename to gymnasium/core.py
index 96e5870ce..8ad9638c4 100644
--- a/gym/core.py
+++ b/gymnasium/core.py
@@ -15,12 +15,12 @@
import numpy as np
-from gym import spaces
-from gym.logger import warn
-from gym.utils import seeding
+from gymnasium import spaces
+from gymnasium.logger import warn
+from gymnasium.utils import seeding
if TYPE_CHECKING:
- from gym.envs.registration import EnvSpec
+ from gymnasium.envs.registration import EnvSpec
if sys.version_info[0:2] == (3, 6):
warn(
@@ -51,7 +51,7 @@ class Env(Generic[ObsType, ActType]):
- :attr:`action_space` - The Space object corresponding to valid actions
- :attr:`observation_space` - The Space object corresponding to valid observations
- :attr:`reward_range` - A tuple corresponding to the minimum and maximum possible rewards
- - :attr:`spec` - An environment spec that contains the information used to initialise the environment from `gym.make`
+ - :attr:`spec` - An environment spec that contains the information used to initialise the environment from `gymnasium.make`
- :attr:`metadata` - The metadata of the environment, i.e. render modes
- :attr:`np_random` - The random number generator for the environment
@@ -188,7 +188,7 @@ def unwrapped(self) -> "Env":
"""Returns the base non-wrapped environment.
Returns:
- Env: The base non-wrapped gym.Env instance
+ Env: The base non-wrapped gymnasium.Env instance
"""
return self
@@ -362,7 +362,7 @@ class ObservationWrapper(Wrapper):
``observation["target_position"] - observation["agent_position"]``. For this, you could implement an
observation wrapper like this::
- class RelativePosition(gym.ObservationWrapper):
+ class RelativePosition(gymnasium.ObservationWrapper):
def __init__(self, env):
super().__init__(env)
self.observation_space = Box(shape=(2,), low=-np.inf, high=np.inf)
@@ -402,7 +402,7 @@ class RewardWrapper(Wrapper):
because it is intrinsic), we want to clip the reward to a range to gain some numerical stability.
To do that, we could, for instance, implement the following wrapper::
- class ClipReward(gym.RewardWrapper):
+ class ClipReward(gymnasium.RewardWrapper):
def __init__(self, env, min_reward, max_reward):
super().__init__(env)
self.min_reward = min_reward
@@ -433,10 +433,10 @@ class ActionWrapper(Wrapper):
In that case, you need to specify the new action space of the wrapper by setting :attr:`self.action_space` in
the :meth:`__init__` method of your wrapper.
- Let’s say you have an environment with action space of type :class:`gym.spaces.Box`, but you would only like
+ Let’s say you have an environment with action space of type :class:`gymnasium.spaces.Box`, but you would only like
to use a finite subset of actions. Then, you might want to implement the following wrapper::
- class DiscreteActions(gym.ActionWrapper):
+ class DiscreteActions(gymnasium.ActionWrapper):
def __init__(self, env, disc_to_cont):
super().__init__(env)
self.disc_to_cont = disc_to_cont
@@ -446,7 +446,7 @@ def action(self, act):
return self.disc_to_cont[act]
if __name__ == "__main__":
- env = gym.make("LunarLanderContinuous-v2")
+ env = gymnasium.make("LunarLanderContinuous-v2")
wrapped_env = DiscreteActions(env, [np.array([1,0]), np.array([-1,0]),
np.array([0,1]), np.array([0,-1])])
print(wrapped_env.action_space) #Discrete(4)
diff --git a/gym/envs/__init__.py b/gymnasium/envs/__init__.py
similarity index 58%
rename from gym/envs/__init__.py
rename to gymnasium/envs/__init__.py
index cf7281027..a7b408718 100644
--- a/gym/envs/__init__.py
+++ b/gymnasium/envs/__init__.py
@@ -1,5 +1,5 @@
-from gym.envs.registration import load_env_plugins as _load_env_plugins
-from gym.envs.registration import make, register, registry, spec
+from gymnasium.envs.registration import load_env_plugins as _load_env_plugins
+from gymnasium.envs.registration import make, register, registry, spec
# Hook to load plugins from entry points
_load_env_plugins()
@@ -10,41 +10,41 @@
register(
id="CartPole-v0",
- entry_point="gym.envs.classic_control.cartpole:CartPoleEnv",
+ entry_point="gymnasium.envs.classic_control.cartpole:CartPoleEnv",
max_episode_steps=200,
reward_threshold=195.0,
)
register(
id="CartPole-v1",
- entry_point="gym.envs.classic_control.cartpole:CartPoleEnv",
+ entry_point="gymnasium.envs.classic_control.cartpole:CartPoleEnv",
max_episode_steps=500,
reward_threshold=475.0,
)
register(
id="MountainCar-v0",
- entry_point="gym.envs.classic_control.mountain_car:MountainCarEnv",
+ entry_point="gymnasium.envs.classic_control.mountain_car:MountainCarEnv",
max_episode_steps=200,
reward_threshold=-110.0,
)
register(
id="MountainCarContinuous-v0",
- entry_point="gym.envs.classic_control.continuous_mountain_car:Continuous_MountainCarEnv",
+ entry_point="gymnasium.envs.classic_control.continuous_mountain_car:Continuous_MountainCarEnv",
max_episode_steps=999,
reward_threshold=90.0,
)
register(
id="Pendulum-v1",
- entry_point="gym.envs.classic_control.pendulum:PendulumEnv",
+ entry_point="gymnasium.envs.classic_control.pendulum:PendulumEnv",
max_episode_steps=200,
)
register(
id="Acrobot-v1",
- entry_point="gym.envs.classic_control.acrobot:AcrobotEnv",
+ entry_point="gymnasium.envs.classic_control.acrobot:AcrobotEnv",
reward_threshold=-100.0,
max_episode_steps=500,
)
@@ -54,14 +54,14 @@
register(
id="LunarLander-v2",
- entry_point="gym.envs.box2d.lunar_lander:LunarLander",
+ entry_point="gymnasium.envs.box2d.lunar_lander:LunarLander",
max_episode_steps=1000,
reward_threshold=200,
)
register(
id="LunarLanderContinuous-v2",
- entry_point="gym.envs.box2d.lunar_lander:LunarLander",
+ entry_point="gymnasium.envs.box2d.lunar_lander:LunarLander",
kwargs={"continuous": True},
max_episode_steps=1000,
reward_threshold=200,
@@ -69,14 +69,14 @@
register(
id="BipedalWalker-v3",
- entry_point="gym.envs.box2d.bipedal_walker:BipedalWalker",
+ entry_point="gymnasium.envs.box2d.bipedal_walker:BipedalWalker",
max_episode_steps=1600,
reward_threshold=300,
)
register(
id="BipedalWalkerHardcore-v3",
- entry_point="gym.envs.box2d.bipedal_walker:BipedalWalker",
+ entry_point="gymnasium.envs.box2d.bipedal_walker:BipedalWalker",
kwargs={"hardcore": True},
max_episode_steps=2000,
reward_threshold=300,
@@ -84,7 +84,7 @@
register(
id="CarRacing-v2",
- entry_point="gym.envs.box2d.car_racing:CarRacing",
+ entry_point="gymnasium.envs.box2d.car_racing:CarRacing",
max_episode_steps=1000,
reward_threshold=900,
)
@@ -94,13 +94,13 @@
register(
id="Blackjack-v1",
- entry_point="gym.envs.toy_text.blackjack:BlackjackEnv",
+ entry_point="gymnasium.envs.toy_text.blackjack:BlackjackEnv",
kwargs={"sab": True, "natural": False},
)
register(
id="FrozenLake-v1",
- entry_point="gym.envs.toy_text.frozen_lake:FrozenLakeEnv",
+ entry_point="gymnasium.envs.toy_text.frozen_lake:FrozenLakeEnv",
kwargs={"map_name": "4x4"},
max_episode_steps=100,
reward_threshold=0.70, # optimum = 0.74
@@ -108,7 +108,7 @@
register(
id="FrozenLake8x8-v1",
- entry_point="gym.envs.toy_text.frozen_lake:FrozenLakeEnv",
+ entry_point="gymnasium.envs.toy_text.frozen_lake:FrozenLakeEnv",
kwargs={"map_name": "8x8"},
max_episode_steps=200,
reward_threshold=0.85, # optimum = 0.91
@@ -116,12 +116,12 @@
register(
id="CliffWalking-v0",
- entry_point="gym.envs.toy_text.cliffwalking:CliffWalkingEnv",
+ entry_point="gymnasium.envs.toy_text.cliffwalking:CliffWalkingEnv",
)
register(
id="Taxi-v3",
- entry_point="gym.envs.toy_text.taxi:TaxiEnv",
+ entry_point="gymnasium.envs.toy_text.taxi:TaxiEnv",
reward_threshold=8, # optimum = 8.46
max_episode_steps=200,
)
@@ -133,119 +133,119 @@
register(
id="Reacher-v2",
- entry_point="gym.envs.mujoco:ReacherEnv",
+ entry_point="gymnasium.envs.mujoco:ReacherEnv",
max_episode_steps=50,
reward_threshold=-3.75,
)
register(
id="Reacher-v4",
- entry_point="gym.envs.mujoco.reacher_v4:ReacherEnv",
+ entry_point="gymnasium.envs.mujoco.reacher_v4:ReacherEnv",
max_episode_steps=50,
reward_threshold=-3.75,
)
register(
id="Pusher-v2",
- entry_point="gym.envs.mujoco:PusherEnv",
+ entry_point="gymnasium.envs.mujoco:PusherEnv",
max_episode_steps=100,
reward_threshold=0.0,
)
register(
id="Pusher-v4",
- entry_point="gym.envs.mujoco.pusher_v4:PusherEnv",
+ entry_point="gymnasium.envs.mujoco.pusher_v4:PusherEnv",
max_episode_steps=100,
reward_threshold=0.0,
)
register(
id="InvertedPendulum-v2",
- entry_point="gym.envs.mujoco:InvertedPendulumEnv",
+ entry_point="gymnasium.envs.mujoco:InvertedPendulumEnv",
max_episode_steps=1000,
reward_threshold=950.0,
)
register(
id="InvertedPendulum-v4",
- entry_point="gym.envs.mujoco.inverted_pendulum_v4:InvertedPendulumEnv",
+ entry_point="gymnasium.envs.mujoco.inverted_pendulum_v4:InvertedPendulumEnv",
max_episode_steps=1000,
reward_threshold=950.0,
)
register(
id="InvertedDoublePendulum-v2",
- entry_point="gym.envs.mujoco:InvertedDoublePendulumEnv",
+ entry_point="gymnasium.envs.mujoco:InvertedDoublePendulumEnv",
max_episode_steps=1000,
reward_threshold=9100.0,
)
register(
id="InvertedDoublePendulum-v4",
- entry_point="gym.envs.mujoco.inverted_double_pendulum_v4:InvertedDoublePendulumEnv",
+ entry_point="gymnasium.envs.mujoco.inverted_double_pendulum_v4:InvertedDoublePendulumEnv",
max_episode_steps=1000,
reward_threshold=9100.0,
)
register(
id="HalfCheetah-v2",
- entry_point="gym.envs.mujoco:HalfCheetahEnv",
+ entry_point="gymnasium.envs.mujoco:HalfCheetahEnv",
max_episode_steps=1000,
reward_threshold=4800.0,
)
register(
id="HalfCheetah-v3",
- entry_point="gym.envs.mujoco.half_cheetah_v3:HalfCheetahEnv",
+ entry_point="gymnasium.envs.mujoco.half_cheetah_v3:HalfCheetahEnv",
max_episode_steps=1000,
reward_threshold=4800.0,
)
register(
id="HalfCheetah-v4",
- entry_point="gym.envs.mujoco.half_cheetah_v4:HalfCheetahEnv",
+ entry_point="gymnasium.envs.mujoco.half_cheetah_v4:HalfCheetahEnv",
max_episode_steps=1000,
reward_threshold=4800.0,
)
register(
id="Hopper-v2",
- entry_point="gym.envs.mujoco:HopperEnv",
+ entry_point="gymnasium.envs.mujoco:HopperEnv",
max_episode_steps=1000,
reward_threshold=3800.0,
)
register(
id="Hopper-v3",
- entry_point="gym.envs.mujoco.hopper_v3:HopperEnv",
+ entry_point="gymnasium.envs.mujoco.hopper_v3:HopperEnv",
max_episode_steps=1000,
reward_threshold=3800.0,
)
register(
id="Hopper-v4",
- entry_point="gym.envs.mujoco.hopper_v4:HopperEnv",
+ entry_point="gymnasium.envs.mujoco.hopper_v4:HopperEnv",
max_episode_steps=1000,
reward_threshold=3800.0,
)
register(
id="Swimmer-v2",
- entry_point="gym.envs.mujoco:SwimmerEnv",
+ entry_point="gymnasium.envs.mujoco:SwimmerEnv",
max_episode_steps=1000,
reward_threshold=360.0,
)
register(
id="Swimmer-v3",
- entry_point="gym.envs.mujoco.swimmer_v3:SwimmerEnv",
+ entry_point="gymnasium.envs.mujoco.swimmer_v3:SwimmerEnv",
max_episode_steps=1000,
reward_threshold=360.0,
)
register(
id="Swimmer-v4",
- entry_point="gym.envs.mujoco.swimmer_v4:SwimmerEnv",
+ entry_point="gymnasium.envs.mujoco.swimmer_v4:SwimmerEnv",
max_episode_steps=1000,
reward_threshold=360.0,
)
@@ -253,68 +253,68 @@
register(
id="Walker2d-v2",
max_episode_steps=1000,
- entry_point="gym.envs.mujoco:Walker2dEnv",
+ entry_point="gymnasium.envs.mujoco:Walker2dEnv",
)
register(
id="Walker2d-v3",
max_episode_steps=1000,
- entry_point="gym.envs.mujoco.walker2d_v3:Walker2dEnv",
+ entry_point="gymnasium.envs.mujoco.walker2d_v3:Walker2dEnv",
)
register(
id="Walker2d-v4",
max_episode_steps=1000,
- entry_point="gym.envs.mujoco.walker2d_v4:Walker2dEnv",
+ entry_point="gymnasium.envs.mujoco.walker2d_v4:Walker2dEnv",
)
register(
id="Ant-v2",
- entry_point="gym.envs.mujoco:AntEnv",
+ entry_point="gymnasium.envs.mujoco:AntEnv",
max_episode_steps=1000,
reward_threshold=6000.0,
)
register(
id="Ant-v3",
- entry_point="gym.envs.mujoco.ant_v3:AntEnv",
+ entry_point="gymnasium.envs.mujoco.ant_v3:AntEnv",
max_episode_steps=1000,
reward_threshold=6000.0,
)
register(
id="Ant-v4",
- entry_point="gym.envs.mujoco.ant_v4:AntEnv",
+ entry_point="gymnasium.envs.mujoco.ant_v4:AntEnv",
max_episode_steps=1000,
reward_threshold=6000.0,
)
register(
id="Humanoid-v2",
- entry_point="gym.envs.mujoco:HumanoidEnv",
+ entry_point="gymnasium.envs.mujoco:HumanoidEnv",
max_episode_steps=1000,
)
register(
id="Humanoid-v3",
- entry_point="gym.envs.mujoco.humanoid_v3:HumanoidEnv",
+ entry_point="gymnasium.envs.mujoco.humanoid_v3:HumanoidEnv",
max_episode_steps=1000,
)
register(
id="Humanoid-v4",
- entry_point="gym.envs.mujoco.humanoid_v4:HumanoidEnv",
+ entry_point="gymnasium.envs.mujoco.humanoid_v4:HumanoidEnv",
max_episode_steps=1000,
)
register(
id="HumanoidStandup-v2",
- entry_point="gym.envs.mujoco:HumanoidStandupEnv",
+ entry_point="gymnasium.envs.mujoco:HumanoidStandupEnv",
max_episode_steps=1000,
)
register(
id="HumanoidStandup-v4",
- entry_point="gym.envs.mujoco.humanoidstandup_v4:HumanoidStandupEnv",
+ entry_point="gymnasium.envs.mujoco.humanoidstandup_v4:HumanoidStandupEnv",
max_episode_steps=1000,
)
diff --git a/gymnasium/envs/box2d/__init__.py b/gymnasium/envs/box2d/__init__.py
new file mode 100644
index 000000000..04aac955e
--- /dev/null
+++ b/gymnasium/envs/box2d/__init__.py
@@ -0,0 +1,3 @@
+from gymnasium.envs.box2d.bipedal_walker import BipedalWalker, BipedalWalkerHardcore
+from gymnasium.envs.box2d.car_racing import CarRacing
+from gymnasium.envs.box2d.lunar_lander import LunarLander, LunarLanderContinuous
diff --git a/gym/envs/box2d/bipedal_walker.py b/gymnasium/envs/box2d/bipedal_walker.py
similarity index 98%
rename from gym/envs/box2d/bipedal_walker.py
rename to gymnasium/envs/box2d/bipedal_walker.py
index 9e5bf0c82..4af127111 100644
--- a/gym/envs/box2d/bipedal_walker.py
+++ b/gymnasium/envs/box2d/bipedal_walker.py
@@ -5,10 +5,10 @@
import numpy as np
-import gym
-from gym import error, spaces
-from gym.error import DependencyNotInstalled
-from gym.utils import EzPickle
+import gymnasium
+from gymnasium import error, spaces
+from gymnasium.error import DependencyNotInstalled
+from gymnasium.utils import EzPickle
try:
import Box2D
@@ -21,7 +21,7 @@
revoluteJointDef,
)
except ImportError:
- raise DependencyNotInstalled("box2D is not installed, run `pip install gym[box2d]`")
+ raise DependencyNotInstalled("box2D is not installed, run `pip install gymnasium[box2d]`")
if TYPE_CHECKING:
@@ -98,7 +98,7 @@ def EndContact(self, contact):
leg.ground_contact = False
-class BipedalWalker(gym.Env, EzPickle):
+class BipedalWalker(gymnasium.Env, EzPickle):
"""
### Description
This is a simple 4-joint walker robot environment.
@@ -112,7 +112,7 @@ class BipedalWalker(gym.Env, EzPickle):
A heuristic is provided for testing. It's also useful to get demonstrations
to learn from. To run the heuristic:
```
- python gym/envs/box2d/bipedal_walker.py
+ python gymnasium/envs/box2d/bipedal_walker.py
```
### Action Space
@@ -142,8 +142,8 @@ class BipedalWalker(gym.Env, EzPickle):
To use to the _hardcore_ environment, you need to specify the
`hardcore=True` argument like below:
```python
- import gym
- env = gym.make("BipedalWalker-v3", hardcore=True)
+ import gymnasium
+ env = gymnasium.make("BipedalWalker-v3", hardcore=True)
```
### Version History
@@ -611,7 +611,7 @@ def render(self):
from pygame import gfxdraw
except ImportError:
raise DependencyNotInstalled(
- "pygame is not installed, run `pip install gym[box2d]`"
+ "pygame is not installed, run `pip install gymnasium[box2d]`"
)
if self.screen is None and self.render_mode == "human":
@@ -758,8 +758,8 @@ def __init__(self):
raise error.Error(
"Error initializing BipedalWalkerHardcore Environment.\n"
"Currently, we do not support initializing this mode of environment by calling the class directly.\n"
- "To use this environment, instead create it by specifying the hardcore keyword in gym.make, i.e.\n"
- 'gym.make("BipedalWalker-v3", hardcore=True)'
+ "To use this environment, instead create it by specifying the hardcore keyword in gymnasium.make, i.e.\n"
+ 'gymnasium.make("BipedalWalker-v3", hardcore=True)'
)
diff --git a/gym/envs/box2d/car_dynamics.py b/gymnasium/envs/box2d/car_dynamics.py
similarity index 99%
rename from gym/envs/box2d/car_dynamics.py
rename to gymnasium/envs/box2d/car_dynamics.py
index 435a4dec2..036743f00 100644
--- a/gym/envs/box2d/car_dynamics.py
+++ b/gymnasium/envs/box2d/car_dynamics.py
@@ -12,12 +12,12 @@
import Box2D
import numpy as np
-from gym.error import DependencyNotInstalled
+from gymnasium.error import DependencyNotInstalled
try:
from Box2D.b2 import fixtureDef, polygonShape, revoluteJointDef
except ImportError:
- raise DependencyNotInstalled("box2D is not installed, run `pip install gym[box2d]`")
+ raise DependencyNotInstalled("box2D is not installed, run `pip install gymnasium[box2d]`")
SIZE = 0.02
diff --git a/gym/envs/box2d/car_racing.py b/gymnasium/envs/box2d/car_racing.py
similarity index 98%
rename from gym/envs/box2d/car_racing.py
rename to gymnasium/envs/box2d/car_racing.py
index 9ba35a2ff..c422a894f 100644
--- a/gym/envs/box2d/car_racing.py
+++ b/gymnasium/envs/box2d/car_racing.py
@@ -5,17 +5,17 @@
import numpy as np
-import gym
-from gym import spaces
-from gym.envs.box2d.car_dynamics import Car
-from gym.error import DependencyNotInstalled, InvalidAction
-from gym.utils import EzPickle
+import gymnasium
+from gymnasium import spaces
+from gymnasium.envs.box2d.car_dynamics import Car
+from gymnasium.error import DependencyNotInstalled, InvalidAction
+from gymnasium.utils import EzPickle
try:
import Box2D
from Box2D.b2 import contactListener, fixtureDef, polygonShape
except ImportError:
- raise DependencyNotInstalled("box2D is not installed, run `pip install gym[box2d]`")
+ raise DependencyNotInstalled("box2D is not installed, run `pip install gymnasium[box2d]`")
try:
# As pygame is necessary for using the environment (reset and step) even without a render mode
@@ -24,7 +24,7 @@
from pygame import gfxdraw
except ImportError:
raise DependencyNotInstalled(
- "pygame is not installed, run `pip install gym[box2d]`"
+ "pygame is not installed, run `pip install gymnasium[box2d]`"
)
@@ -102,7 +102,7 @@ def _contact(self, contact, begin):
obj.tiles.remove(tile)
-class CarRacing(gym.Env, EzPickle):
+class CarRacing(gymnasium.Env, EzPickle):
"""
### Description
The easiest control task to learn from pixels - a top-down
@@ -113,7 +113,7 @@ class CarRacing(gym.Env, EzPickle):
steering wheel position, and gyroscope.
To play yourself (it's rather fast for humans), type:
```
- python gym/envs/box2d/car_racing.py
+ python gymnasium/envs/box2d/car_racing.py
```
Remember: it's a powerful rear-wheel drive car - don't press the accelerator
and turn at the same time.
@@ -157,7 +157,7 @@ class CarRacing(gym.Env, EzPickle):
`domain_randomize` must be `True` on init for this argument to work.
Example usage:
```py
- env = gym.make("CarRacing-v1", domain_randomize=True)
+ env = gymnasium.make("CarRacing-v1", domain_randomize=True)
# normal reset, this changes the colour scheme by default
env.reset()
diff --git a/gym/envs/box2d/lunar_lander.py b/gymnasium/envs/box2d/lunar_lander.py
similarity index 97%
rename from gym/envs/box2d/lunar_lander.py
rename to gymnasium/envs/box2d/lunar_lander.py
index 87185c43a..d619186af 100644
--- a/gym/envs/box2d/lunar_lander.py
+++ b/gymnasium/envs/box2d/lunar_lander.py
@@ -6,11 +6,11 @@
import numpy as np
-import gym
-from gym import error, spaces
-from gym.error import DependencyNotInstalled
-from gym.utils import EzPickle, colorize
-from gym.utils.step_api_compatibility import step_api_compatibility
+import gymnasium
+from gymnasium import error, spaces
+from gymnasium.error import DependencyNotInstalled
+from gymnasium.utils import EzPickle, colorize
+from gymnasium.utils.step_api_compatibility import step_api_compatibility
try:
import Box2D
@@ -23,7 +23,7 @@
revoluteJointDef,
)
except ImportError:
- raise DependencyNotInstalled("box2d is not installed, run `pip install gym[box2d]`")
+ raise DependencyNotInstalled("box2d is not installed, run `pip install gymnasium[box2d]`")
if TYPE_CHECKING:
@@ -72,7 +72,7 @@ def EndContact(self, contact):
self.env.legs[i].ground_contact = False
-class LunarLander(gym.Env, EzPickle):
+class LunarLander(gymnasium.Env, EzPickle):
"""
### Description
This environment is a classic rocket trajectory optimization problem.
@@ -88,7 +88,7 @@ class LunarLander(gym.Env, EzPickle):
To see a heuristic landing, run:
```
- python gym/envs/box2d/lunar_lander.py
+ python gymnasium/envs/box2d/lunar_lander.py
```
@@ -139,8 +139,8 @@ class LunarLander(gym.Env, EzPickle):
To use to the _continuous_ environment, you need to specify the
`continuous=True` argument like below:
```python
- import gym
- env = gym.make(
+ import gymnasium
+ env = gymnasium.make(
"LunarLander-v2",
continuous: bool = False,
gravity: float = -10.0,
@@ -605,7 +605,7 @@ def render(self):
from pygame import gfxdraw
except ImportError:
raise DependencyNotInstalled(
- "pygame is not installed, run `pip install gym[box2d]`"
+ "pygame is not installed, run `pip install gymnasium[box2d]`"
)
if self.screen is None and self.render_mode == "human":
@@ -800,8 +800,8 @@ def __init__(self):
raise error.Error(
"Error initializing LunarLanderContinuous Environment.\n"
"Currently, we do not support initializing this mode of environment by calling the class directly.\n"
- "To use this environment, instead create it by specifying the continuous keyword in gym.make, i.e.\n"
- 'gym.make("LunarLander-v2", continuous=True)'
+ "To use this environment, instead create it by specifying the continuous keyword in gymnasium.make, i.e.\n"
+ 'gymnasium.make("LunarLander-v2", continuous=True)'
)
diff --git a/gymnasium/envs/classic_control/__init__.py b/gymnasium/envs/classic_control/__init__.py
new file mode 100644
index 000000000..381a132f0
--- /dev/null
+++ b/gymnasium/envs/classic_control/__init__.py
@@ -0,0 +1,5 @@
+from gymnasium.envs.classic_control.acrobot import AcrobotEnv
+from gymnasium.envs.classic_control.cartpole import CartPoleEnv
+from gymnasium.envs.classic_control.continuous_mountain_car import Continuous_MountainCarEnv
+from gymnasium.envs.classic_control.mountain_car import MountainCarEnv
+from gymnasium.envs.classic_control.pendulum import PendulumEnv
diff --git a/gym/envs/classic_control/acrobot.py b/gymnasium/envs/classic_control/acrobot.py
similarity index 97%
rename from gym/envs/classic_control/acrobot.py
rename to gymnasium/envs/classic_control/acrobot.py
index d618078a0..9972a6303 100644
--- a/gym/envs/classic_control/acrobot.py
+++ b/gymnasium/envs/classic_control/acrobot.py
@@ -4,8 +4,8 @@
import numpy as np
from numpy import cos, pi, sin
-from gym import core, spaces
-from gym.error import DependencyNotInstalled
+from gymnasium import core, spaces
+from gymnasium.error import DependencyNotInstalled
__copyright__ = "Copyright 2013, RLPy http://acl.mit.edu/RLPy"
__credits__ = [
@@ -20,7 +20,7 @@
# SOURCE:
# https://github.com/rlpy/rlpy/blob/master/rlpy/Domains/Acrobot.py
-from gym.envs.classic_control import utils
+from gymnasium.envs.classic_control import utils
class AcrobotEnv(core.Env):
@@ -97,7 +97,7 @@ class AcrobotEnv(core.Env):
No additional arguments are currently supported.
```
- env = gym.make('Acrobot-v1')
+ env = gymnasium.make('Acrobot-v1')
```
By default, the dynamics of the acrobot follow those described in Sutton and Barto's book
@@ -126,7 +126,7 @@ class AcrobotEnv(core.Env):
- v1: Maximum number of steps increased from 200 to 500. The observation space for v0 provided direct readings of
`theta1` and `theta2` in radians, having a range of `[-pi, pi]`. The v1 observation space as described here provides the
sine and cosine of each angle instead.
- - v0: Initial versions release (1.0.0) (removed from gym for v1)
+ - v0: Initial versions release (1.0.0) (removed from gymnasium for v1)
### References
- Sutton, R. S. (1996). Generalization in Reinforcement Learning: Successful Examples Using Sparse Coarse Coding.
@@ -282,7 +282,7 @@ def render(self):
from pygame import gfxdraw
except ImportError:
raise DependencyNotInstalled(
- "pygame is not installed, run `pip install gym[classic_control]`"
+ "pygame is not installed, run `pip install gymnasium[classic_control]`"
)
if self.screen is None:
diff --git a/gym/envs/classic_control/assets/clockwise.png b/gymnasium/envs/classic_control/assets/clockwise.png
similarity index 100%
rename from gym/envs/classic_control/assets/clockwise.png
rename to gymnasium/envs/classic_control/assets/clockwise.png
diff --git a/gym/envs/classic_control/cartpole.py b/gymnasium/envs/classic_control/cartpole.py
similarity index 96%
rename from gym/envs/classic_control/cartpole.py
rename to gymnasium/envs/classic_control/cartpole.py
index a1d404599..6547496f4 100644
--- a/gym/envs/classic_control/cartpole.py
+++ b/gymnasium/envs/classic_control/cartpole.py
@@ -8,13 +8,13 @@
import numpy as np
-import gym
-from gym import logger, spaces
-from gym.envs.classic_control import utils
-from gym.error import DependencyNotInstalled
+import gymnasium
+from gymnasium import logger, spaces
+from gymnasium.envs.classic_control import utils
+from gymnasium.error import DependencyNotInstalled
-class CartPoleEnv(gym.Env[np.ndarray, Union[int, np.ndarray]]):
+class CartPoleEnv(gymnasium.Env[np.ndarray, Union[int, np.ndarray]]):
"""
### Description
@@ -75,7 +75,7 @@ class CartPoleEnv(gym.Env[np.ndarray, Union[int, np.ndarray]]):
### Arguments
```
- gym.make('CartPole-v1')
+ gymnasium.make('CartPole-v1')
```
No additional arguments are currently supported.
@@ -212,7 +212,7 @@ def render(self):
from pygame import gfxdraw
except ImportError:
raise DependencyNotInstalled(
- "pygame is not installed, run `pip install gym[classic_control]`"
+ "pygame is not installed, run `pip install gymnasium[classic_control]`"
)
if self.screen is None:
diff --git a/gym/envs/classic_control/continuous_mountain_car.py b/gymnasium/envs/classic_control/continuous_mountain_car.py
similarity index 94%
rename from gym/envs/classic_control/continuous_mountain_car.py
rename to gymnasium/envs/classic_control/continuous_mountain_car.py
index 3d427b670..32fbf8bef 100644
--- a/gym/envs/classic_control/continuous_mountain_car.py
+++ b/gymnasium/envs/classic_control/continuous_mountain_car.py
@@ -7,7 +7,7 @@
of Jose Antonio Martin H. (version 1.0), adapted by 'Tom Schaul, tom@idsia.ch'
and then modified by Arnaud de Broissia
-* the gym MountainCar environment
+* the gymnasium MountainCar environment
itself from
http://incompleteideas.net/sutton/MountainCar/MountainCar1.cp
permalink: https://perma.cc/6Z2N-PFWC
@@ -18,13 +18,13 @@
import numpy as np
-import gym
-from gym import spaces
-from gym.envs.classic_control import utils
-from gym.error import DependencyNotInstalled
+import gymnasium
+from gymnasium import spaces
+from gymnasium.envs.classic_control import utils
+from gymnasium.error import DependencyNotInstalled
-class Continuous_MountainCarEnv(gym.Env):
+class Continuous_MountainCarEnv(gymnasium.Env):
"""
### Description
@@ -32,7 +32,7 @@ class Continuous_MountainCarEnv(gym.Env):
at the bottom of a sinusoidal valley, with the only possible actions being the accelerations
that can be applied to the car in either direction. The goal of the MDP is to strategically
accelerate the car to reach the goal state on top of the right hill. There are two versions
- of the mountain car domain in gym: one with discrete actions and one with continuous.
+ of the mountain car domain in gymnasium: one with discrete actions and one with continuous.
This version is the one with continuous actions.
This MDP first appeared in [Andrew Moore's PhD Thesis (1990)](https://www.cl.cam.ac.uk/techreports/UCAM-CL-TR-209.pdf)
@@ -92,7 +92,7 @@ class Continuous_MountainCarEnv(gym.Env):
### Arguments
```
- gym.make('MountainCarContinuous-v0')
+ gymnasium.make('MountainCarContinuous-v0')
```
### Version History
@@ -112,7 +112,7 @@ def __init__(self, render_mode: Optional[str] = None, goal_velocity=0):
self.max_position = 0.6
self.max_speed = 0.07
self.goal_position = (
- 0.45 # was 0.5 in gym, 0.45 in Arnaud de Broissia's version
+ 0.45 # was 0.5 in gymnasium, 0.45 in Arnaud de Broissia's version
)
self.goal_velocity = goal_velocity
self.power = 0.0015
@@ -194,7 +194,7 @@ def render(self):
from pygame import gfxdraw
except ImportError:
raise DependencyNotInstalled(
- "pygame is not installed, run `pip install gym[classic_control]`"
+ "pygame is not installed, run `pip install gymnasium[classic_control]`"
)
if self.screen is None:
diff --git a/gym/envs/classic_control/mountain_car.py b/gymnasium/envs/classic_control/mountain_car.py
similarity index 95%
rename from gym/envs/classic_control/mountain_car.py
rename to gymnasium/envs/classic_control/mountain_car.py
index f25aeab91..c85997d7b 100644
--- a/gym/envs/classic_control/mountain_car.py
+++ b/gymnasium/envs/classic_control/mountain_car.py
@@ -7,13 +7,13 @@
import numpy as np
-import gym
-from gym import spaces
-from gym.envs.classic_control import utils
-from gym.error import DependencyNotInstalled
+import gymnasium
+from gymnasium import spaces
+from gymnasium.envs.classic_control import utils
+from gymnasium.error import DependencyNotInstalled
-class MountainCarEnv(gym.Env):
+class MountainCarEnv(gymnasium.Env):
"""
### Description
@@ -21,7 +21,7 @@ class MountainCarEnv(gym.Env):
at the bottom of a sinusoidal valley, with the only possible actions being the accelerations
that can be applied to the car in either direction. The goal of the MDP is to strategically
accelerate the car to reach the goal state on top of the right hill. There are two versions
- of the mountain car domain in gym: one with discrete actions and one with continuous.
+ of the mountain car domain in gymnasium: one with discrete actions and one with continuous.
This version is the one with discrete actions.
This MDP first appeared in [Andrew Moore's PhD Thesis (1990)](https://www.cl.cam.ac.uk/techreports/UCAM-CL-TR-209.pdf)
@@ -87,7 +87,7 @@ class MountainCarEnv(gym.Env):
### Arguments
```
- gym.make('MountainCar-v0')
+ gymnasium.make('MountainCar-v0')
```
### Version History
@@ -172,7 +172,7 @@ def render(self):
from pygame import gfxdraw
except ImportError:
raise DependencyNotInstalled(
- "pygame is not installed, run `pip install gym[classic_control]`"
+ "pygame is not installed, run `pip install gymnasium[classic_control]`"
)
if self.screen is None:
diff --git a/gym/envs/classic_control/pendulum.py b/gymnasium/envs/classic_control/pendulum.py
similarity index 96%
rename from gym/envs/classic_control/pendulum.py
rename to gymnasium/envs/classic_control/pendulum.py
index 2a1f11a65..f1fccbaa9 100644
--- a/gym/envs/classic_control/pendulum.py
+++ b/gymnasium/envs/classic_control/pendulum.py
@@ -5,16 +5,16 @@
import numpy as np
-import gym
-from gym import spaces
-from gym.envs.classic_control import utils
-from gym.error import DependencyNotInstalled
+import gymnasium
+from gymnasium import spaces
+from gymnasium.envs.classic_control import utils
+from gymnasium.error import DependencyNotInstalled
DEFAULT_X = np.pi
DEFAULT_Y = 1.0
-class PendulumEnv(gym.Env):
+class PendulumEnv(gymnasium.Env):
"""
### Description
@@ -77,7 +77,7 @@ class PendulumEnv(gym.Env):
The default value is g = 10.0 .
```
- gym.make('Pendulum-v1', g=9.81)
+ gymnasium.make('Pendulum-v1', g=9.81)
```
### Version History
@@ -110,7 +110,7 @@ def __init__(self, render_mode: Optional[str] = None, g=10.0):
high = np.array([1.0, 1.0, self.max_speed], dtype=np.float32)
# This will throw a warning in tests/envs/test_envs in utils/env_checker.py as the space is not symmetric
# or normalised as max_torque == 2 by default. Ignoring the issue here as the default settings are too old
- # to update to follow the openai gym api
+ # to update to follow the openai gymnasium api
self.action_space = spaces.Box(
low=-self.max_torque, high=self.max_torque, shape=(1,), dtype=np.float32
)
@@ -168,7 +168,7 @@ def render(self):
from pygame import gfxdraw
except ImportError:
raise DependencyNotInstalled(
- "pygame is not installed, run `pip install gym[classic_control]`"
+ "pygame is not installed, run `pip install gymnasium[classic_control]`"
)
if self.screen is None:
diff --git a/gym/envs/classic_control/utils.py b/gymnasium/envs/classic_control/utils.py
similarity index 100%
rename from gym/envs/classic_control/utils.py
rename to gymnasium/envs/classic_control/utils.py
diff --git a/gymnasium/envs/mujoco/__init__.py b/gymnasium/envs/mujoco/__init__.py
new file mode 100644
index 000000000..350f75439
--- /dev/null
+++ b/gymnasium/envs/mujoco/__init__.py
@@ -0,0 +1,19 @@
+from gymnasium.envs.mujoco.mujoco_env import MujocoEnv, MuJocoPyEnv # isort:skip
+from gymnasium.envs.mujoco.mujoco_rendering import ( # isort:skip
+ RenderContextOffscreen,
+ Viewer,
+)
+
+# ^^^^^ so that user gets the correct error
+# message if mujoco is not installed correctly
+from gymnasium.envs.mujoco.ant import AntEnv
+from gymnasium.envs.mujoco.half_cheetah import HalfCheetahEnv
+from gymnasium.envs.mujoco.hopper import HopperEnv
+from gymnasium.envs.mujoco.humanoid import HumanoidEnv
+from gymnasium.envs.mujoco.humanoidstandup import HumanoidStandupEnv
+from gymnasium.envs.mujoco.inverted_double_pendulum import InvertedDoublePendulumEnv
+from gymnasium.envs.mujoco.inverted_pendulum import InvertedPendulumEnv
+from gymnasium.envs.mujoco.pusher import PusherEnv
+from gymnasium.envs.mujoco.reacher import ReacherEnv
+from gymnasium.envs.mujoco.swimmer import SwimmerEnv
+from gymnasium.envs.mujoco.walker2d import Walker2dEnv
diff --git a/gym/envs/mujoco/ant.py b/gymnasium/envs/mujoco/ant.py
similarity index 95%
rename from gym/envs/mujoco/ant.py
rename to gymnasium/envs/mujoco/ant.py
index 09e006be6..348512f1b 100644
--- a/gym/envs/mujoco/ant.py
+++ b/gymnasium/envs/mujoco/ant.py
@@ -1,8 +1,8 @@
import numpy as np
-from gym import utils
-from gym.envs.mujoco import MuJocoPyEnv
-from gym.spaces import Box
+from gymnasium import utils
+from gymnasium.envs.mujoco import MuJocoPyEnv
+from gymnasium.spaces import Box
class AntEnv(MuJocoPyEnv, utils.EzPickle):
diff --git a/gym/envs/mujoco/ant_v3.py b/gymnasium/envs/mujoco/ant_v3.py
similarity index 98%
rename from gym/envs/mujoco/ant_v3.py
rename to gymnasium/envs/mujoco/ant_v3.py
index 751efabdf..9b884c3d2 100644
--- a/gym/envs/mujoco/ant_v3.py
+++ b/gymnasium/envs/mujoco/ant_v3.py
@@ -1,8 +1,8 @@
import numpy as np
-from gym import utils
-from gym.envs.mujoco import MuJocoPyEnv
-from gym.spaces import Box
+from gymnasium import utils
+from gymnasium.envs.mujoco import MuJocoPyEnv
+from gymnasium.spaces import Box
DEFAULT_CAMERA_CONFIG = {
"distance": 4.0,
diff --git a/gym/envs/mujoco/ant_v4.py b/gymnasium/envs/mujoco/ant_v4.py
similarity index 97%
rename from gym/envs/mujoco/ant_v4.py
rename to gymnasium/envs/mujoco/ant_v4.py
index 93782641e..b40302c6b 100644
--- a/gym/envs/mujoco/ant_v4.py
+++ b/gymnasium/envs/mujoco/ant_v4.py
@@ -1,8 +1,8 @@
import numpy as np
-from gym import utils
-from gym.envs.mujoco import MujocoEnv
-from gym.spaces import Box
+from gymnasium import utils
+from gymnasium.envs.mujoco import MujocoEnv
+from gymnasium.spaces import Box
DEFAULT_CAMERA_CONFIG = {
"distance": 4.0,
@@ -143,13 +143,13 @@ class AntEnv(MujocoEnv, utils.EzPickle):
No additional arguments are currently supported in v2 and lower.
```
- env = gym.make('Ant-v2')
+ env = gymnasium.make('Ant-v2')
```
- v3 and v4 take gym.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc.
+ v3 and v4 take gymnasium.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc.
```
- env = gym.make('Ant-v4', ctrl_cost_weight=0.1, ...)
+ env = gymnasium.make('Ant-v4', ctrl_cost_weight=0.1, ...)
```
| Parameter | Type | Default |Description |
@@ -166,7 +166,7 @@ class AntEnv(MujocoEnv, utils.EzPickle):
### Version History
* v4: all mujoco environments now use the mujoco bindings in mujoco>=2.1.3
- * v3: support for gym.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc. rgb rendering comes from tracking camera (so agent does not run away from screen)
+ * v3: support for gymnasium.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc. rgb rendering comes from tracking camera (so agent does not run away from screen)
* v2: All continuous control environments now use mujoco_py >= 1.50
* v1: max_time_steps raised to 1000 for robot based tasks. Added reward_threshold to environments.
* v0: Initial versions release (1.0.0)
diff --git a/gym/envs/mujoco/assets/ant.xml b/gymnasium/envs/mujoco/assets/ant.xml
similarity index 100%
rename from gym/envs/mujoco/assets/ant.xml
rename to gymnasium/envs/mujoco/assets/ant.xml
diff --git a/gym/envs/mujoco/assets/half_cheetah.xml b/gymnasium/envs/mujoco/assets/half_cheetah.xml
similarity index 100%
rename from gym/envs/mujoco/assets/half_cheetah.xml
rename to gymnasium/envs/mujoco/assets/half_cheetah.xml
diff --git a/gym/envs/mujoco/assets/hopper.xml b/gymnasium/envs/mujoco/assets/hopper.xml
similarity index 100%
rename from gym/envs/mujoco/assets/hopper.xml
rename to gymnasium/envs/mujoco/assets/hopper.xml
diff --git a/gym/envs/mujoco/assets/humanoid.xml b/gymnasium/envs/mujoco/assets/humanoid.xml
similarity index 98%
rename from gym/envs/mujoco/assets/humanoid.xml
rename to gymnasium/envs/mujoco/assets/humanoid.xml
index c8d5fc61a..a263bdbcf 100755
--- a/gym/envs/mujoco/assets/humanoid.xml
+++ b/gymnasium/envs/mujoco/assets/humanoid.xml
@@ -1,121 +1,121 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/gym/envs/mujoco/assets/humanoidstandup.xml b/gymnasium/envs/mujoco/assets/humanoidstandup.xml
similarity index 98%
rename from gym/envs/mujoco/assets/humanoidstandup.xml
rename to gymnasium/envs/mujoco/assets/humanoidstandup.xml
index 8dd36ba87..854dbc91c 100755
--- a/gym/envs/mujoco/assets/humanoidstandup.xml
+++ b/gymnasium/envs/mujoco/assets/humanoidstandup.xml
@@ -1,121 +1,121 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/gym/envs/mujoco/assets/inverted_double_pendulum.xml b/gymnasium/envs/mujoco/assets/inverted_double_pendulum.xml
similarity index 100%
rename from gym/envs/mujoco/assets/inverted_double_pendulum.xml
rename to gymnasium/envs/mujoco/assets/inverted_double_pendulum.xml
diff --git a/gym/envs/mujoco/assets/inverted_pendulum.xml b/gymnasium/envs/mujoco/assets/inverted_pendulum.xml
similarity index 98%
rename from gym/envs/mujoco/assets/inverted_pendulum.xml
rename to gymnasium/envs/mujoco/assets/inverted_pendulum.xml
index 851450429..8fb2db057 100644
--- a/gym/envs/mujoco/assets/inverted_pendulum.xml
+++ b/gymnasium/envs/mujoco/assets/inverted_pendulum.xml
@@ -1,27 +1,27 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/gym/envs/mujoco/assets/point.xml b/gymnasium/envs/mujoco/assets/point.xml
similarity index 100%
rename from gym/envs/mujoco/assets/point.xml
rename to gymnasium/envs/mujoco/assets/point.xml
diff --git a/gym/envs/mujoco/assets/pusher.xml b/gymnasium/envs/mujoco/assets/pusher.xml
similarity index 100%
rename from gym/envs/mujoco/assets/pusher.xml
rename to gymnasium/envs/mujoco/assets/pusher.xml
diff --git a/gym/envs/mujoco/assets/reacher.xml b/gymnasium/envs/mujoco/assets/reacher.xml
similarity index 98%
rename from gym/envs/mujoco/assets/reacher.xml
rename to gymnasium/envs/mujoco/assets/reacher.xml
index 151d1f851..1945a7f16 100644
--- a/gym/envs/mujoco/assets/reacher.xml
+++ b/gymnasium/envs/mujoco/assets/reacher.xml
@@ -1,39 +1,39 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/gym/envs/mujoco/assets/swimmer.xml b/gymnasium/envs/mujoco/assets/swimmer.xml
similarity index 100%
rename from gym/envs/mujoco/assets/swimmer.xml
rename to gymnasium/envs/mujoco/assets/swimmer.xml
diff --git a/gym/envs/mujoco/assets/walker2d.xml b/gymnasium/envs/mujoco/assets/walker2d.xml
similarity index 100%
rename from gym/envs/mujoco/assets/walker2d.xml
rename to gymnasium/envs/mujoco/assets/walker2d.xml
diff --git a/gym/envs/mujoco/half_cheetah.py b/gymnasium/envs/mujoco/half_cheetah.py
similarity index 94%
rename from gym/envs/mujoco/half_cheetah.py
rename to gymnasium/envs/mujoco/half_cheetah.py
index d29422a1a..f4ae8e791 100644
--- a/gym/envs/mujoco/half_cheetah.py
+++ b/gymnasium/envs/mujoco/half_cheetah.py
@@ -1,8 +1,8 @@
import numpy as np
-from gym import utils
-from gym.envs.mujoco import MuJocoPyEnv
-from gym.spaces import Box
+from gymnasium import utils
+from gymnasium.envs.mujoco import MuJocoPyEnv
+from gymnasium.spaces import Box
class HalfCheetahEnv(MuJocoPyEnv, utils.EzPickle):
diff --git a/gym/envs/mujoco/half_cheetah_v3.py b/gymnasium/envs/mujoco/half_cheetah_v3.py
similarity index 97%
rename from gym/envs/mujoco/half_cheetah_v3.py
rename to gymnasium/envs/mujoco/half_cheetah_v3.py
index 665ad5fcc..2cf666aec 100644
--- a/gym/envs/mujoco/half_cheetah_v3.py
+++ b/gymnasium/envs/mujoco/half_cheetah_v3.py
@@ -2,9 +2,9 @@
import numpy as np
-from gym import utils
-from gym.envs.mujoco import MuJocoPyEnv
-from gym.spaces import Box
+from gymnasium import utils
+from gymnasium.envs.mujoco import MuJocoPyEnv
+from gymnasium.spaces import Box
DEFAULT_CAMERA_CONFIG = {
"distance": 4.0,
diff --git a/gym/envs/mujoco/half_cheetah_v4.py b/gymnasium/envs/mujoco/half_cheetah_v4.py
similarity index 96%
rename from gym/envs/mujoco/half_cheetah_v4.py
rename to gymnasium/envs/mujoco/half_cheetah_v4.py
index b30c2861b..8c97cac18 100644
--- a/gym/envs/mujoco/half_cheetah_v4.py
+++ b/gymnasium/envs/mujoco/half_cheetah_v4.py
@@ -2,9 +2,9 @@
import numpy as np
-from gym import utils
-from gym.envs.mujoco import MujocoEnv
-from gym.spaces import Box
+from gymnasium import utils
+from gymnasium.envs.mujoco import MujocoEnv
+from gymnasium.spaces import Box
DEFAULT_CAMERA_CONFIG = {
"distance": 4.0,
@@ -106,13 +106,13 @@ class HalfCheetahEnv(MujocoEnv, utils.EzPickle):
No additional arguments are currently supported in v2 and lower.
```
- env = gym.make('HalfCheetah-v2')
+ env = gymnasium.make('HalfCheetah-v2')
```
- v3 and v4 take gym.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc.
+ v3 and v4 take gymnasium.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc.
```
- env = gym.make('HalfCheetah-v4', ctrl_cost_weight=0.1, ....)
+ env = gymnasium.make('HalfCheetah-v4', ctrl_cost_weight=0.1, ....)
```
| Parameter | Type | Default | Description |
@@ -126,7 +126,7 @@ class HalfCheetahEnv(MujocoEnv, utils.EzPickle):
### Version History
* v4: all mujoco environments now use the mujoco bindings in mujoco>=2.1.3
- * v3: support for gym.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc. rgb rendering comes from tracking camera (so agent does not run away from screen)
+ * v3: support for gymnasium.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc. rgb rendering comes from tracking camera (so agent does not run away from screen)
* v2: All continuous control environments now use mujoco_py >= 1.50
* v1: max_time_steps raised to 1000 for robot based tasks. Added reward_threshold to environments.
* v0: Initial versions release (1.0.0)
diff --git a/gym/envs/mujoco/hopper.py b/gymnasium/envs/mujoco/hopper.py
similarity index 94%
rename from gym/envs/mujoco/hopper.py
rename to gymnasium/envs/mujoco/hopper.py
index 315f605c4..11f4c4080 100644
--- a/gym/envs/mujoco/hopper.py
+++ b/gymnasium/envs/mujoco/hopper.py
@@ -1,8 +1,8 @@
import numpy as np
-from gym import utils
-from gym.envs.mujoco import MuJocoPyEnv
-from gym.spaces import Box
+from gymnasium import utils
+from gymnasium.envs.mujoco import MuJocoPyEnv
+from gymnasium.spaces import Box
class HopperEnv(MuJocoPyEnv, utils.EzPickle):
diff --git a/gym/envs/mujoco/hopper_v3.py b/gymnasium/envs/mujoco/hopper_v3.py
similarity index 97%
rename from gym/envs/mujoco/hopper_v3.py
rename to gymnasium/envs/mujoco/hopper_v3.py
index e31fc06a7..8024cbe89 100644
--- a/gym/envs/mujoco/hopper_v3.py
+++ b/gymnasium/envs/mujoco/hopper_v3.py
@@ -2,9 +2,9 @@
import numpy as np
-from gym import utils
-from gym.envs.mujoco import MuJocoPyEnv
-from gym.spaces import Box
+from gymnasium import utils
+from gymnasium.envs.mujoco import MuJocoPyEnv
+from gymnasium.spaces import Box
DEFAULT_CAMERA_CONFIG = {
"trackbodyid": 2,
diff --git a/gym/envs/mujoco/hopper_v4.py b/gymnasium/envs/mujoco/hopper_v4.py
similarity index 96%
rename from gym/envs/mujoco/hopper_v4.py
rename to gymnasium/envs/mujoco/hopper_v4.py
index b3490b7aa..abd7d7570 100644
--- a/gym/envs/mujoco/hopper_v4.py
+++ b/gymnasium/envs/mujoco/hopper_v4.py
@@ -1,8 +1,8 @@
import numpy as np
-from gym import utils
-from gym.envs.mujoco import MujocoEnv
-from gym.spaces import Box
+from gymnasium import utils
+from gymnasium.envs.mujoco import MujocoEnv
+from gymnasium.spaces import Box
DEFAULT_CAMERA_CONFIG = {
"trackbodyid": 2,
@@ -107,13 +107,13 @@ class HopperEnv(MujocoEnv, utils.EzPickle):
No additional arguments are currently supported in v2 and lower.
```
- env = gym.make('Hopper-v2')
+ env = gymnasium.make('Hopper-v2')
```
- v3 and v4 take gym.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc.
+ v3 and v4 take gymnasium.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc.
```
- env = gym.make('Hopper-v4', ctrl_cost_weight=0.1, ....)
+ env = gymnasium.make('Hopper-v4', ctrl_cost_weight=0.1, ....)
```
| Parameter | Type | Default | Description |
@@ -132,7 +132,7 @@ class HopperEnv(MujocoEnv, utils.EzPickle):
### Version History
* v4: all mujoco environments now use the mujoco bindings in mujoco>=2.1.3
- * v3: support for gym.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc. rgb rendering comes from tracking camera (so agent does not run away from screen)
+ * v3: support for gymnasium.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc. rgb rendering comes from tracking camera (so agent does not run away from screen)
* v2: All continuous control environments now use mujoco_py >= 1.50
* v1: max_time_steps raised to 1000 for robot based tasks. Added reward_threshold to environments.
* v0: Initial versions release (1.0.0)
diff --git a/gym/envs/mujoco/humanoid.py b/gymnasium/envs/mujoco/humanoid.py
similarity index 96%
rename from gym/envs/mujoco/humanoid.py
rename to gymnasium/envs/mujoco/humanoid.py
index 5dde40a0a..59370b211 100644
--- a/gym/envs/mujoco/humanoid.py
+++ b/gymnasium/envs/mujoco/humanoid.py
@@ -1,8 +1,8 @@
import numpy as np
-from gym import utils
-from gym.envs.mujoco import MuJocoPyEnv
-from gym.spaces import Box
+from gymnasium import utils
+from gymnasium.envs.mujoco import MuJocoPyEnv
+from gymnasium.spaces import Box
def mass_center(model, sim):
diff --git a/gym/envs/mujoco/humanoid_v3.py b/gymnasium/envs/mujoco/humanoid_v3.py
similarity index 98%
rename from gym/envs/mujoco/humanoid_v3.py
rename to gymnasium/envs/mujoco/humanoid_v3.py
index 36e53bf18..1ff04ba76 100644
--- a/gym/envs/mujoco/humanoid_v3.py
+++ b/gymnasium/envs/mujoco/humanoid_v3.py
@@ -1,8 +1,8 @@
import numpy as np
-from gym import utils
-from gym.envs.mujoco import MuJocoPyEnv
-from gym.spaces import Box
+from gymnasium import utils
+from gymnasium.envs.mujoco import MuJocoPyEnv
+from gymnasium.spaces import Box
DEFAULT_CAMERA_CONFIG = {
"trackbodyid": 1,
diff --git a/gym/envs/mujoco/humanoid_v4.py b/gymnasium/envs/mujoco/humanoid_v4.py
similarity index 98%
rename from gym/envs/mujoco/humanoid_v4.py
rename to gymnasium/envs/mujoco/humanoid_v4.py
index add57a02f..7ac078d52 100644
--- a/gym/envs/mujoco/humanoid_v4.py
+++ b/gymnasium/envs/mujoco/humanoid_v4.py
@@ -1,8 +1,8 @@
import numpy as np
-from gym import utils
-from gym.envs.mujoco import MujocoEnv
-from gym.spaces import Box
+from gymnasium import utils
+from gymnasium.envs.mujoco import MujocoEnv
+from gymnasium.spaces import Box
DEFAULT_CAMERA_CONFIG = {
"trackbodyid": 1,
@@ -182,13 +182,13 @@ class HumanoidEnv(MujocoEnv, utils.EzPickle):
No additional arguments are currently supported in v2 and lower.
```
- env = gym.make('Humanoid-v4')
+ env = gymnasium.make('Humanoid-v4')
```
- v3 and v4 take gym.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc.
+ v3 and v4 take gymnasium.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc.
```
- env = gym.make('Humanoid-v4', ctrl_cost_weight=0.1, ....)
+ env = gymnasium.make('Humanoid-v4', ctrl_cost_weight=0.1, ....)
```
| Parameter | Type | Default | Description |
@@ -206,7 +206,7 @@ class HumanoidEnv(MujocoEnv, utils.EzPickle):
### Version History
* v4: all mujoco environments now use the mujoco bindings in mujoco>=2.1.3
- * v3: support for gym.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc. rgb rendering comes from tracking camera (so agent does not run away from screen)
+ * v3: support for gymnasium.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc. rgb rendering comes from tracking camera (so agent does not run away from screen)
* v2: All continuous control environments now use mujoco_py >= 1.50
* v1: max_time_steps raised to 1000 for robot based tasks. Added reward_threshold to environments.
* v0: Initial versions release (1.0.0)
diff --git a/gym/envs/mujoco/humanoidstandup.py b/gymnasium/envs/mujoco/humanoidstandup.py
similarity index 95%
rename from gym/envs/mujoco/humanoidstandup.py
rename to gymnasium/envs/mujoco/humanoidstandup.py
index db25e12b3..574a500a1 100644
--- a/gym/envs/mujoco/humanoidstandup.py
+++ b/gymnasium/envs/mujoco/humanoidstandup.py
@@ -1,8 +1,8 @@
import numpy as np
-from gym import utils
-from gym.envs.mujoco import MuJocoPyEnv
-from gym.spaces import Box
+from gymnasium import utils
+from gymnasium.envs.mujoco import MuJocoPyEnv
+from gymnasium.spaces import Box
class HumanoidStandupEnv(MuJocoPyEnv, utils.EzPickle):
diff --git a/gym/envs/mujoco/humanoidstandup_v4.py b/gymnasium/envs/mujoco/humanoidstandup_v4.py
similarity index 98%
rename from gym/envs/mujoco/humanoidstandup_v4.py
rename to gymnasium/envs/mujoco/humanoidstandup_v4.py
index b04351229..15213a403 100644
--- a/gym/envs/mujoco/humanoidstandup_v4.py
+++ b/gymnasium/envs/mujoco/humanoidstandup_v4.py
@@ -1,8 +1,8 @@
import numpy as np
-from gym import utils
-from gym.envs.mujoco import MujocoEnv
-from gym.spaces import Box
+from gymnasium import utils
+from gymnasium.envs.mujoco import MujocoEnv
+from gymnasium.spaces import Box
class HumanoidStandupEnv(MujocoEnv, utils.EzPickle):
@@ -162,17 +162,17 @@ class HumanoidStandupEnv(MujocoEnv, utils.EzPickle):
No additional arguments are currently supported.
```
- env = gym.make('HumanoidStandup-v4')
+ env = gymnasium.make('HumanoidStandup-v4')
```
There is no v3 for HumanoidStandup, unlike the robot environments where a v3 and
- beyond take gym.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc.
+ beyond take gymnasium.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc.
### Version History
* v4: all mujoco environments now use the mujoco bindings in mujoco>=2.1.3
- * v3: support for gym.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc. rgb rendering comes from tracking camera (so agent does not run away from screen)
+ * v3: support for gymnasium.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc. rgb rendering comes from tracking camera (so agent does not run away from screen)
* v2: All continuous control environments now use mujoco_py >= 1.50
* v1: max_time_steps raised to 1000 for robot based tasks. Added reward_threshold to environments.
* v0: Initial versions release (1.0.0)
diff --git a/gym/envs/mujoco/inverted_double_pendulum.py b/gymnasium/envs/mujoco/inverted_double_pendulum.py
similarity index 95%
rename from gym/envs/mujoco/inverted_double_pendulum.py
rename to gymnasium/envs/mujoco/inverted_double_pendulum.py
index 639b96557..d0b6ca4b7 100644
--- a/gym/envs/mujoco/inverted_double_pendulum.py
+++ b/gymnasium/envs/mujoco/inverted_double_pendulum.py
@@ -1,8 +1,8 @@
import numpy as np
-from gym import utils
-from gym.envs.mujoco import MuJocoPyEnv
-from gym.spaces import Box
+from gymnasium import utils
+from gymnasium.envs.mujoco import MuJocoPyEnv
+from gymnasium.spaces import Box
class InvertedDoublePendulumEnv(MuJocoPyEnv, utils.EzPickle):
diff --git a/gym/envs/mujoco/inverted_double_pendulum_v4.py b/gymnasium/envs/mujoco/inverted_double_pendulum_v4.py
similarity index 95%
rename from gym/envs/mujoco/inverted_double_pendulum_v4.py
rename to gymnasium/envs/mujoco/inverted_double_pendulum_v4.py
index b5d992564..8e48f47ff 100644
--- a/gym/envs/mujoco/inverted_double_pendulum_v4.py
+++ b/gymnasium/envs/mujoco/inverted_double_pendulum_v4.py
@@ -1,8 +1,8 @@
import numpy as np
-from gym import utils
-from gym.envs.mujoco import MujocoEnv
-from gym.spaces import Box
+from gymnasium import utils
+from gymnasium.envs.mujoco import MujocoEnv
+from gymnasium.spaces import Box
class InvertedDoublePendulumEnv(MujocoEnv, utils.EzPickle):
@@ -97,16 +97,16 @@ class InvertedDoublePendulumEnv(MujocoEnv, utils.EzPickle):
No additional arguments are currently supported.
```
- env = gym.make('InvertedDoublePendulum-v4')
+ env = gymnasium.make('InvertedDoublePendulum-v4')
```
There is no v3 for InvertedPendulum, unlike the robot environments where a v3 and
- beyond take gym.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc.
+ beyond take gymnasium.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc.
### Version History
* v4: all mujoco environments now use the mujoco bindings in mujoco>=2.1.3
- * v3: support for gym.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc. rgb rendering comes from tracking camera (so agent does not run away from screen)
+ * v3: support for gymnasium.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc. rgb rendering comes from tracking camera (so agent does not run away from screen)
* v2: All continuous control environments now use mujoco_py >= 1.50
* v1: max_time_steps raised to 1000 for robot based tasks (including inverted pendulum)
* v0: Initial versions release (1.0.0)
diff --git a/gym/envs/mujoco/inverted_pendulum.py b/gymnasium/envs/mujoco/inverted_pendulum.py
similarity index 93%
rename from gym/envs/mujoco/inverted_pendulum.py
rename to gymnasium/envs/mujoco/inverted_pendulum.py
index eebdbbb00..343515d09 100644
--- a/gym/envs/mujoco/inverted_pendulum.py
+++ b/gymnasium/envs/mujoco/inverted_pendulum.py
@@ -1,8 +1,8 @@
import numpy as np
-from gym import utils
-from gym.envs.mujoco import MuJocoPyEnv
-from gym.spaces import Box
+from gymnasium import utils
+from gymnasium.envs.mujoco import MuJocoPyEnv
+from gymnasium.spaces import Box
class InvertedPendulumEnv(MuJocoPyEnv, utils.EzPickle):
diff --git a/gym/envs/mujoco/inverted_pendulum_v4.py b/gymnasium/envs/mujoco/inverted_pendulum_v4.py
similarity index 92%
rename from gym/envs/mujoco/inverted_pendulum_v4.py
rename to gymnasium/envs/mujoco/inverted_pendulum_v4.py
index 258242756..f2f18fcf5 100644
--- a/gym/envs/mujoco/inverted_pendulum_v4.py
+++ b/gymnasium/envs/mujoco/inverted_pendulum_v4.py
@@ -1,8 +1,8 @@
import numpy as np
-from gym import utils
-from gym.envs.mujoco import MujocoEnv
-from gym.spaces import Box
+from gymnasium import utils
+from gymnasium.envs.mujoco import MujocoEnv
+from gymnasium.spaces import Box
class InvertedPendulumEnv(MujocoEnv, utils.EzPickle):
@@ -68,16 +68,16 @@ class InvertedPendulumEnv(MujocoEnv, utils.EzPickle):
No additional arguments are currently supported.
```
- env = gym.make('InvertedPendulum-v4')
+ env = gymnasium.make('InvertedPendulum-v4')
```
There is no v3 for InvertedPendulum, unlike the robot environments where a
- v3 and beyond take gym.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc.
+ v3 and beyond take gymnasium.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc.
### Version History
* v4: all mujoco environments now use the mujoco bindings in mujoco>=2.1.3
- * v3: support for gym.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc. rgb rendering comes from tracking camera (so agent does not run away from screen)
+ * v3: support for gymnasium.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc. rgb rendering comes from tracking camera (so agent does not run away from screen)
* v2: All continuous control environments now use mujoco_py >= 1.50
* v1: max_time_steps raised to 1000 for robot based tasks (including inverted pendulum)
* v0: Initial versions release (1.0.0)
diff --git a/gym/envs/mujoco/mujoco_env.py b/gymnasium/envs/mujoco/mujoco_env.py
similarity index 97%
rename from gym/envs/mujoco/mujoco_env.py
rename to gymnasium/envs/mujoco/mujoco_env.py
index 28b6fbb9a..42e37ffad 100644
--- a/gym/envs/mujoco/mujoco_env.py
+++ b/gymnasium/envs/mujoco/mujoco_env.py
@@ -3,9 +3,9 @@
import numpy as np
-import gym
-from gym import error, logger, spaces
-from gym.spaces import Space
+import gymnasium
+from gymnasium import error, logger, spaces
+from gymnasium.spaces import Space
MUJOCO_PY_NOT_INSTALLED = False
MUJOCO_NOT_INSTALLED = False
@@ -26,7 +26,7 @@
DEFAULT_SIZE = 480
-class BaseMujocoEnv(gym.Env):
+class BaseMujocoEnv(gymnasium.Env):
"""Superclass for all MuJoCo environments."""
def __init__(
@@ -395,15 +395,15 @@ def close(self):
def _get_viewer(
self, mode
- ) -> Union["gym.envs.mujoco.Viewer", "gym.envs.mujoco.RenderContextOffscreen"]:
+ ) -> Union["gymnasium.envs.mujoco.Viewer", "gymnasium.envs.mujoco.RenderContextOffscreen"]:
self.viewer = self._viewers.get(mode)
if self.viewer is None:
if mode == "human":
- from gym.envs.mujoco import Viewer
+ from gymnasium.envs.mujoco import Viewer
self.viewer = Viewer(self.model, self.data)
elif mode in {"rgb_array", "depth_array"}:
- from gym.envs.mujoco import RenderContextOffscreen
+ from gymnasium.envs.mujoco import RenderContextOffscreen
self.viewer = RenderContextOffscreen(self.model, self.data)
else:
diff --git a/gym/envs/mujoco/mujoco_rendering.py b/gymnasium/envs/mujoco/mujoco_rendering.py
similarity index 100%
rename from gym/envs/mujoco/mujoco_rendering.py
rename to gymnasium/envs/mujoco/mujoco_rendering.py
diff --git a/gym/envs/mujoco/pusher.py b/gymnasium/envs/mujoco/pusher.py
similarity index 95%
rename from gym/envs/mujoco/pusher.py
rename to gymnasium/envs/mujoco/pusher.py
index 63f58f2ed..2c446bdc2 100644
--- a/gym/envs/mujoco/pusher.py
+++ b/gymnasium/envs/mujoco/pusher.py
@@ -1,8 +1,8 @@
import numpy as np
-from gym import utils
-from gym.envs.mujoco import MuJocoPyEnv
-from gym.spaces import Box
+from gymnasium import utils
+from gymnasium.envs.mujoco import MuJocoPyEnv
+from gymnasium.spaces import Box
class PusherEnv(MuJocoPyEnv, utils.EzPickle):
diff --git a/gym/envs/mujoco/pusher_v4.py b/gymnasium/envs/mujoco/pusher_v4.py
similarity index 98%
rename from gym/envs/mujoco/pusher_v4.py
rename to gymnasium/envs/mujoco/pusher_v4.py
index 07ecd1652..df9b9456f 100644
--- a/gym/envs/mujoco/pusher_v4.py
+++ b/gymnasium/envs/mujoco/pusher_v4.py
@@ -1,8 +1,8 @@
import numpy as np
-from gym import utils
-from gym.envs.mujoco import MujocoEnv
-from gym.spaces import Box
+from gymnasium import utils
+from gymnasium.envs.mujoco import MujocoEnv
+from gymnasium.spaces import Box
class PusherEnv(MujocoEnv, utils.EzPickle):
@@ -113,11 +113,11 @@ class PusherEnv(MujocoEnv, utils.EzPickle):
(or by changing the path to a modified XML file in another folder)..
```
- env = gym.make('Pusher-v4')
+ env = gymnasium.make('Pusher-v4')
```
There is no v3 for Pusher, unlike the robot environments where a v3 and
- beyond take gym.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc.
+ beyond take gymnasium.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc.
### Version History
diff --git a/gym/envs/mujoco/reacher.py b/gymnasium/envs/mujoco/reacher.py
similarity index 95%
rename from gym/envs/mujoco/reacher.py
rename to gymnasium/envs/mujoco/reacher.py
index 931dc50f8..342a82a29 100644
--- a/gym/envs/mujoco/reacher.py
+++ b/gymnasium/envs/mujoco/reacher.py
@@ -1,8 +1,8 @@
import numpy as np
-from gym import utils
-from gym.envs.mujoco import MuJocoPyEnv
-from gym.spaces import Box
+from gymnasium import utils
+from gymnasium.envs.mujoco import MuJocoPyEnv
+from gymnasium.spaces import Box
class ReacherEnv(MuJocoPyEnv, utils.EzPickle):
diff --git a/gym/envs/mujoco/reacher_v4.py b/gymnasium/envs/mujoco/reacher_v4.py
similarity index 97%
rename from gym/envs/mujoco/reacher_v4.py
rename to gymnasium/envs/mujoco/reacher_v4.py
index 4740652be..a3a153cb6 100644
--- a/gym/envs/mujoco/reacher_v4.py
+++ b/gymnasium/envs/mujoco/reacher_v4.py
@@ -1,8 +1,8 @@
import numpy as np
-from gym import utils
-from gym.envs.mujoco import MujocoEnv
-from gym.spaces import Box
+from gymnasium import utils
+from gymnasium.envs.mujoco import MujocoEnv
+from gymnasium.spaces import Box
class ReacherEnv(MujocoEnv, utils.EzPickle):
@@ -103,11 +103,11 @@ class ReacherEnv(MujocoEnv, utils.EzPickle):
(or by changing the path to a modified XML file in another folder)..
```
- env = gym.make('Reacher-v4')
+ env = gymnasium.make('Reacher-v4')
```
There is no v3 for Reacher, unlike the robot environments where a v3 and
- beyond take gym.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc.
+ beyond take gymnasium.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc.
### Version History
diff --git a/gym/envs/mujoco/swimmer.py b/gymnasium/envs/mujoco/swimmer.py
similarity index 93%
rename from gym/envs/mujoco/swimmer.py
rename to gymnasium/envs/mujoco/swimmer.py
index 612a392f4..a82bab533 100644
--- a/gym/envs/mujoco/swimmer.py
+++ b/gymnasium/envs/mujoco/swimmer.py
@@ -1,8 +1,8 @@
import numpy as np
-from gym import utils
-from gym.envs.mujoco import MuJocoPyEnv
-from gym.spaces import Box
+from gymnasium import utils
+from gymnasium.envs.mujoco import MuJocoPyEnv
+from gymnasium.spaces import Box
class SwimmerEnv(MuJocoPyEnv, utils.EzPickle):
diff --git a/gym/envs/mujoco/swimmer_v3.py b/gymnasium/envs/mujoco/swimmer_v3.py
similarity index 97%
rename from gym/envs/mujoco/swimmer_v3.py
rename to gymnasium/envs/mujoco/swimmer_v3.py
index 68a0d4fc4..97170b8e8 100644
--- a/gym/envs/mujoco/swimmer_v3.py
+++ b/gymnasium/envs/mujoco/swimmer_v3.py
@@ -2,9 +2,9 @@
import numpy as np
-from gym import utils
-from gym.envs.mujoco import MuJocoPyEnv
-from gym.spaces import Box
+from gymnasium import utils
+from gymnasium.envs.mujoco import MuJocoPyEnv
+from gymnasium.spaces import Box
DEFAULT_CAMERA_CONFIG = {}
diff --git a/gym/envs/mujoco/swimmer_v4.py b/gymnasium/envs/mujoco/swimmer_v4.py
similarity index 95%
rename from gym/envs/mujoco/swimmer_v4.py
rename to gymnasium/envs/mujoco/swimmer_v4.py
index ef611af92..f43dcaa33 100644
--- a/gym/envs/mujoco/swimmer_v4.py
+++ b/gymnasium/envs/mujoco/swimmer_v4.py
@@ -2,9 +2,9 @@
import numpy as np
-from gym import utils
-from gym.envs.mujoco import MujocoEnv
-from gym.spaces import Box
+from gymnasium import utils
+from gymnasium.envs.mujoco import MujocoEnv
+from gymnasium.spaces import Box
DEFAULT_CAMERA_CONFIG = {}
@@ -97,13 +97,13 @@ class SwimmerEnv(MujocoEnv, utils.EzPickle):
No additional arguments are currently supported in v2 and lower.
```
- gym.make('Swimmer-v4')
+ gymnasium.make('Swimmer-v4')
```
- v3 and v4 take gym.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc.
+ v3 and v4 take gymnasium.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc.
```
- env = gym.make('Swimmer-v4', ctrl_cost_weight=0.1, ....)
+ env = gymnasium.make('Swimmer-v4', ctrl_cost_weight=0.1, ....)
```
| Parameter | Type | Default | Description |
@@ -118,7 +118,7 @@ class SwimmerEnv(MujocoEnv, utils.EzPickle):
### Version History
* v4: all mujoco environments now use the mujoco bindings in mujoco>=2.1.3
- * v3: support for gym.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc. rgb rendering comes from tracking camera (so agent does not run away from screen)
+ * v3: support for gymnasium.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc. rgb rendering comes from tracking camera (so agent does not run away from screen)
* v2: All continuous control environments now use mujoco_py >= 1.50
* v1: max_time_steps raised to 1000 for robot based tasks. Added reward_threshold to environments.
* v0: Initial versions release (1.0.0)
diff --git a/gym/envs/mujoco/walker2d.py b/gymnasium/envs/mujoco/walker2d.py
similarity index 94%
rename from gym/envs/mujoco/walker2d.py
rename to gymnasium/envs/mujoco/walker2d.py
index 3c5506c49..74d0890df 100644
--- a/gym/envs/mujoco/walker2d.py
+++ b/gymnasium/envs/mujoco/walker2d.py
@@ -1,8 +1,8 @@
import numpy as np
-from gym import utils
-from gym.envs.mujoco import MuJocoPyEnv
-from gym.spaces import Box
+from gymnasium import utils
+from gymnasium.envs.mujoco import MuJocoPyEnv
+from gymnasium.spaces import Box
class Walker2dEnv(MuJocoPyEnv, utils.EzPickle):
diff --git a/gym/envs/mujoco/walker2d_v3.py b/gymnasium/envs/mujoco/walker2d_v3.py
similarity index 97%
rename from gym/envs/mujoco/walker2d_v3.py
rename to gymnasium/envs/mujoco/walker2d_v3.py
index cfbd9933a..8622abefd 100644
--- a/gym/envs/mujoco/walker2d_v3.py
+++ b/gymnasium/envs/mujoco/walker2d_v3.py
@@ -1,8 +1,8 @@
import numpy as np
-from gym import utils
-from gym.envs.mujoco import MuJocoPyEnv
-from gym.spaces import Box
+from gymnasium import utils
+from gymnasium.envs.mujoco import MuJocoPyEnv
+from gymnasium.spaces import Box
DEFAULT_CAMERA_CONFIG = {
"trackbodyid": 2,
diff --git a/gym/envs/mujoco/walker2d_v4.py b/gymnasium/envs/mujoco/walker2d_v4.py
similarity index 96%
rename from gym/envs/mujoco/walker2d_v4.py
rename to gymnasium/envs/mujoco/walker2d_v4.py
index 47e562817..0fd6481fc 100644
--- a/gym/envs/mujoco/walker2d_v4.py
+++ b/gymnasium/envs/mujoco/walker2d_v4.py
@@ -1,8 +1,8 @@
import numpy as np
-from gym import utils
-from gym.envs.mujoco import MujocoEnv
-from gym.spaces import Box
+from gymnasium import utils
+from gymnasium.envs.mujoco import MujocoEnv
+from gymnasium.spaces import Box
DEFAULT_CAMERA_CONFIG = {
"trackbodyid": 2,
@@ -112,13 +112,13 @@ class Walker2dEnv(MujocoEnv, utils.EzPickle):
No additional arguments are currently supported in v2 and lower.
```
- env = gym.make('Walker2d-v4')
+ env = gymnasium.make('Walker2d-v4')
```
- v3 and beyond take gym.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc.
+ v3 and beyond take gymnasium.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc.
```
- env = gym.make('Walker2d-v4', ctrl_cost_weight=0.1, ....)
+ env = gymnasium.make('Walker2d-v4', ctrl_cost_weight=0.1, ....)
```
| Parameter | Type | Default | Description |
@@ -137,7 +137,7 @@ class Walker2dEnv(MujocoEnv, utils.EzPickle):
### Version History
* v4: all mujoco environments now use the mujoco bindings in mujoco>=2.1.3
- * v3: support for gym.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc. rgb rendering comes from tracking camera (so agent does not run away from screen)
+ * v3: support for gymnasium.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc. rgb rendering comes from tracking camera (so agent does not run away from screen)
* v2: All continuous control environments now use mujoco_py >= 1.50
* v1: max_time_steps raised to 1000 for robot based tasks. Added reward_threshold to environments.
* v0: Initial versions release (1.0.0)
diff --git a/gym/envs/registration.py b/gymnasium/envs/registration.py
similarity index 97%
rename from gym/envs/registration.py
rename to gymnasium/envs/registration.py
index 6b0237eac..ccc15a984 100644
--- a/gym/envs/registration.py
+++ b/gymnasium/envs/registration.py
@@ -21,15 +21,15 @@
import numpy as np
-from gym.wrappers import (
+from gymnasium.wrappers import (
AutoResetWrapper,
HumanRendering,
OrderEnforcing,
RenderCollection,
TimeLimit,
)
-from gym.wrappers.compatibility import EnvCompatibility
-from gym.wrappers.env_checker import PassiveEnvChecker
+from gymnasium.wrappers.compatibility import EnvCompatibility
+from gymnasium.wrappers.env_checker import PassiveEnvChecker
if sys.version_info < (3, 10):
import importlib_metadata as metadata # type: ignore
@@ -41,7 +41,7 @@
else:
from typing_extensions import Literal
-from gym import Env, error, logger
+from gymnasium import Env, error, logger
ENV_ID_RE = re.compile(
r"^(?:(?P[\w:-]+)\/)?(?:(?P[\w:.-]+?))(?:-v(?P\d+))?$"
@@ -116,17 +116,17 @@ def get_env_id(ns: Optional[str], name: str, version: Optional[int]) -> str:
@dataclass
class EnvSpec:
- """A specification for creating environments with `gym.make`.
+ """A specification for creating environments with `gymnasium.make`.
- * id: The string used to create the environment with `gym.make`
+ * id: The string used to create the environment with `gymnasium.make`
* entry_point: The location of the environment to create from
* reward_threshold: The reward threshold for completing the environment.
* nondeterministic: If the observation of an environment cannot be repeated with the same initial state, random number generator state and actions.
* max_episode_steps: The max number of steps that the environment can take before truncation
* order_enforce: If to enforce the order of `reset` before `step` and `render` functions
* autoreset: If to automatically reset the environment on episode end
- * disable_env_checker: If to disable the environment checker wrapper in `gym.make`, by default False (runs the environment checker)
- * kwargs: Additional keyword arguments passed to the environments through `gym.make`
+ * disable_env_checker: If to disable the environment checker wrapper in `gymnasium.make`, by default False (runs the environment checker)
+ * kwargs: Additional keyword arguments passed to the environments through `gymnasium.make`
"""
id: str
@@ -263,7 +263,7 @@ def find_highest_version(ns: Optional[str], name: str) -> Optional[int]:
return max(version, default=None)
-def load_env_plugins(entry_point: str = "gym.envs") -> None:
+def load_env_plugins(entry_point: str = "gymnasium.envs") -> None:
# Load third-party environments
for plugin in metadata.entry_points(group=entry_point):
# Python 3.8 doesn't support plugin.module, plugin.attr
@@ -414,7 +414,7 @@ def _check_spec_register(spec: EnvSpec):
f"`{spec.id}` when the versioned environment "
f"`{latest_versioned_spec.id}` of the same name "
f"already exists. Note: the default behavior is "
- f"that `gym.make` with the unversioned environment "
+ f"that `gymnasium.make` with the unversioned environment "
f"will return the latest versioned environment"
)
@@ -443,7 +443,7 @@ def register(
apply_api_compatibility: bool = False,
**kwargs,
):
- """Register an environment with gym.
+ """Register an environment with gymnasium.
The `id` parameter corresponds to the name of the environment, with the syntax as follows:
`(namespace)/(env_name)-v(version)` where `namespace` is optional.
@@ -509,7 +509,7 @@ def make(
) -> Env:
"""Create an environment according to the given ID.
- To find all available environments use `gym.envs.registry.keys()` for all valid ids.
+ To find all available environments use `gymnasium.envs.registry.keys()` for all valid ids.
Args:
id: Name of the environment. Optionally, a module to import can be included, eg. 'module:Env-v0'
diff --git a/gymnasium/envs/toy_text/__init__.py b/gymnasium/envs/toy_text/__init__.py
new file mode 100644
index 000000000..72f2b508b
--- /dev/null
+++ b/gymnasium/envs/toy_text/__init__.py
@@ -0,0 +1,4 @@
+from gymnasium.envs.toy_text.blackjack import BlackjackEnv
+from gymnasium.envs.toy_text.cliffwalking import CliffWalkingEnv
+from gymnasium.envs.toy_text.frozen_lake import FrozenLakeEnv
+from gymnasium.envs.toy_text.taxi import TaxiEnv
diff --git a/gym/envs/toy_text/blackjack.py b/gymnasium/envs/toy_text/blackjack.py
similarity index 97%
rename from gym/envs/toy_text/blackjack.py
rename to gymnasium/envs/toy_text/blackjack.py
index 8a767e08e..ea800873e 100644
--- a/gym/envs/toy_text/blackjack.py
+++ b/gymnasium/envs/toy_text/blackjack.py
@@ -3,9 +3,9 @@
import numpy as np
-import gym
-from gym import spaces
-from gym.error import DependencyNotInstalled
+import gymnasium
+from gymnasium import spaces
+from gymnasium.error import DependencyNotInstalled
def cmp(a, b):
@@ -46,7 +46,7 @@ def is_natural(hand): # Is this hand a natural blackjack?
return sorted(hand) == [1, 10]
-class BlackjackEnv(gym.Env):
+class BlackjackEnv(gymnasium.Env):
"""
Blackjack is a card game where the goal is to beat the dealer by obtaining cards
that sum to closer to 21 (without going over 21) than the dealers cards.
@@ -94,7 +94,7 @@ class BlackjackEnv(gym.Env):
### Arguments
```
- gym.make('Blackjack-v1', natural=False, sab=False)
+ gymnasium.make('Blackjack-v1', natural=False, sab=False)
```
`natural=False`: Whether to give an additional reward for
@@ -194,7 +194,7 @@ def render(self):
import pygame
except ImportError:
raise DependencyNotInstalled(
- "pygame is not installed, run `pip install gym[toy_text]`"
+ "pygame is not installed, run `pip install gymnasium[toy_text]`"
)
player_sum, dealer_card_value, usable_ace = self._get_obs()
diff --git a/gym/envs/toy_text/cliffwalking.py b/gymnasium/envs/toy_text/cliffwalking.py
similarity index 97%
rename from gym/envs/toy_text/cliffwalking.py
rename to gymnasium/envs/toy_text/cliffwalking.py
index 9b543174e..c25cc90d4 100644
--- a/gym/envs/toy_text/cliffwalking.py
+++ b/gymnasium/envs/toy_text/cliffwalking.py
@@ -5,9 +5,9 @@
import numpy as np
-from gym import Env, spaces
-from gym.envs.toy_text.utils import categorical_sample
-from gym.error import DependencyNotInstalled
+from gymnasium import Env, spaces
+from gymnasium.envs.toy_text.utils import categorical_sample
+from gymnasium.error import DependencyNotInstalled
UP = 0
RIGHT = 1
@@ -55,7 +55,7 @@ class CliffWalkingEnv(Env):
### Arguments
```
- gym.make('CliffWalking-v0')
+ gymnasium.make('CliffWalking-v0')
```
### Version History
@@ -173,7 +173,7 @@ def _render_gui(self, mode):
import pygame
except ImportError:
raise DependencyNotInstalled(
- "pygame is not installed, run `pip install gym[toy_text]`"
+ "pygame is not installed, run `pip install gymnasium[toy_text]`"
)
if self.window_surface is None:
pygame.init()
diff --git a/gym/envs/toy_text/font/Minecraft.ttf b/gymnasium/envs/toy_text/font/Minecraft.ttf
similarity index 100%
rename from gym/envs/toy_text/font/Minecraft.ttf
rename to gymnasium/envs/toy_text/font/Minecraft.ttf
diff --git a/gym/envs/toy_text/frozen_lake.py b/gymnasium/envs/toy_text/frozen_lake.py
similarity index 96%
rename from gym/envs/toy_text/frozen_lake.py
rename to gymnasium/envs/toy_text/frozen_lake.py
index 404d2b08a..a468a6501 100644
--- a/gym/envs/toy_text/frozen_lake.py
+++ b/gymnasium/envs/toy_text/frozen_lake.py
@@ -5,9 +5,9 @@
import numpy as np
-from gym import Env, spaces, utils
-from gym.envs.toy_text.utils import categorical_sample
-from gym.error import DependencyNotInstalled
+from gymnasium import Env, spaces, utils
+from gymnasium.envs.toy_text.utils import categorical_sample
+from gymnasium.error import DependencyNotInstalled
LEFT = 0
DOWN = 1
@@ -105,7 +105,7 @@ class FrozenLakeEnv(Env):
### Arguments
```
- gym.make('FrozenLake-v1', desc=None, map_name="4x4", is_slippery=True)
+ gymnasium.make('FrozenLake-v1', desc=None, map_name="4x4", is_slippery=True)
```
`desc`: Used to specify custom map for frozen lake. For example,
@@ -115,9 +115,9 @@ class FrozenLakeEnv(Env):
A random generated map can be specified by calling the function `generate_random_map`. For example,
```
- from gym.envs.toy_text.frozen_lake import generate_random_map
+ from gymnasium.envs.toy_text.frozen_lake import generate_random_map
- gym.make('FrozenLake-v1', desc=generate_random_map(size=8))
+ gymnasium.make('FrozenLake-v1', desc=generate_random_map(size=8))
```
`map_name`: ID to use any of the preloaded maps.
@@ -277,7 +277,7 @@ def _render_gui(self, mode):
import pygame
except ImportError:
raise DependencyNotInstalled(
- "pygame is not installed, run `pip install gym[toy_text]`"
+ "pygame is not installed, run `pip install gymnasium[toy_text]`"
)
if self.window_surface is None:
diff --git a/gym/envs/toy_text/img/C2.png b/gymnasium/envs/toy_text/img/C2.png
similarity index 100%
rename from gym/envs/toy_text/img/C2.png
rename to gymnasium/envs/toy_text/img/C2.png
diff --git a/gym/envs/toy_text/img/C3.png b/gymnasium/envs/toy_text/img/C3.png
similarity index 100%
rename from gym/envs/toy_text/img/C3.png
rename to gymnasium/envs/toy_text/img/C3.png
diff --git a/gym/envs/toy_text/img/C4.png b/gymnasium/envs/toy_text/img/C4.png
similarity index 100%
rename from gym/envs/toy_text/img/C4.png
rename to gymnasium/envs/toy_text/img/C4.png
diff --git a/gym/envs/toy_text/img/C5.png b/gymnasium/envs/toy_text/img/C5.png
similarity index 100%
rename from gym/envs/toy_text/img/C5.png
rename to gymnasium/envs/toy_text/img/C5.png
diff --git a/gym/envs/toy_text/img/C6.png b/gymnasium/envs/toy_text/img/C6.png
similarity index 100%
rename from gym/envs/toy_text/img/C6.png
rename to gymnasium/envs/toy_text/img/C6.png
diff --git a/gym/envs/toy_text/img/C7.png b/gymnasium/envs/toy_text/img/C7.png
similarity index 100%
rename from gym/envs/toy_text/img/C7.png
rename to gymnasium/envs/toy_text/img/C7.png
diff --git a/gym/envs/toy_text/img/C8.png b/gymnasium/envs/toy_text/img/C8.png
similarity index 100%
rename from gym/envs/toy_text/img/C8.png
rename to gymnasium/envs/toy_text/img/C8.png
diff --git a/gym/envs/toy_text/img/C9.png b/gymnasium/envs/toy_text/img/C9.png
similarity index 100%
rename from gym/envs/toy_text/img/C9.png
rename to gymnasium/envs/toy_text/img/C9.png
diff --git a/gym/envs/toy_text/img/CA.png b/gymnasium/envs/toy_text/img/CA.png
similarity index 100%
rename from gym/envs/toy_text/img/CA.png
rename to gymnasium/envs/toy_text/img/CA.png
diff --git a/gym/envs/toy_text/img/CJ.png b/gymnasium/envs/toy_text/img/CJ.png
similarity index 100%
rename from gym/envs/toy_text/img/CJ.png
rename to gymnasium/envs/toy_text/img/CJ.png
diff --git a/gym/envs/toy_text/img/CK.png b/gymnasium/envs/toy_text/img/CK.png
similarity index 100%
rename from gym/envs/toy_text/img/CK.png
rename to gymnasium/envs/toy_text/img/CK.png
diff --git a/gym/envs/toy_text/img/CQ.png b/gymnasium/envs/toy_text/img/CQ.png
similarity index 100%
rename from gym/envs/toy_text/img/CQ.png
rename to gymnasium/envs/toy_text/img/CQ.png
diff --git a/gym/envs/toy_text/img/CT.png b/gymnasium/envs/toy_text/img/CT.png
similarity index 100%
rename from gym/envs/toy_text/img/CT.png
rename to gymnasium/envs/toy_text/img/CT.png
diff --git a/gym/envs/toy_text/img/Card.png b/gymnasium/envs/toy_text/img/Card.png
similarity index 100%
rename from gym/envs/toy_text/img/Card.png
rename to gymnasium/envs/toy_text/img/Card.png
diff --git a/gym/envs/toy_text/img/D2.png b/gymnasium/envs/toy_text/img/D2.png
similarity index 100%
rename from gym/envs/toy_text/img/D2.png
rename to gymnasium/envs/toy_text/img/D2.png
diff --git a/gym/envs/toy_text/img/D3.png b/gymnasium/envs/toy_text/img/D3.png
similarity index 100%
rename from gym/envs/toy_text/img/D3.png
rename to gymnasium/envs/toy_text/img/D3.png
diff --git a/gym/envs/toy_text/img/D4.png b/gymnasium/envs/toy_text/img/D4.png
similarity index 100%
rename from gym/envs/toy_text/img/D4.png
rename to gymnasium/envs/toy_text/img/D4.png
diff --git a/gym/envs/toy_text/img/D5.png b/gymnasium/envs/toy_text/img/D5.png
similarity index 100%
rename from gym/envs/toy_text/img/D5.png
rename to gymnasium/envs/toy_text/img/D5.png
diff --git a/gym/envs/toy_text/img/D6.png b/gymnasium/envs/toy_text/img/D6.png
similarity index 100%
rename from gym/envs/toy_text/img/D6.png
rename to gymnasium/envs/toy_text/img/D6.png
diff --git a/gym/envs/toy_text/img/D7.png b/gymnasium/envs/toy_text/img/D7.png
similarity index 100%
rename from gym/envs/toy_text/img/D7.png
rename to gymnasium/envs/toy_text/img/D7.png
diff --git a/gym/envs/toy_text/img/D8.png b/gymnasium/envs/toy_text/img/D8.png
similarity index 100%
rename from gym/envs/toy_text/img/D8.png
rename to gymnasium/envs/toy_text/img/D8.png
diff --git a/gym/envs/toy_text/img/D9.png b/gymnasium/envs/toy_text/img/D9.png
similarity index 100%
rename from gym/envs/toy_text/img/D9.png
rename to gymnasium/envs/toy_text/img/D9.png
diff --git a/gym/envs/toy_text/img/DA.png b/gymnasium/envs/toy_text/img/DA.png
similarity index 100%
rename from gym/envs/toy_text/img/DA.png
rename to gymnasium/envs/toy_text/img/DA.png
diff --git a/gym/envs/toy_text/img/DJ.png b/gymnasium/envs/toy_text/img/DJ.png
similarity index 100%
rename from gym/envs/toy_text/img/DJ.png
rename to gymnasium/envs/toy_text/img/DJ.png
diff --git a/gym/envs/toy_text/img/DK.png b/gymnasium/envs/toy_text/img/DK.png
similarity index 100%
rename from gym/envs/toy_text/img/DK.png
rename to gymnasium/envs/toy_text/img/DK.png
diff --git a/gym/envs/toy_text/img/DQ.png b/gymnasium/envs/toy_text/img/DQ.png
similarity index 100%
rename from gym/envs/toy_text/img/DQ.png
rename to gymnasium/envs/toy_text/img/DQ.png
diff --git a/gym/envs/toy_text/img/DT.png b/gymnasium/envs/toy_text/img/DT.png
similarity index 100%
rename from gym/envs/toy_text/img/DT.png
rename to gymnasium/envs/toy_text/img/DT.png
diff --git a/gym/envs/toy_text/img/H2.png b/gymnasium/envs/toy_text/img/H2.png
similarity index 100%
rename from gym/envs/toy_text/img/H2.png
rename to gymnasium/envs/toy_text/img/H2.png
diff --git a/gym/envs/toy_text/img/H3.png b/gymnasium/envs/toy_text/img/H3.png
similarity index 100%
rename from gym/envs/toy_text/img/H3.png
rename to gymnasium/envs/toy_text/img/H3.png
diff --git a/gym/envs/toy_text/img/H4.png b/gymnasium/envs/toy_text/img/H4.png
similarity index 100%
rename from gym/envs/toy_text/img/H4.png
rename to gymnasium/envs/toy_text/img/H4.png
diff --git a/gym/envs/toy_text/img/H5.png b/gymnasium/envs/toy_text/img/H5.png
similarity index 100%
rename from gym/envs/toy_text/img/H5.png
rename to gymnasium/envs/toy_text/img/H5.png
diff --git a/gym/envs/toy_text/img/H6.png b/gymnasium/envs/toy_text/img/H6.png
similarity index 100%
rename from gym/envs/toy_text/img/H6.png
rename to gymnasium/envs/toy_text/img/H6.png
diff --git a/gym/envs/toy_text/img/H7.png b/gymnasium/envs/toy_text/img/H7.png
similarity index 100%
rename from gym/envs/toy_text/img/H7.png
rename to gymnasium/envs/toy_text/img/H7.png
diff --git a/gym/envs/toy_text/img/H8.png b/gymnasium/envs/toy_text/img/H8.png
similarity index 100%
rename from gym/envs/toy_text/img/H8.png
rename to gymnasium/envs/toy_text/img/H8.png
diff --git a/gym/envs/toy_text/img/H9.png b/gymnasium/envs/toy_text/img/H9.png
similarity index 100%
rename from gym/envs/toy_text/img/H9.png
rename to gymnasium/envs/toy_text/img/H9.png
diff --git a/gym/envs/toy_text/img/HA.png b/gymnasium/envs/toy_text/img/HA.png
similarity index 100%
rename from gym/envs/toy_text/img/HA.png
rename to gymnasium/envs/toy_text/img/HA.png
diff --git a/gym/envs/toy_text/img/HJ.png b/gymnasium/envs/toy_text/img/HJ.png
similarity index 100%
rename from gym/envs/toy_text/img/HJ.png
rename to gymnasium/envs/toy_text/img/HJ.png
diff --git a/gym/envs/toy_text/img/HK.png b/gymnasium/envs/toy_text/img/HK.png
similarity index 100%
rename from gym/envs/toy_text/img/HK.png
rename to gymnasium/envs/toy_text/img/HK.png
diff --git a/gym/envs/toy_text/img/HQ.png b/gymnasium/envs/toy_text/img/HQ.png
similarity index 100%
rename from gym/envs/toy_text/img/HQ.png
rename to gymnasium/envs/toy_text/img/HQ.png
diff --git a/gym/envs/toy_text/img/HT.png b/gymnasium/envs/toy_text/img/HT.png
similarity index 100%
rename from gym/envs/toy_text/img/HT.png
rename to gymnasium/envs/toy_text/img/HT.png
diff --git a/gym/envs/toy_text/img/S2.png b/gymnasium/envs/toy_text/img/S2.png
similarity index 100%
rename from gym/envs/toy_text/img/S2.png
rename to gymnasium/envs/toy_text/img/S2.png
diff --git a/gym/envs/toy_text/img/S3.png b/gymnasium/envs/toy_text/img/S3.png
similarity index 100%
rename from gym/envs/toy_text/img/S3.png
rename to gymnasium/envs/toy_text/img/S3.png
diff --git a/gym/envs/toy_text/img/S4.png b/gymnasium/envs/toy_text/img/S4.png
similarity index 100%
rename from gym/envs/toy_text/img/S4.png
rename to gymnasium/envs/toy_text/img/S4.png
diff --git a/gym/envs/toy_text/img/S5.png b/gymnasium/envs/toy_text/img/S5.png
similarity index 100%
rename from gym/envs/toy_text/img/S5.png
rename to gymnasium/envs/toy_text/img/S5.png
diff --git a/gym/envs/toy_text/img/S6.png b/gymnasium/envs/toy_text/img/S6.png
similarity index 100%
rename from gym/envs/toy_text/img/S6.png
rename to gymnasium/envs/toy_text/img/S6.png
diff --git a/gym/envs/toy_text/img/S7.png b/gymnasium/envs/toy_text/img/S7.png
similarity index 100%
rename from gym/envs/toy_text/img/S7.png
rename to gymnasium/envs/toy_text/img/S7.png
diff --git a/gym/envs/toy_text/img/S8.png b/gymnasium/envs/toy_text/img/S8.png
similarity index 100%
rename from gym/envs/toy_text/img/S8.png
rename to gymnasium/envs/toy_text/img/S8.png
diff --git a/gym/envs/toy_text/img/S9.png b/gymnasium/envs/toy_text/img/S9.png
similarity index 100%
rename from gym/envs/toy_text/img/S9.png
rename to gymnasium/envs/toy_text/img/S9.png
diff --git a/gym/envs/toy_text/img/SA.png b/gymnasium/envs/toy_text/img/SA.png
similarity index 100%
rename from gym/envs/toy_text/img/SA.png
rename to gymnasium/envs/toy_text/img/SA.png
diff --git a/gym/envs/toy_text/img/SJ.png b/gymnasium/envs/toy_text/img/SJ.png
similarity index 100%
rename from gym/envs/toy_text/img/SJ.png
rename to gymnasium/envs/toy_text/img/SJ.png
diff --git a/gym/envs/toy_text/img/SK.png b/gymnasium/envs/toy_text/img/SK.png
similarity index 100%
rename from gym/envs/toy_text/img/SK.png
rename to gymnasium/envs/toy_text/img/SK.png
diff --git a/gym/envs/toy_text/img/SQ.png b/gymnasium/envs/toy_text/img/SQ.png
similarity index 100%
rename from gym/envs/toy_text/img/SQ.png
rename to gymnasium/envs/toy_text/img/SQ.png
diff --git a/gym/envs/toy_text/img/ST.png b/gymnasium/envs/toy_text/img/ST.png
similarity index 100%
rename from gym/envs/toy_text/img/ST.png
rename to gymnasium/envs/toy_text/img/ST.png
diff --git a/gym/envs/toy_text/img/cab_front.png b/gymnasium/envs/toy_text/img/cab_front.png
similarity index 100%
rename from gym/envs/toy_text/img/cab_front.png
rename to gymnasium/envs/toy_text/img/cab_front.png
diff --git a/gym/envs/toy_text/img/cab_left.png b/gymnasium/envs/toy_text/img/cab_left.png
similarity index 100%
rename from gym/envs/toy_text/img/cab_left.png
rename to gymnasium/envs/toy_text/img/cab_left.png
diff --git a/gym/envs/toy_text/img/cab_rear.png b/gymnasium/envs/toy_text/img/cab_rear.png
similarity index 100%
rename from gym/envs/toy_text/img/cab_rear.png
rename to gymnasium/envs/toy_text/img/cab_rear.png
diff --git a/gym/envs/toy_text/img/cab_right.png b/gymnasium/envs/toy_text/img/cab_right.png
similarity index 100%
rename from gym/envs/toy_text/img/cab_right.png
rename to gymnasium/envs/toy_text/img/cab_right.png
diff --git a/gym/envs/toy_text/img/cookie.png b/gymnasium/envs/toy_text/img/cookie.png
similarity index 100%
rename from gym/envs/toy_text/img/cookie.png
rename to gymnasium/envs/toy_text/img/cookie.png
diff --git a/gym/envs/toy_text/img/cracked_hole.png b/gymnasium/envs/toy_text/img/cracked_hole.png
similarity index 100%
rename from gym/envs/toy_text/img/cracked_hole.png
rename to gymnasium/envs/toy_text/img/cracked_hole.png
diff --git a/gym/envs/toy_text/img/elf_down.png b/gymnasium/envs/toy_text/img/elf_down.png
similarity index 100%
rename from gym/envs/toy_text/img/elf_down.png
rename to gymnasium/envs/toy_text/img/elf_down.png
diff --git a/gym/envs/toy_text/img/elf_left.png b/gymnasium/envs/toy_text/img/elf_left.png
similarity index 100%
rename from gym/envs/toy_text/img/elf_left.png
rename to gymnasium/envs/toy_text/img/elf_left.png
diff --git a/gym/envs/toy_text/img/elf_right.png b/gymnasium/envs/toy_text/img/elf_right.png
similarity index 100%
rename from gym/envs/toy_text/img/elf_right.png
rename to gymnasium/envs/toy_text/img/elf_right.png
diff --git a/gym/envs/toy_text/img/elf_up.png b/gymnasium/envs/toy_text/img/elf_up.png
similarity index 100%
rename from gym/envs/toy_text/img/elf_up.png
rename to gymnasium/envs/toy_text/img/elf_up.png
diff --git a/gym/envs/toy_text/img/goal.png b/gymnasium/envs/toy_text/img/goal.png
similarity index 100%
rename from gym/envs/toy_text/img/goal.png
rename to gymnasium/envs/toy_text/img/goal.png
diff --git a/gym/envs/toy_text/img/gridworld_median_bottom.png b/gymnasium/envs/toy_text/img/gridworld_median_bottom.png
similarity index 100%
rename from gym/envs/toy_text/img/gridworld_median_bottom.png
rename to gymnasium/envs/toy_text/img/gridworld_median_bottom.png
diff --git a/gym/envs/toy_text/img/gridworld_median_horiz.png b/gymnasium/envs/toy_text/img/gridworld_median_horiz.png
similarity index 100%
rename from gym/envs/toy_text/img/gridworld_median_horiz.png
rename to gymnasium/envs/toy_text/img/gridworld_median_horiz.png
diff --git a/gym/envs/toy_text/img/gridworld_median_left.png b/gymnasium/envs/toy_text/img/gridworld_median_left.png
similarity index 100%
rename from gym/envs/toy_text/img/gridworld_median_left.png
rename to gymnasium/envs/toy_text/img/gridworld_median_left.png
diff --git a/gym/envs/toy_text/img/gridworld_median_right.png b/gymnasium/envs/toy_text/img/gridworld_median_right.png
similarity index 100%
rename from gym/envs/toy_text/img/gridworld_median_right.png
rename to gymnasium/envs/toy_text/img/gridworld_median_right.png
diff --git a/gym/envs/toy_text/img/gridworld_median_top.png b/gymnasium/envs/toy_text/img/gridworld_median_top.png
similarity index 100%
rename from gym/envs/toy_text/img/gridworld_median_top.png
rename to gymnasium/envs/toy_text/img/gridworld_median_top.png
diff --git a/gym/envs/toy_text/img/gridworld_median_vert.png b/gymnasium/envs/toy_text/img/gridworld_median_vert.png
similarity index 100%
rename from gym/envs/toy_text/img/gridworld_median_vert.png
rename to gymnasium/envs/toy_text/img/gridworld_median_vert.png
diff --git a/gym/envs/toy_text/img/hole.png b/gymnasium/envs/toy_text/img/hole.png
similarity index 100%
rename from gym/envs/toy_text/img/hole.png
rename to gymnasium/envs/toy_text/img/hole.png
diff --git a/gym/envs/toy_text/img/hotel.png b/gymnasium/envs/toy_text/img/hotel.png
similarity index 100%
rename from gym/envs/toy_text/img/hotel.png
rename to gymnasium/envs/toy_text/img/hotel.png
diff --git a/gym/envs/toy_text/img/ice.png b/gymnasium/envs/toy_text/img/ice.png
similarity index 100%
rename from gym/envs/toy_text/img/ice.png
rename to gymnasium/envs/toy_text/img/ice.png
diff --git a/gym/envs/toy_text/img/mountain_bg1.png b/gymnasium/envs/toy_text/img/mountain_bg1.png
similarity index 100%
rename from gym/envs/toy_text/img/mountain_bg1.png
rename to gymnasium/envs/toy_text/img/mountain_bg1.png
diff --git a/gym/envs/toy_text/img/mountain_bg2.png b/gymnasium/envs/toy_text/img/mountain_bg2.png
similarity index 100%
rename from gym/envs/toy_text/img/mountain_bg2.png
rename to gymnasium/envs/toy_text/img/mountain_bg2.png
diff --git a/gym/envs/toy_text/img/mountain_cliff.png b/gymnasium/envs/toy_text/img/mountain_cliff.png
similarity index 100%
rename from gym/envs/toy_text/img/mountain_cliff.png
rename to gymnasium/envs/toy_text/img/mountain_cliff.png
diff --git a/gym/envs/toy_text/img/mountain_near-cliff1.png b/gymnasium/envs/toy_text/img/mountain_near-cliff1.png
similarity index 100%
rename from gym/envs/toy_text/img/mountain_near-cliff1.png
rename to gymnasium/envs/toy_text/img/mountain_near-cliff1.png
diff --git a/gym/envs/toy_text/img/mountain_near-cliff2.png b/gymnasium/envs/toy_text/img/mountain_near-cliff2.png
similarity index 100%
rename from gym/envs/toy_text/img/mountain_near-cliff2.png
rename to gymnasium/envs/toy_text/img/mountain_near-cliff2.png
diff --git a/gym/envs/toy_text/img/passenger.png b/gymnasium/envs/toy_text/img/passenger.png
similarity index 100%
rename from gym/envs/toy_text/img/passenger.png
rename to gymnasium/envs/toy_text/img/passenger.png
diff --git a/gym/envs/toy_text/img/stool.png b/gymnasium/envs/toy_text/img/stool.png
similarity index 100%
rename from gym/envs/toy_text/img/stool.png
rename to gymnasium/envs/toy_text/img/stool.png
diff --git a/gym/envs/toy_text/img/taxi_background.png b/gymnasium/envs/toy_text/img/taxi_background.png
similarity index 100%
rename from gym/envs/toy_text/img/taxi_background.png
rename to gymnasium/envs/toy_text/img/taxi_background.png
diff --git a/gym/envs/toy_text/taxi.py b/gymnasium/envs/toy_text/taxi.py
similarity index 98%
rename from gym/envs/toy_text/taxi.py
rename to gymnasium/envs/toy_text/taxi.py
index d9b9a8170..a0a789112 100644
--- a/gym/envs/toy_text/taxi.py
+++ b/gymnasium/envs/toy_text/taxi.py
@@ -5,9 +5,9 @@
import numpy as np
-from gym import Env, spaces, utils
-from gym.envs.toy_text.utils import categorical_sample
-from gym.error import DependencyNotInstalled
+from gymnasium import Env, spaces, utils
+from gymnasium.envs.toy_text.utils import categorical_sample
+from gymnasium.error import DependencyNotInstalled
MAP = [
"+---------+",
@@ -110,7 +110,7 @@ class TaxiEnv(Env):
### Arguments
```
- gym.make('Taxi-v3')
+ gymnasium.make('Taxi-v3')
```
### Version History
@@ -288,7 +288,7 @@ def _render_gui(self, mode):
import pygame # dependency to pygame only if rendering with human
except ImportError:
raise DependencyNotInstalled(
- "pygame is not installed, run `pip install gym[toy_text]`"
+ "pygame is not installed, run `pip install gymnasium[toy_text]`"
)
if self.window is None:
diff --git a/gym/envs/toy_text/utils.py b/gymnasium/envs/toy_text/utils.py
similarity index 100%
rename from gym/envs/toy_text/utils.py
rename to gymnasium/envs/toy_text/utils.py
diff --git a/gym/error.py b/gymnasium/error.py
similarity index 91%
rename from gym/error.py
rename to gymnasium/error.py
index 9a9b88998..e80282ed8 100644
--- a/gym/error.py
+++ b/gymnasium/error.py
@@ -1,4 +1,4 @@
-"""Set of Error classes for gym."""
+"""Set of Error classes for gymnasium."""
import warnings
@@ -69,7 +69,7 @@ class InvalidAction(Error):
class APIError(Error):
- """Deprecated, to be removed at gym 1.0."""
+ """Deprecated, to be removed at gymnasium 1.0."""
def __init__(
self,
@@ -82,7 +82,7 @@ def __init__(
"""Initialise API error."""
super().__init__(message)
- warnings.warn("APIError is deprecated and will be removed at gym 1.0")
+ warnings.warn("APIError is deprecated and will be removed at gymnasium 1.0")
if http_body and hasattr(http_body, "decode"):
try:
@@ -111,11 +111,11 @@ def __str__(self):
class APIConnectionError(APIError):
- """Deprecated, to be removed at gym 1.0."""
+ """Deprecated, to be removed at gymnasium 1.0."""
class InvalidRequestError(APIError):
- """Deprecated, to be removed at gym 1.0."""
+ """Deprecated, to be removed at gymnasium 1.0."""
def __init__(
self,
@@ -132,11 +132,11 @@ def __init__(
class AuthenticationError(APIError):
- """Deprecated, to be removed at gym 1.0."""
+ """Deprecated, to be removed at gymnasium 1.0."""
class RateLimitError(APIError):
- """Deprecated, to be removed at gym 1.0."""
+ """Deprecated, to be removed at gymnasium 1.0."""
# Video errors
@@ -191,4 +191,4 @@ class ClosedEnvironmentError(Exception):
class CustomSpaceError(Exception):
- """The space is a custom gym.Space instance, and is not supported by `AsyncVectorEnv` with `shared_memory=True`."""
+ """The space is a custom gymnasium.Space instance, and is not supported by `AsyncVectorEnv` with `shared_memory=True`."""
diff --git a/gym/logger.py b/gymnasium/logger.py
similarity index 97%
rename from gym/logger.py
rename to gymnasium/logger.py
index 349e5756c..0bfb6dd15 100644
--- a/gym/logger.py
+++ b/gymnasium/logger.py
@@ -3,7 +3,7 @@
import warnings
from typing import Optional, Type
-from gym.utils import colorize
+from gymnasium.utils import colorize
DEBUG = 10
INFO = 20
@@ -15,7 +15,7 @@
# Ensure DeprecationWarning to be displayed (#2685, #3059)
-warnings.filterwarnings("once", "", DeprecationWarning, module=r"^gym\.")
+warnings.filterwarnings("once", "", DeprecationWarning, module=r"^gymnasium\.")
def set_level(level: int):
diff --git a/gym/py.typed b/gymnasium/py.typed
similarity index 100%
rename from gym/py.typed
rename to gymnasium/py.typed
diff --git a/gym/spaces/__init__.py b/gymnasium/spaces/__init__.py
similarity index 59%
rename from gym/spaces/__init__.py
rename to gymnasium/spaces/__init__.py
index 0f6f4923c..2ef5af6c0 100644
--- a/gym/spaces/__init__.py
+++ b/gymnasium/spaces/__init__.py
@@ -8,17 +8,17 @@
self.action_space = spaces.Discrete(3)
self.observation_space = spaces.Box(0, 1, shape=(2,))
"""
-from gym.spaces.box import Box
-from gym.spaces.dict import Dict
-from gym.spaces.discrete import Discrete
-from gym.spaces.graph import Graph, GraphInstance
-from gym.spaces.multi_binary import MultiBinary
-from gym.spaces.multi_discrete import MultiDiscrete
-from gym.spaces.sequence import Sequence
-from gym.spaces.space import Space
-from gym.spaces.text import Text
-from gym.spaces.tuple import Tuple
-from gym.spaces.utils import flatdim, flatten, flatten_space, unflatten
+from gymnasium.spaces.box import Box
+from gymnasium.spaces.dict import Dict
+from gymnasium.spaces.discrete import Discrete
+from gymnasium.spaces.graph import Graph, GraphInstance
+from gymnasium.spaces.multi_binary import MultiBinary
+from gymnasium.spaces.multi_discrete import MultiDiscrete
+from gymnasium.spaces.sequence import Sequence
+from gymnasium.spaces.space import Space
+from gymnasium.spaces.text import Text
+from gymnasium.spaces.tuple import Tuple
+from gymnasium.spaces.utils import flatdim, flatten, flatten_space, unflatten
__all__ = [
"Space",
diff --git a/gym/spaces/box.py b/gymnasium/spaces/box.py
similarity index 98%
rename from gym/spaces/box.py
rename to gymnasium/spaces/box.py
index f09cbcf18..0802f83b6 100644
--- a/gym/spaces/box.py
+++ b/gymnasium/spaces/box.py
@@ -3,9 +3,9 @@
import numpy as np
-import gym.error
-from gym import logger
-from gym.spaces.space import Space
+import gymnasium.error
+from gymnasium import logger
+from gymnasium.spaces.space import Space
def _short_repr(arr: np.ndarray) -> str:
@@ -135,7 +135,7 @@ def __init__(
@property
def shape(self) -> Tuple[int, ...]:
- """Has stricter type than gym.Space - never None."""
+ """Has stricter type than gymnasium.Space - never None."""
return self._shape
@property
@@ -186,7 +186,7 @@ def sample(self, mask: None = None) -> np.ndarray:
A sampled value from the Box
"""
if mask is not None:
- raise gym.error.Error(
+ raise gymnasium.error.Error(
f"Box.sample cannot be provided a mask, actual value: {mask}"
)
diff --git a/gym/spaces/dict.py b/gymnasium/spaces/dict.py
similarity index 97%
rename from gym/spaces/dict.py
rename to gymnasium/spaces/dict.py
index 280986fcf..7d7f5f97d 100644
--- a/gym/spaces/dict.py
+++ b/gymnasium/spaces/dict.py
@@ -9,7 +9,7 @@
import numpy as np
-from gym.spaces.space import Space
+from gymnasium.spaces.space import Space
class Dict(Space[TypingDict[str, Space]], Mapping):
@@ -19,14 +19,14 @@ class Dict(Space[TypingDict[str, Space]], Mapping):
Example usage:
- >>> from gym.spaces import Dict, Discrete
+ >>> from gymnasium.spaces import Dict, Discrete
>>> observation_space = Dict({"position": Discrete(2), "velocity": Discrete(3)})
>>> observation_space.sample()
OrderedDict([('position', 1), ('velocity', 2)])
Example usage [nested]::
- >>> from gym.spaces import Box, Dict, Discrete, MultiBinary, MultiDiscrete
+ >>> from gymnasium.spaces import Box, Dict, Discrete, MultiBinary, MultiDiscrete
>>> Dict(
... {
... "ext_controller": MultiDiscrete([5, 2, 2]),
@@ -70,7 +70,7 @@ def __init__(
Example::
- >>> from gym.spaces import Box, Discrete
+ >>> from gymnasium.spaces import Box, Discrete
>>> Dict({"position": Box(-1, 1, shape=(2,)), "color": Discrete(3)})
Dict(color:Discrete(3), position:Box(-1.0, 1.0, (2,), float32))
>>> Dict(position=Box(-1, 1, shape=(2,)), color=Discrete(3))
@@ -197,7 +197,7 @@ def __setitem__(self, key: str, value: Space):
"""Set the space that is associated to `key`."""
assert isinstance(
value, Space
- ), f"Trying to set {key} to Dict space with value that is not a gym space, actual type: {type(value)}"
+ ), f"Trying to set {key} to Dict space with value that is not a gymnasium space, actual type: {type(value)}"
self.spaces[key] = value
def __iter__(self):
diff --git a/gym/spaces/discrete.py b/gymnasium/spaces/discrete.py
similarity index 99%
rename from gym/spaces/discrete.py
rename to gymnasium/spaces/discrete.py
index 5d5e1c14a..19cdfbcf8 100644
--- a/gym/spaces/discrete.py
+++ b/gymnasium/spaces/discrete.py
@@ -3,7 +3,7 @@
import numpy as np
-from gym.spaces.space import Space
+from gymnasium.spaces.space import Space
class Discrete(Space[int]):
diff --git a/gym/spaces/graph.py b/gymnasium/spaces/graph.py
similarity index 97%
rename from gym/spaces/graph.py
rename to gymnasium/spaces/graph.py
index 2f393c2c4..c1e0aaa57 100644
--- a/gym/spaces/graph.py
+++ b/gymnasium/spaces/graph.py
@@ -3,11 +3,11 @@
import numpy as np
-from gym.logger import warn
-from gym.spaces.box import Box
-from gym.spaces.discrete import Discrete
-from gym.spaces.multi_discrete import MultiDiscrete
-from gym.spaces.space import Space
+from gymnasium.logger import warn
+from gymnasium.spaces.box import Box
+from gymnasium.spaces.discrete import Discrete
+from gymnasium.spaces.multi_discrete import MultiDiscrete
+from gymnasium.spaces.space import Space
class GraphInstance(NamedTuple):
diff --git a/gym/spaces/multi_binary.py b/gymnasium/spaces/multi_binary.py
similarity index 97%
rename from gym/spaces/multi_binary.py
rename to gymnasium/spaces/multi_binary.py
index 0c384fb48..cbb448455 100644
--- a/gym/spaces/multi_binary.py
+++ b/gymnasium/spaces/multi_binary.py
@@ -3,7 +3,7 @@
import numpy as np
-from gym.spaces.space import Space
+from gymnasium.spaces.space import Space
class MultiBinary(Space[np.ndarray]):
@@ -47,7 +47,7 @@ def __init__(
@property
def shape(self) -> Tuple[int, ...]:
- """Has stricter type than gym.Space - never None."""
+ """Has stricter type than gymnasium.Space - never None."""
return self._shape # type: ignore
@property
diff --git a/gym/spaces/multi_discrete.py b/gymnasium/spaces/multi_discrete.py
similarity index 97%
rename from gym/spaces/multi_discrete.py
rename to gymnasium/spaces/multi_discrete.py
index 5349865e4..3f5b60d15 100644
--- a/gym/spaces/multi_discrete.py
+++ b/gymnasium/spaces/multi_discrete.py
@@ -3,9 +3,9 @@
import numpy as np
-from gym import logger
-from gym.spaces.discrete import Discrete
-from gym.spaces.space import Space
+from gymnasium import logger
+from gymnasium.spaces.discrete import Discrete
+from gymnasium.spaces.space import Space
class MultiDiscrete(Space[np.ndarray]):
@@ -58,7 +58,7 @@ def __init__(
@property
def shape(self) -> Tuple[int, ...]:
- """Has stricter type than :class:`gym.Space` - never None."""
+ """Has stricter type than :class:`gymnasium.Space` - never None."""
return self._shape # type: ignore
@property
diff --git a/gym/spaces/sequence.py b/gymnasium/spaces/sequence.py
similarity index 98%
rename from gym/spaces/sequence.py
rename to gymnasium/spaces/sequence.py
index 62ccf8b27..ea7f39d4d 100644
--- a/gym/spaces/sequence.py
+++ b/gymnasium/spaces/sequence.py
@@ -4,8 +4,8 @@
import numpy as np
-import gym
-from gym.spaces.space import Space
+import gymnasium
+from gymnasium.spaces.space import Space
class Sequence(Space[Tuple]):
@@ -34,7 +34,7 @@ def __init__(
seed: Optionally, you can use this argument to seed the RNG that is used to sample from the space.
"""
assert isinstance(
- space, gym.Space
+ space, gymnasium.Space
), f"Expects the feature space to be instance of a gym Space, actual type: {type(space)}"
self.feature_space = space
super().__init__(
diff --git a/gym/spaces/space.py b/gymnasium/spaces/space.py
similarity index 98%
rename from gym/spaces/space.py
rename to gymnasium/spaces/space.py
index 753ab6e31..2c073dbdc 100644
--- a/gym/spaces/space.py
+++ b/gymnasium/spaces/space.py
@@ -16,7 +16,7 @@
import numpy as np
-from gym.utils import seeding
+from gymnasium.utils import seeding
T_cov = TypeVar("T_cov", covariant=True)
@@ -41,8 +41,8 @@ class Space(Generic[T_cov]):
class. However, most use-cases should be covered by the existing space
classes (e.g. :class:`Box`, :class:`Discrete`, etc...), and container classes (:class`Tuple` &
:class:`Dict`). Note that parametrized probability distributions (through the
- :meth:`Space.sample()` method), and batching functions (in :class:`gym.vector.VectorEnv`), are
- only well-defined for instances of spaces provided in gym by default.
+ :meth:`Space.sample()` method), and batching functions (in :class:`gymnasium.vector.VectorEnv`), are
+ only well-defined for instances of spaces provided in gymnasium by default.
Moreover, some implementations of Reinforcement Learning algorithms might
not handle custom spaces properly. Use custom spaces with care.
"""
diff --git a/gym/spaces/text.py b/gymnasium/spaces/text.py
similarity index 99%
rename from gym/spaces/text.py
rename to gymnasium/spaces/text.py
index 1ac184e46..add2abc42 100644
--- a/gym/spaces/text.py
+++ b/gymnasium/spaces/text.py
@@ -3,7 +3,7 @@
import numpy as np
-from gym.spaces.space import Space
+from gymnasium.spaces.space import Space
alphanumeric: FrozenSet[str] = frozenset(
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
diff --git a/gym/spaces/tuple.py b/gymnasium/spaces/tuple.py
similarity index 97%
rename from gym/spaces/tuple.py
rename to gymnasium/spaces/tuple.py
index e37f8cda1..2971ebb61 100644
--- a/gym/spaces/tuple.py
+++ b/gymnasium/spaces/tuple.py
@@ -7,7 +7,7 @@
import numpy as np
-from gym.spaces.space import Space
+from gymnasium.spaces.space import Space
class Tuple(Space[tuple], CollectionSequence):
@@ -17,7 +17,7 @@ class Tuple(Space[tuple], CollectionSequence):
Example usage::
- >>> from gym.spaces import Box, Discrete
+ >>> from gymnasium.spaces import Box, Discrete
>>> observation_space = Tuple((Discrete(2), Box(-1, 1, shape=(2,))))
>>> observation_space.sample()
(0, array([0.03633198, 0.42370757], dtype=float32))
@@ -40,7 +40,7 @@ def __init__(
for space in self.spaces:
assert isinstance(
space, Space
- ), "Elements of the tuple must be instances of gym.Space"
+ ), "Elements of the tuple must be instances of gymnasium.Space"
super().__init__(None, None, seed) # type: ignore
@property
diff --git a/gym/spaces/utils.py b/gymnasium/spaces/utils.py
similarity index 99%
rename from gym/spaces/utils.py
rename to gymnasium/spaces/utils.py
index 818292151..c44d63d4f 100644
--- a/gym/spaces/utils.py
+++ b/gymnasium/spaces/utils.py
@@ -11,7 +11,7 @@
import numpy as np
-from gym.spaces import (
+from gymnasium.spaces import (
Box,
Dict,
Discrete,
@@ -32,7 +32,7 @@ def flatdim(space: Space) -> int:
Example usage::
- >>> from gym.spaces import Discrete
+ >>> from gymnasium.spaces import Discrete
>>> space = Dict({"position": Discrete(2), "velocity": Discrete(3)})
>>> flatdim(space)
5
@@ -130,7 +130,7 @@ def flatten(space: Space[T], x: T) -> FlatType:
- None
Raises:
- NotImplementedError: If the space is not defined in ``gym.spaces``.
+ NotImplementedError: If the space is not defined in ``gymnasium.spaces``.
"""
raise NotImplementedError(f"Unknown space: `{space}`")
@@ -229,7 +229,7 @@ def unflatten(space: Space[T], x: FlatType) -> T:
A point with a structure that matches the space.
Raises:
- NotImplementedError: if the space is not defined in ``gym.spaces``.
+ NotImplementedError: if the space is not defined in ``gymnasium.spaces``.
"""
raise NotImplementedError(f"Unknown space: `{space}`")
@@ -383,7 +383,7 @@ def flatten_space(space: Space) -> Union[Dict, Sequence, Tuple, Graph]:
A flattened Box
Raises:
- NotImplementedError: if the space is not defined in ``gym.spaces``.
+ NotImplementedError: if the space is not defined in ``gymnasium.spaces``.
"""
raise NotImplementedError(f"Unknown space: `{space}`")
diff --git a/gym/utils/__init__.py b/gymnasium/utils/__init__.py
similarity index 78%
rename from gym/utils/__init__.py
rename to gymnasium/utils/__init__.py
index 6258a576a..b97d9cb2c 100644
--- a/gym/utils/__init__.py
+++ b/gymnasium/utils/__init__.py
@@ -6,5 +6,5 @@
# These submodules should not have any import-time dependencies.
# We want this since we use `utils` during our import-time sanity checks
# that verify that our dependencies are actually present.
-from gym.utils.colorize import colorize
-from gym.utils.ezpickle import EzPickle
+from gymnasium.utils.colorize import colorize
+from gymnasium.utils.ezpickle import EzPickle
diff --git a/gym/utils/colorize.py b/gymnasium/utils/colorize.py
similarity index 100%
rename from gym/utils/colorize.py
rename to gymnasium/utils/colorize.py
diff --git a/gym/utils/env_checker.py b/gymnasium/utils/env_checker.py
similarity index 93%
rename from gym/utils/env_checker.py
rename to gymnasium/utils/env_checker.py
index 0e34ad5b9..5cef06b97 100644
--- a/gym/utils/env_checker.py
+++ b/gymnasium/utils/env_checker.py
@@ -19,9 +19,9 @@
import numpy as np
-import gym
-from gym import logger, spaces
-from gym.utils.passive_env_checker import (
+import gymnasium
+from gymnasium import logger, spaces
+from gymnasium.utils.passive_env_checker import (
check_action_space,
check_observation_space,
env_render_passive_checker,
@@ -59,7 +59,7 @@ def data_equivalence(data_1, data_2) -> bool:
return False
-def check_reset_seed(env: gym.Env):
+def check_reset_seed(env: gymnasium.Env):
"""Check that the environment can be reset with a seed.
Args:
@@ -123,12 +123,12 @@ def check_reset_seed(env: gym.Env):
f"Actual default: {seed_param.default}"
)
else:
- raise gym.error.Error(
+ raise gymnasium.error.Error(
"The `reset` method does not provide a `seed` or `**kwargs` keyword argument."
)
-def check_reset_options(env: gym.Env):
+def check_reset_options(env: gymnasium.Env):
"""Check that the environment can be reset with options.
Args:
@@ -151,12 +151,12 @@ def check_reset_options(env: gym.Env):
f"This should never happen, please report this issue. The error was: {e}"
)
else:
- raise gym.error.Error(
+ raise gymnasium.error.Error(
"The `reset` method does not provide an `options` or `**kwargs` keyword argument."
)
-def check_reset_return_info_deprecation(env: gym.Env):
+def check_reset_return_info_deprecation(env: gymnasium.Env):
"""Makes sure support for deprecated `return_info` argument is dropped.
Args:
@@ -173,7 +173,7 @@ def check_reset_return_info_deprecation(env: gym.Env):
)
-def check_seed_deprecation(env: gym.Env):
+def check_seed_deprecation(env: gymnasium.Env):
"""Makes sure support for deprecated function `seed` is dropped.
Args:
@@ -185,11 +185,11 @@ def check_seed_deprecation(env: gym.Env):
if callable(seed_fn):
logger.warn(
"Official support for the `seed` function is dropped. "
- "Standard practice is to reset gym environments using `env.reset(seed=)`"
+ "Standard practice is to reset gymnasium environments using `env.reset(seed=)`"
)
-def check_reset_return_type(env: gym.Env):
+def check_reset_return_type(env: gymnasium.Env):
"""Checks that :meth:`reset` correctly returns a tuple of the form `(obs , info)`.
Args:
@@ -252,7 +252,7 @@ def check_space_limit(space, space_type: str):
check_space_limit(subspace, space_type)
-def check_env(env: gym.Env, warn: bool = None, skip_render_check: bool = False):
+def check_env(env: gymnasium.Env, warn: bool = None, skip_render_check: bool = False):
"""Check that an environment follows Gym API.
This is an invasive function that calls the environment's reset and step.
@@ -270,8 +270,8 @@ def check_env(env: gym.Env, warn: bool = None, skip_render_check: bool = False):
logger.warn("`check_env(warn=...)` parameter is now ignored.")
assert isinstance(
- env, gym.Env
- ), "The environment must inherit from the gym.Env class. See https://www.gymlibrary.dev/content/environment_creation/ for more info."
+ env, gymnasium.Env
+ ), "The environment must inherit from the gymnasium.Env class. See https://www.gymlibrary.dev/content/environment_creation/ for more info."
if env.unwrapped is not env:
logger.warn(
diff --git a/gym/utils/ezpickle.py b/gymnasium/utils/ezpickle.py
similarity index 100%
rename from gym/utils/ezpickle.py
rename to gymnasium/utils/ezpickle.py
diff --git a/gym/utils/passive_env_checker.py b/gymnasium/utils/passive_env_checker.py
similarity index 96%
rename from gym/utils/passive_env_checker.py
rename to gymnasium/utils/passive_env_checker.py
index bd826510f..80ac122d8 100644
--- a/gym/utils/passive_env_checker.py
+++ b/gymnasium/utils/passive_env_checker.py
@@ -5,7 +5,7 @@
import numpy as np
-from gym import Space, error, logger, spaces
+from gymnasium import Space, error, logger, spaces
def _check_box_observation_space(observation_space: spaces.Box):
@@ -72,7 +72,7 @@ def check_space(
"""A passive check of the environment action space that should not affect the environment."""
if not isinstance(space, spaces.Space):
raise AssertionError(
- f"{space_type} space does not inherit from `gym.spaces.Space`, actual type: {type(space)}"
+ f"{space_type} space does not inherit from `gymnasium.spaces.Space`, actual type: {type(space)}"
)
elif isinstance(space, spaces.Box):
@@ -172,7 +172,7 @@ def env_reset_passive_checker(env, **kwargs):
signature = inspect.signature(env.reset)
if "seed" not in signature.parameters and "kwargs" not in signature.parameters:
logger.warn(
- "Future gym versions will require that `Env.reset` can be passed a `seed` instead of using `Env.seed` for resetting the environment random number generator."
+ "Future gymnasium versions will require that `Env.reset` can be passed a `seed` instead of using `Env.seed` for resetting the environment random number generator."
)
else:
seed_param = signature.parameters.get("seed")
@@ -185,7 +185,7 @@ def env_reset_passive_checker(env, **kwargs):
if "options" not in signature.parameters and "kwargs" not in signature.parameters:
logger.warn(
- "Future gym versions will require that `Env.reset` can be passed `options` to allow the environment initialisation to be passed additional information."
+ "Future gymnasium versions will require that `Env.reset` can be passed `options` to allow the environment initialisation to be passed additional information."
)
# Checks the result of env.reset with kwargs
diff --git a/gym/utils/play.py b/gymnasium/utils/play.py
similarity index 95%
rename from gym/utils/play.py
rename to gymnasium/utils/play.py
index 796c2e408..8ae652be6 100644
--- a/gym/utils/play.py
+++ b/gymnasium/utils/play.py
@@ -4,11 +4,11 @@
import numpy as np
-import gym.error
-from gym import Env, logger
-from gym.core import ActType, ObsType
-from gym.error import DependencyNotInstalled
-from gym.logger import deprecation
+import gymnasium.error
+from gymnasium import Env, logger
+from gymnasium.core import ActType, ObsType
+from gymnasium.error import DependencyNotInstalled
+from gymnasium.logger import deprecation
try:
import pygame
@@ -16,8 +16,8 @@
from pygame.event import Event
from pygame.locals import VIDEORESIZE
except ImportError:
- raise gym.error.DependencyNotInstalled(
- "Pygame is not installed, run `pip install gym[classic_control]`"
+ raise gymnasium.error.DependencyNotInstalled(
+ "Pygame is not installed, run `pip install gymnasium[classic_control]`"
)
try:
@@ -26,7 +26,7 @@
matplotlib.use("TkAgg")
import matplotlib.pyplot as plt
except ImportError:
- logger.warn("Matplotlib is not installed, run `pip install gym[other]`")
+ logger.warn("Matplotlib is not installed, run `pip install gymnasium[other]`")
matplotlib, plt = None, None
@@ -148,9 +148,9 @@ def play(
Example::
- >>> import gym
- >>> from gym.utils.play import play
- >>> play(gym.make("CarRacing-v1", render_mode="rgb_array"), keys_to_action={
+ >>> import gymnasium
+ >>> from gymnasium.utils.play import play
+ >>> play(gymnasium.make("CarRacing-v1", render_mode="rgb_array"), keys_to_action={
... "w": np.array([0, 0.7, 0]),
... "a": np.array([-1, 0, 0]),
... "s": np.array([0, 0, 1]),
@@ -173,7 +173,7 @@ def play(
>>> def callback(obs_t, obs_tp1, action, rew, terminated, truncated, info):
... return [rew,]
>>> plotter = PlayPlot(callback, 150, ["reward"])
- >>> play(gym.make("ALE/AirRaid-v5"), callback=plotter.callback)
+ >>> play(gymnasium.make("ALE/AirRaid-v5"), callback=plotter.callback)
Args:
@@ -328,7 +328,7 @@ def __init__(
if plt is None:
raise DependencyNotInstalled(
- "matplotlib is not installed, run `pip install gym[other]`"
+ "matplotlib is not installed, run `pip install gymnasium[other]`"
)
num_plots = len(self.plot_names)
@@ -381,6 +381,6 @@ def callback(
if plt is None:
raise DependencyNotInstalled(
- "matplotlib is not installed, run `pip install gym[other]`"
+ "matplotlib is not installed, run `pip install gymnasium[other]`"
)
plt.pause(0.000001)
diff --git a/gym/utils/save_video.py b/gymnasium/utils/save_video.py
similarity index 93%
rename from gym/utils/save_video.py
rename to gymnasium/utils/save_video.py
index f134e6e17..9b225d0a2 100644
--- a/gym/utils/save_video.py
+++ b/gymnasium/utils/save_video.py
@@ -2,13 +2,13 @@
import os
from typing import Callable, Optional
-import gym
-from gym import logger
+import gymnasium
+from gymnasium import logger
try:
from moviepy.video.io.ImageSequenceClip import ImageSequenceClip
except ImportError:
- raise gym.error.DependencyNotInstalled(
+ raise gymnasium.error.DependencyNotInstalled(
"MoviePy is not installed, run `pip install moviepy`"
)
@@ -59,9 +59,9 @@ def save_video(
You need to specify either fps or duration.
Example:
- >>> import gym
- >>> from gym.utils.save_video import save_video
- >>> env = gym.make("FrozenLake-v1", render_mode="rgb_array_list")
+ >>> import gymnasium
+ >>> from gymnasium.utils.save_video import save_video
+ >>> env = gymnasium.make("FrozenLake-v1", render_mode="rgb_array_list")
>>> env.reset()
>>> step_starting_index = 0
>>> episode_index = 0
diff --git a/gym/utils/seeding.py b/gymnasium/utils/seeding.py
similarity index 96%
rename from gym/utils/seeding.py
rename to gymnasium/utils/seeding.py
index a5ecafbe9..63bab4d72 100644
--- a/gym/utils/seeding.py
+++ b/gymnasium/utils/seeding.py
@@ -3,7 +3,7 @@
import numpy as np
-from gym import error
+from gymnasium import error
def np_random(seed: Optional[int] = None) -> Tuple[np.random.Generator, Any]:
diff --git a/gym/utils/step_api_compatibility.py b/gymnasium/utils/step_api_compatibility.py
similarity index 99%
rename from gym/utils/step_api_compatibility.py
rename to gymnasium/utils/step_api_compatibility.py
index 2ac2f9b23..e54b5a151 100644
--- a/gym/utils/step_api_compatibility.py
+++ b/gymnasium/utils/step_api_compatibility.py
@@ -3,7 +3,7 @@
import numpy as np
-from gym.core import ObsType
+from gymnasium.core import ObsType
DoneStepType = Tuple[
Union[ObsType, np.ndarray],
diff --git a/gym/vector/__init__.py b/gymnasium/vector/__init__.py
similarity index 88%
rename from gym/vector/__init__.py
rename to gymnasium/vector/__init__.py
index 1eb9653f2..160fa6a65 100644
--- a/gym/vector/__init__.py
+++ b/gymnasium/vector/__init__.py
@@ -1,10 +1,10 @@
"""Module for vector environments."""
from typing import Iterable, List, Optional, Union
-import gym
-from gym.vector.async_vector_env import AsyncVectorEnv
-from gym.vector.sync_vector_env import SyncVectorEnv
-from gym.vector.vector_env import VectorEnv, VectorEnvWrapper
+import gymnasium
+from gymnasium.vector.async_vector_env import AsyncVectorEnv
+from gymnasium.vector.sync_vector_env import SyncVectorEnv
+from gymnasium.vector.vector_env import VectorEnv, VectorEnvWrapper
__all__ = ["AsyncVectorEnv", "SyncVectorEnv", "VectorEnv", "VectorEnvWrapper", "make"]
@@ -21,8 +21,8 @@ def make(
Example::
- >>> import gym
- >>> env = gym.vector.make('CartPole-v1', num_envs=3)
+ >>> import gymnasium
+ >>> env = gymnasium.vector.make('CartPole-v1', num_envs=3)
>>> env.reset()
array([[-0.04456399, 0.04653909, 0.01326909, -0.02099827],
[ 0.03073904, 0.00145001, -0.03088818, -0.03131252],
@@ -48,7 +48,7 @@ def create_env(env_num: int):
_disable_env_checker = True if env_num > 0 else disable_env_checker
def _make_env():
- env = gym.envs.registration.make(
+ env = gymnasium.envs.registration.make(
id,
disable_env_checker=_disable_env_checker,
**kwargs,
diff --git a/gym/vector/async_vector_env.py b/gymnasium/vector/async_vector_env.py
similarity index 97%
rename from gym/vector/async_vector_env.py
rename to gymnasium/vector/async_vector_env.py
index a9d89f92e..0c88e96dd 100644
--- a/gym/vector/async_vector_env.py
+++ b/gymnasium/vector/async_vector_env.py
@@ -8,16 +8,16 @@
import numpy as np
-import gym
-from gym import logger
-from gym.core import ObsType
-from gym.error import (
+import gymnasium
+from gymnasium import logger
+from gymnasium.core import ObsType
+from gymnasium.error import (
AlreadyPendingCallError,
ClosedEnvironmentError,
CustomSpaceError,
NoAsyncCallError,
)
-from gym.vector.utils import (
+from gymnasium.vector.utils import (
CloudpickleWrapper,
clear_mpi_env_vars,
concatenate,
@@ -27,7 +27,7 @@
read_from_shared_memory,
write_to_shared_memory,
)
-from gym.vector.vector_env import VectorEnv
+from gymnasium.vector.vector_env import VectorEnv
__all__ = ["AsyncVectorEnv"]
@@ -46,10 +46,10 @@ class AsyncVectorEnv(VectorEnv):
Example::
- >>> import gym
- >>> env = gym.vector.AsyncVectorEnv([
- ... lambda: gym.make("Pendulum-v0", g=9.81),
- ... lambda: gym.make("Pendulum-v0", g=1.62)
+ >>> import gymnasium
+ >>> env = gymnasium.vector.AsyncVectorEnv([
+ ... lambda: gymnasium.make("Pendulum-v0", g=9.81),
+ ... lambda: gymnasium.make("Pendulum-v0", g=1.62)
... ])
>>> env.reset()
array([[-0.8286432 , 0.5597771 , 0.90249056],
@@ -59,8 +59,8 @@ class AsyncVectorEnv(VectorEnv):
def __init__(
self,
env_fns: Sequence[callable],
- observation_space: Optional[gym.Space] = None,
- action_space: Optional[gym.Space] = None,
+ observation_space: Optional[gymnasium.Space] = None,
+ action_space: Optional[gymnasium.Space] = None,
shared_memory: bool = True,
copy: bool = True,
context: Optional[str] = None,
@@ -94,7 +94,7 @@ def __init__(
RuntimeError: If the observation space of some sub-environment does not match observation_space
(or, by default, the observation space of the first sub-environment).
ValueError: If observation_space is a custom space (i.e. not a default space in Gym,
- such as gym.spaces.Box, gym.spaces.Discrete, or gym.spaces.Dict) and shared_memory is True.
+ such as gymnasium.spaces.Box, gymnasium.spaces.Discrete, or gymnasium.spaces.Dict) and shared_memory is True.
"""
ctx = mp.get_context(context)
self.env_fns = env_fns
@@ -126,7 +126,7 @@ def __init__(
raise ValueError(
"Using `shared_memory=True` in `AsyncVectorEnv` "
"is incompatible with non-standard Gym observation spaces "
- "(i.e. custom spaces inheriting from `gym.Space`), and is "
+ "(i.e. custom spaces inheriting from `gymnasium.Space`), and is "
"only compatible with default Gym spaces (e.g. `Box`, "
"`Tuple`, `Dict`) for batching. Set `shared_memory=False` "
"if you use custom observation spaces."
diff --git a/gym/vector/sync_vector_env.py b/gymnasium/vector/sync_vector_env.py
similarity index 95%
rename from gym/vector/sync_vector_env.py
rename to gymnasium/vector/sync_vector_env.py
index 3619fa936..8e2a72664 100644
--- a/gym/vector/sync_vector_env.py
+++ b/gymnasium/vector/sync_vector_env.py
@@ -4,10 +4,10 @@
import numpy as np
-from gym import Env
-from gym.spaces import Space
-from gym.vector.utils import concatenate, create_empty_array, iterate
-from gym.vector.vector_env import VectorEnv
+from gymnasium import Env
+from gymnasium.spaces import Space
+from gymnasium.vector.utils import concatenate, create_empty_array, iterate
+from gymnasium.vector.vector_env import VectorEnv
__all__ = ["SyncVectorEnv"]
@@ -17,10 +17,10 @@ class SyncVectorEnv(VectorEnv):
Example::
- >>> import gym
- >>> env = gym.vector.SyncVectorEnv([
- ... lambda: gym.make("Pendulum-v0", g=9.81),
- ... lambda: gym.make("Pendulum-v0", g=1.62)
+ >>> import gymnasium
+ >>> env = gymnasium.vector.SyncVectorEnv([
+ ... lambda: gymnasium.make("Pendulum-v0", g=9.81),
+ ... lambda: gymnasium.make("Pendulum-v0", g=1.62)
... ])
>>> env.reset()
array([[-0.8286432 , 0.5597771 , 0.90249056],
diff --git a/gymnasium/vector/utils/__init__.py b/gymnasium/vector/utils/__init__.py
new file mode 100644
index 000000000..35394b54d
--- /dev/null
+++ b/gymnasium/vector/utils/__init__.py
@@ -0,0 +1,23 @@
+"""Module for gymnasium vector utils."""
+from gymnasium.vector.utils.misc import CloudpickleWrapper, clear_mpi_env_vars
+from gymnasium.vector.utils.numpy_utils import concatenate, create_empty_array
+from gymnasium.vector.utils.shared_memory import (
+ create_shared_memory,
+ read_from_shared_memory,
+ write_to_shared_memory,
+)
+from gymnasium.vector.utils.spaces import _BaseGymSpaces # pyright: reportPrivateUsage=false
+from gymnasium.vector.utils.spaces import BaseGymSpaces, batch_space, iterate
+
+__all__ = [
+ "CloudpickleWrapper",
+ "clear_mpi_env_vars",
+ "concatenate",
+ "create_empty_array",
+ "create_shared_memory",
+ "read_from_shared_memory",
+ "write_to_shared_memory",
+ "BaseGymSpaces",
+ "batch_space",
+ "iterate",
+]
diff --git a/gym/vector/utils/misc.py b/gymnasium/vector/utils/misc.py
similarity index 100%
rename from gym/vector/utils/misc.py
rename to gymnasium/vector/utils/misc.py
diff --git a/gym/vector/utils/numpy_utils.py b/gymnasium/vector/utils/numpy_utils.py
similarity index 92%
rename from gym/vector/utils/numpy_utils.py
rename to gymnasium/vector/utils/numpy_utils.py
index d596cde86..effcc1650 100644
--- a/gym/vector/utils/numpy_utils.py
+++ b/gymnasium/vector/utils/numpy_utils.py
@@ -5,7 +5,7 @@
import numpy as np
-from gym.spaces import Box, Dict, Discrete, MultiBinary, MultiDiscrete, Space, Tuple
+from gymnasium.spaces import Box, Dict, Discrete, MultiBinary, MultiDiscrete, Space, Tuple
__all__ = ["concatenate", "create_empty_array"]
@@ -18,7 +18,7 @@ def concatenate(
Example::
- >>> from gym.spaces import Box
+ >>> from gymnasium.spaces import Box
>>> space = Box(low=0, high=1, shape=(3,), dtype=np.float32)
>>> out = np.zeros((2, 3), dtype=np.float32)
>>> items = [space.sample() for _ in range(2)]
@@ -38,7 +38,7 @@ def concatenate(
ValueError: Space is not a valid :class:`gym.Space` instance
"""
raise ValueError(
- f"Space of type `{type(space)}` is not a valid `gym.Space` instance."
+ f"Space of type `{type(space)}` is not a valid `gymnasium.Space` instance."
)
@@ -81,7 +81,7 @@ def create_empty_array(
Example::
- >>> from gym.spaces import Box, Dict
+ >>> from gymnasium.spaces import Box, Dict
>>> space = Dict({
... 'position': Box(low=0, high=1, shape=(3,), dtype=np.float32),
... 'velocity': Box(low=0, high=1, shape=(2,), dtype=np.float32)})
@@ -103,7 +103,7 @@ def create_empty_array(
ValueError: Space is not a valid :class:`gym.Space` instance
"""
raise ValueError(
- f"Space of type `{type(space)}` is not a valid `gym.Space` instance."
+ f"Space of type `{type(space)}` is not a valid `gymnasium.Space` instance."
)
diff --git a/gym/vector/utils/shared_memory.py b/gymnasium/vector/utils/shared_memory.py
similarity index 94%
rename from gym/vector/utils/shared_memory.py
rename to gymnasium/vector/utils/shared_memory.py
index 6d664c47e..06e4d0522 100644
--- a/gym/vector/utils/shared_memory.py
+++ b/gymnasium/vector/utils/shared_memory.py
@@ -7,8 +7,8 @@
import numpy as np
-from gym.error import CustomSpaceError
-from gym.spaces import Box, Dict, Discrete, MultiBinary, MultiDiscrete, Space, Tuple
+from gymnasium.error import CustomSpaceError
+from gymnasium.spaces import Box, Dict, Discrete, MultiBinary, MultiDiscrete, Space, Tuple
__all__ = ["create_shared_memory", "read_from_shared_memory", "write_to_shared_memory"]
@@ -30,7 +30,7 @@ def create_shared_memory(
shared_memory for the shared object across processes.
Raises:
- CustomSpaceError: Space is not a valid :class:`gym.Space` instance
+ CustomSpaceError: Space is not a valid :class:`gymnasium.Space` instance
"""
raise CustomSpaceError(
"Cannot create a shared memory for space with "
@@ -90,7 +90,7 @@ def read_from_shared_memory(
Batch of observations as a (possibly nested) numpy array.
Raises:
- CustomSpaceError: Space is not a valid :class:`gym.Space` instance
+ CustomSpaceError: Space is not a valid :class:`gymnasium.Space` instance
"""
raise CustomSpaceError(
"Cannot read from a shared memory for space with "
@@ -146,7 +146,7 @@ def write_to_shared_memory(
This object is created with `create_shared_memory`.
Raises:
- CustomSpaceError: Space is not a valid :class:`gym.Space` instance
+ CustomSpaceError: Space is not a valid :class:`gymnasium.Space` instance
"""
raise CustomSpaceError(
"Cannot write to a shared memory for space with "
diff --git a/gym/vector/utils/spaces.py b/gymnasium/vector/utils/spaces.py
similarity index 92%
rename from gym/vector/utils/spaces.py
rename to gymnasium/vector/utils/spaces.py
index a914423f0..565aaf732 100644
--- a/gym/vector/utils/spaces.py
+++ b/gymnasium/vector/utils/spaces.py
@@ -1,4 +1,4 @@
-"""Utility functions for gym spaces: batch space and iterator."""
+"""Utility functions for gymnasium spaces: batch space and iterator."""
from collections import OrderedDict
from copy import deepcopy
from functools import singledispatch
@@ -6,8 +6,8 @@
import numpy as np
-from gym.error import CustomSpaceError
-from gym.spaces import Box, Dict, Discrete, MultiBinary, MultiDiscrete, Space, Tuple
+from gymnasium.error import CustomSpaceError
+from gymnasium.spaces import Box, Dict, Discrete, MultiBinary, MultiDiscrete, Space, Tuple
BaseGymSpaces = (Box, Discrete, MultiDiscrete, MultiBinary)
_BaseGymSpaces = BaseGymSpaces
@@ -20,7 +20,7 @@ def batch_space(space: Space, n: int = 1) -> Space:
Example::
- >>> from gym.spaces import Box, Dict
+ >>> from gymnasium.spaces import Box, Dict
>>> space = Dict({
... 'position': Box(low=0, high=1, shape=(3,), dtype=np.float32),
... 'velocity': Box(low=0, high=1, shape=(2,), dtype=np.float32)
@@ -39,7 +39,7 @@ def batch_space(space: Space, n: int = 1) -> Space:
ValueError: Cannot batch space that is not a valid :class:`gym.Space` instance
"""
raise ValueError(
- f"Cannot batch space with type `{type(space)}`. The space must be a valid `gym.Space` instance."
+ f"Cannot batch space with type `{type(space)}`. The space must be a valid `gymnasium.Space` instance."
)
@@ -130,7 +130,7 @@ def iterate(space: Space, items) -> Iterator:
Example::
- >>> from gym.spaces import Box, Dict
+ >>> from gymnasium.spaces import Box, Dict
>>> space = Dict({
... 'position': Box(low=0, high=1, shape=(2, 3), dtype=np.float32),
... 'velocity': Box(low=0, high=1, shape=(2, 2), dtype=np.float32)})
@@ -156,7 +156,7 @@ def iterate(space: Space, items) -> Iterator:
ValueError: Space is not an instance of :class:`gym.Space`
"""
raise ValueError(
- f"Space of type `{type(space)}` is not a valid `gym.Space` instance."
+ f"Space of type `{type(space)}` is not a valid `gymnasium.Space` instance."
)
@@ -206,6 +206,6 @@ def _iterate_dict(space, items):
def _iterate_custom(space, items):
raise CustomSpaceError(
f"Unable to iterate over {items}, since {space} "
- "is a custom `gym.Space` instance (i.e. not one of "
+ "is a custom `gymnasium.Space` instance (i.e. not one of "
"`Box`, `Dict`, etc...)."
)
diff --git a/gym/vector/vector_env.py b/gymnasium/vector/vector_env.py
similarity index 98%
rename from gym/vector/vector_env.py
rename to gymnasium/vector/vector_env.py
index 450fa77de..315220594 100644
--- a/gym/vector/vector_env.py
+++ b/gymnasium/vector/vector_env.py
@@ -3,13 +3,13 @@
import numpy as np
-import gym
-from gym.vector.utils.spaces import batch_space
+import gymnasium
+from gymnasium.vector.utils.spaces import batch_space
__all__ = ["VectorEnv"]
-class VectorEnv(gym.Env):
+class VectorEnv(gymnasium.Env):
"""Base class for vectorized environments. Runs multiple independent copies of the same environment in parallel.
This is not the same as 1 environment that has multiple subcomponents, but it is many copies of the same base env.
@@ -25,8 +25,8 @@ class VectorEnv(gym.Env):
def __init__(
self,
num_envs: int,
- observation_space: gym.Space,
- action_space: gym.Space,
+ observation_space: gymnasium.Space,
+ action_space: gymnasium.Space,
):
"""Base class for vectorized environments.
diff --git a/gym/version.py b/gymnasium/version.py
similarity index 100%
rename from gym/version.py
rename to gymnasium/version.py
diff --git a/gym/wrappers/README.md b/gymnasium/wrappers/README.md
similarity index 96%
rename from gym/wrappers/README.md
rename to gymnasium/wrappers/README.md
index d5307a158..6445cada3 100644
--- a/gym/wrappers/README.md
+++ b/gymnasium/wrappers/README.md
@@ -12,7 +12,7 @@ but will keep the wrappers available at the wrappers' top-level
folder. So for example, you should access `MyWrapper` as follows:
```python
-from gym.wrappers import MyWrapper
+from gymnasium.wrappers import MyWrapper
```
## Quick tips for writing your own wrapper
diff --git a/gymnasium/wrappers/__init__.py b/gymnasium/wrappers/__init__.py
new file mode 100644
index 000000000..1ff067f3c
--- /dev/null
+++ b/gymnasium/wrappers/__init__.py
@@ -0,0 +1,23 @@
+"""Module of wrapper classes."""
+from gymnasium import error
+from gymnasium.wrappers.atari_preprocessing import AtariPreprocessing
+from gymnasium.wrappers.autoreset import AutoResetWrapper
+from gymnasium.wrappers.clip_action import ClipAction
+from gymnasium.wrappers.filter_observation import FilterObservation
+from gymnasium.wrappers.flatten_observation import FlattenObservation
+from gymnasium.wrappers.frame_stack import FrameStack, LazyFrames
+from gymnasium.wrappers.gray_scale_observation import GrayScaleObservation
+from gymnasium.wrappers.human_rendering import HumanRendering
+from gymnasium.wrappers.normalize import NormalizeObservation, NormalizeReward
+from gymnasium.wrappers.order_enforcing import OrderEnforcing
+from gymnasium.wrappers.record_episode_statistics import RecordEpisodeStatistics
+from gymnasium.wrappers.record_video import RecordVideo, capped_cubic_video_schedule
+from gymnasium.wrappers.render_collection import RenderCollection
+from gymnasium.wrappers.rescale_action import RescaleAction
+from gymnasium.wrappers.resize_observation import ResizeObservation
+from gymnasium.wrappers.step_api_compatibility import StepAPICompatibility
+from gymnasium.wrappers.time_aware_observation import TimeAwareObservation
+from gymnasium.wrappers.time_limit import TimeLimit
+from gymnasium.wrappers.transform_observation import TransformObservation
+from gymnasium.wrappers.transform_reward import TransformReward
+from gymnasium.wrappers.vector_list_info import VectorListInfo
diff --git a/gym/wrappers/atari_preprocessing.py b/gymnasium/wrappers/atari_preprocessing.py
similarity index 96%
rename from gym/wrappers/atari_preprocessing.py
rename to gymnasium/wrappers/atari_preprocessing.py
index 03a331754..3a2ef3845 100644
--- a/gym/wrappers/atari_preprocessing.py
+++ b/gymnasium/wrappers/atari_preprocessing.py
@@ -1,8 +1,8 @@
"""Implementation of Atari 2600 Preprocessing following the guidelines of Machado et al., 2018."""
import numpy as np
-import gym
-from gym.spaces import Box
+import gymnasium
+from gymnasium.spaces import Box
try:
import cv2
@@ -10,7 +10,7 @@
cv2 = None
-class AtariPreprocessing(gym.Wrapper):
+class AtariPreprocessing(gymnasium.Wrapper):
"""Atari 2600 preprocessing wrapper.
This class follows the guidelines in Machado et al. (2018),
@@ -29,7 +29,7 @@ class AtariPreprocessing(gym.Wrapper):
def __init__(
self,
- env: gym.Env,
+ env: gymnasium.Env,
noop_max: int = 30,
frame_skip: int = 4,
screen_size: int = 84,
@@ -60,8 +60,8 @@ def __init__(
"""
super().__init__(env)
if cv2 is None:
- raise gym.error.DependencyNotInstalled(
- "opencv-python package not installed, run `pip install gym[other]` to get dependencies for atari"
+ raise gymnasium.error.DependencyNotInstalled(
+ "opencv-python package not installed, run `pip install gymnasium[other]` to get dependencies for atari"
)
assert frame_skip > 0
assert screen_size > 0
diff --git a/gym/wrappers/autoreset.py b/gymnasium/wrappers/autoreset.py
similarity index 92%
rename from gym/wrappers/autoreset.py
rename to gymnasium/wrappers/autoreset.py
index 17646abfe..8149d50c3 100644
--- a/gym/wrappers/autoreset.py
+++ b/gymnasium/wrappers/autoreset.py
@@ -1,9 +1,9 @@
"""Wrapper that autoreset environments when `terminated=True` or `truncated=True`."""
-import gym
+import gymnasium
-class AutoResetWrapper(gym.Wrapper):
- """A class for providing an automatic reset functionality for gym environments when calling :meth:`self.step`.
+class AutoResetWrapper(gymnasium.Wrapper):
+ """A class for providing an automatic reset functionality for gymnasium environments when calling :meth:`self.step`.
When calling step causes :meth:`Env.step` to return `terminated=True` or `truncated=True`, :meth:`Env.reset` is called,
and the return format of :meth:`self.step` is as follows: ``(new_obs, final_reward, final_terminated, final_truncated, info)``
@@ -24,8 +24,8 @@ class AutoResetWrapper(gym.Wrapper):
Make sure you know what you're doing if you use this wrapper!
"""
- def __init__(self, env: gym.Env):
- """A class for providing an automatic reset functionality for gym environments when calling :meth:`self.step`.
+ def __init__(self, env: gymnasium.Env):
+ """A class for providing an automatic reset functionality for gymnasium environments when calling :meth:`self.step`.
Args:
env (gym.Env): The environment to apply the wrapper
diff --git a/gym/wrappers/clip_action.py b/gymnasium/wrappers/clip_action.py
similarity index 82%
rename from gym/wrappers/clip_action.py
rename to gymnasium/wrappers/clip_action.py
index de2363847..9b106d637 100644
--- a/gym/wrappers/clip_action.py
+++ b/gymnasium/wrappers/clip_action.py
@@ -1,17 +1,17 @@
"""Wrapper for clipping actions within a valid bound."""
import numpy as np
-import gym
-from gym import ActionWrapper
-from gym.spaces import Box
+import gymnasium
+from gymnasium import ActionWrapper
+from gymnasium.spaces import Box
class ClipAction(ActionWrapper):
"""Clip the continuous action within the valid :class:`Box` observation space bound.
Example:
- >>> import gym
- >>> env = gym.make('Bipedal-Walker-v3')
+ >>> import gymnasium
+ >>> env = gymnasium.make('Bipedal-Walker-v3')
>>> env = ClipAction(env)
>>> env.action_space
Box(-1.0, 1.0, (4,), float32)
@@ -19,7 +19,7 @@ class ClipAction(ActionWrapper):
# Executes the action np.array([1.0, 1.0, -1.0, 0]) in the base environment
"""
- def __init__(self, env: gym.Env):
+ def __init__(self, env: gymnasium.Env):
"""A wrapper for clipping continuous actions within the valid bound.
Args:
diff --git a/gym/wrappers/compatibility.py b/gymnasium/wrappers/compatibility.py
similarity index 94%
rename from gym/wrappers/compatibility.py
rename to gymnasium/wrappers/compatibility.py
index 4c0886139..6fcd6b267 100644
--- a/gym/wrappers/compatibility.py
+++ b/gymnasium/wrappers/compatibility.py
@@ -2,9 +2,9 @@
import sys
from typing import Any, Dict, Optional, Tuple
-import gym
-from gym.core import ObsType
-from gym.utils.step_api_compatibility import convert_to_terminated_truncated_step_api
+import gymnasium
+from gymnasium.core import ObsType
+from gymnasium.utils.step_api_compatibility import convert_to_terminated_truncated_step_api
if sys.version_info >= (3, 8):
from typing import Protocol, runtime_checkable
@@ -19,8 +19,8 @@
class LegacyEnv(Protocol):
"""A protocol for environments using the old step API."""
- observation_space: gym.Space
- action_space: gym.Space
+ observation_space: gymnasium.Space
+ action_space: gymnasium.Space
def reset(self) -> Any:
"""Reset the environment and return the initial observation."""
@@ -43,7 +43,7 @@ def seed(self, seed: Optional[int] = None):
...
-class EnvCompatibility(gym.Env):
+class EnvCompatibility(gymnasium.Env):
r"""A wrapper which can transform an environment from the old API to the new API.
Old step API refers to step() method returning (observation, reward, done, info), and reset() only retuning the observation.
diff --git a/gym/wrappers/env_checker.py b/gymnasium/wrappers/env_checker.py
similarity index 90%
rename from gym/wrappers/env_checker.py
rename to gymnasium/wrappers/env_checker.py
index 4c310403b..142d22e1e 100644
--- a/gym/wrappers/env_checker.py
+++ b/gymnasium/wrappers/env_checker.py
@@ -1,7 +1,7 @@
"""A passive environment checker wrapper for an environment's observation and action space along with the reset, step and render functions."""
-import gym
-from gym.core import ActType
-from gym.utils.passive_env_checker import (
+import gymnasium
+from gymnasium.core import ActType
+from gymnasium.utils.passive_env_checker import (
check_action_space,
check_observation_space,
env_render_passive_checker,
@@ -10,8 +10,8 @@
)
-class PassiveEnvChecker(gym.Wrapper):
- """A passive environment checker wrapper that surrounds the step, reset and render functions to check they follow the gym API."""
+class PassiveEnvChecker(gymnasium.Wrapper):
+ """A passive environment checker wrapper that surrounds the step, reset and render functions to check they follow the gymnasium API."""
def __init__(self, env):
"""Initialises the wrapper with the environments, run the observation and action space tests."""
diff --git a/gym/wrappers/filter_observation.py b/gymnasium/wrappers/filter_observation.py
similarity index 86%
rename from gym/wrappers/filter_observation.py
rename to gymnasium/wrappers/filter_observation.py
index 922c82880..6c064422e 100644
--- a/gym/wrappers/filter_observation.py
+++ b/gymnasium/wrappers/filter_observation.py
@@ -2,19 +2,19 @@
import copy
from typing import Sequence
-import gym
-from gym import spaces
+import gymnasium
+from gymnasium import spaces
-class FilterObservation(gym.ObservationWrapper):
+class FilterObservation(gymnasium.ObservationWrapper):
"""Filter Dict observation space by the keys.
Example:
- >>> import gym
- >>> env = gym.wrappers.TransformObservation(
- ... gym.make('CartPole-v1'), lambda obs: {'obs': obs, 'time': 0}
+ >>> import gymnasium
+ >>> env = gymnasium.wrappers.TransformObservation(
+ ... gymnasium.make('CartPole-v1'), lambda obs: {'obs': obs, 'time': 0}
... )
- >>> env.observation_space = gym.spaces.Dict(obs=env.observation_space, time=gym.spaces.Discrete(1))
+ >>> env.observation_space = gymnasium.spaces.Dict(obs=env.observation_space, time=gymnasium.spaces.Discrete(1))
>>> env.reset()
{'obs': array([-0.00067088, -0.01860439, 0.04772898, -0.01911527], dtype=float32), 'time': 0}
>>> env = FilterObservation(env, filter_keys=['time'])
@@ -24,7 +24,7 @@ class FilterObservation(gym.ObservationWrapper):
({'obs': array([ 0.04649447, -0.14996664, -0.03329664, 0.25847703], dtype=float32)}, 1.0, False, {})
"""
- def __init__(self, env: gym.Env, filter_keys: Sequence[str] = None):
+ def __init__(self, env: gymnasium.Env, filter_keys: Sequence[str] = None):
"""A wrapper that filters dictionary observations by their keys.
Args:
diff --git a/gym/wrappers/flatten_observation.py b/gymnasium/wrappers/flatten_observation.py
similarity index 79%
rename from gym/wrappers/flatten_observation.py
rename to gymnasium/wrappers/flatten_observation.py
index fe6518b87..996cd42db 100644
--- a/gym/wrappers/flatten_observation.py
+++ b/gymnasium/wrappers/flatten_observation.py
@@ -1,14 +1,14 @@
"""Wrapper for flattening observations of an environment."""
-import gym
-import gym.spaces as spaces
+import gymnasium
+import gymnasium.spaces as spaces
-class FlattenObservation(gym.ObservationWrapper):
+class FlattenObservation(gymnasium.ObservationWrapper):
"""Observation wrapper that flattens the observation.
Example:
- >>> import gym
- >>> env = gym.make('CarRacing-v1')
+ >>> import gymnasium
+ >>> env = gymnasium.make('CarRacing-v1')
>>> env.observation_space.shape
(96, 96, 3)
>>> env = FlattenObservation(env)
@@ -19,7 +19,7 @@ class FlattenObservation(gym.ObservationWrapper):
(27648,)
"""
- def __init__(self, env: gym.Env):
+ def __init__(self, env: gymnasium.Env):
"""Flattens the observations of an environment.
Args:
diff --git a/gym/wrappers/frame_stack.py b/gymnasium/wrappers/frame_stack.py
similarity index 94%
rename from gym/wrappers/frame_stack.py
rename to gymnasium/wrappers/frame_stack.py
index d55ae998c..bf42a1d90 100644
--- a/gym/wrappers/frame_stack.py
+++ b/gymnasium/wrappers/frame_stack.py
@@ -4,9 +4,9 @@
import numpy as np
-import gym
-from gym.error import DependencyNotInstalled
-from gym.spaces import Box
+import gymnasium
+from gymnasium.error import DependencyNotInstalled
+from gymnasium.spaces import Box
class LazyFrames:
@@ -38,7 +38,7 @@ def __init__(self, frames: list, lz4_compress: bool = False):
from lz4.block import compress
except ImportError:
raise DependencyNotInstalled(
- "lz4 is not installed, run `pip install gym[other]`"
+ "lz4 is not installed, run `pip install gymnasium[other]`"
)
frames = [compress(frame) for frame in frames]
@@ -97,7 +97,7 @@ def _check_decompress(self, frame):
return frame
-class FrameStack(gym.ObservationWrapper):
+class FrameStack(gymnasium.ObservationWrapper):
"""Observation wrapper that stacks the observations in a rolling manner.
For example, if the number of stacks is 4, then the returned observation contains
@@ -112,8 +112,8 @@ class FrameStack(gym.ObservationWrapper):
- After :meth:`reset` is called, the frame buffer will be filled with the initial observation. I.e. the observation returned by :meth:`reset` will consist of ``num_stack`-many identical frames,
Example:
- >>> import gym
- >>> env = gym.make('CarRacing-v1')
+ >>> import gymnasium
+ >>> env = gymnasium.make('CarRacing-v1')
>>> env = FrameStack(env, 4)
>>> env.observation_space
Box(4, 96, 96, 3)
@@ -124,7 +124,7 @@ class FrameStack(gym.ObservationWrapper):
def __init__(
self,
- env: gym.Env,
+ env: gymnasium.Env,
num_stack: int,
lz4_compress: bool = False,
):
diff --git a/gym/wrappers/gray_scale_observation.py b/gymnasium/wrappers/gray_scale_observation.py
similarity index 81%
rename from gym/wrappers/gray_scale_observation.py
rename to gymnasium/wrappers/gray_scale_observation.py
index 1c626f41f..588fba95f 100644
--- a/gym/wrappers/gray_scale_observation.py
+++ b/gymnasium/wrappers/gray_scale_observation.py
@@ -1,26 +1,26 @@
"""Wrapper that converts a color observation to grayscale."""
import numpy as np
-import gym
-from gym.spaces import Box
+import gymnasium
+from gymnasium.spaces import Box
-class GrayScaleObservation(gym.ObservationWrapper):
+class GrayScaleObservation(gymnasium.ObservationWrapper):
"""Convert the image observation from RGB to gray scale.
Example:
- >>> env = gym.make('CarRacing-v1')
+ >>> env = gymnasium.make('CarRacing-v1')
>>> env.observation_space
Box(0, 255, (96, 96, 3), uint8)
- >>> env = GrayScaleObservation(gym.make('CarRacing-v1'))
+ >>> env = GrayScaleObservation(gymnasium.make('CarRacing-v1'))
>>> env.observation_space
Box(0, 255, (96, 96), uint8)
- >>> env = GrayScaleObservation(gym.make('CarRacing-v1'), keep_dim=True)
+ >>> env = GrayScaleObservation(gymnasium.make('CarRacing-v1'), keep_dim=True)
>>> env.observation_space
Box(0, 255, (96, 96, 1), uint8)
"""
- def __init__(self, env: gym.Env, keep_dim: bool = False):
+ def __init__(self, env: gymnasium.Env, keep_dim: bool = False):
"""Convert the image observation from RGB to gray scale.
Args:
diff --git a/gym/wrappers/human_rendering.py b/gymnasium/wrappers/human_rendering.py
similarity index 90%
rename from gym/wrappers/human_rendering.py
rename to gymnasium/wrappers/human_rendering.py
index f488e9d1b..e05ce51c5 100644
--- a/gym/wrappers/human_rendering.py
+++ b/gymnasium/wrappers/human_rendering.py
@@ -1,11 +1,11 @@
"""A wrapper that adds human-renering functionality to an environment."""
import numpy as np
-import gym
-from gym.error import DependencyNotInstalled
+import gymnasium
+from gymnasium.error import DependencyNotInstalled
-class HumanRendering(gym.Wrapper):
+class HumanRendering(gymnasium.Wrapper):
"""Performs human rendering for an environment that only supports "rgb_array"rendering.
This wrapper is particularly useful when you have implemented an environment that can produce
@@ -16,7 +16,7 @@ class HumanRendering(gym.Wrapper):
The ``render_mode`` of the wrapped environment must be either ``'rgb_array'`` or ``'rgb_array_list'``.
Example:
- >>> env = gym.make("LunarLander-v2", render_mode="rgb_array")
+ >>> env = gymnasium.make("LunarLander-v2", render_mode="rgb_array")
>>> wrapped = HumanRendering(env)
>>> wrapped.reset() # This will start rendering to the screen
@@ -25,13 +25,13 @@ class HumanRendering(gym.Wrapper):
implement human-rendering natively (i.e. ``render_mode`` does not contain ``"human"``).
Example:
- >>> env = gym.make("NoNativeRendering-v2", render_mode="human") # NoNativeRendering-v0 doesn't implement human-rendering natively
+ >>> env = gymnasium.make("NoNativeRendering-v2", render_mode="human") # NoNativeRendering-v0 doesn't implement human-rendering natively
>>> env.reset() # This will start rendering to the screen
Warning: If the base environment uses ``render_mode="rgb_array_list"``, its (i.e. the *base environment's*) render method
will always return an empty list:
- >>> env = gym.make("LunarLander-v2", render_mode="rgb_array_list")
+ >>> env = gymnasium.make("LunarLander-v2", render_mode="rgb_array_list")
>>> wrapped = HumanRendering(env)
>>> wrapped.reset()
>>> env.render()
@@ -85,7 +85,7 @@ def _render_frame(self):
import pygame
except ImportError:
raise DependencyNotInstalled(
- "pygame is not installed, run `pip install gym[box2d]`"
+ "pygame is not installed, run `pip install gymnasium[box2d]`"
)
if self.env.render_mode == "rgb_array_list":
last_rgb_array = self.env.render()
diff --git a/gym/wrappers/monitoring/__init__.py b/gymnasium/wrappers/monitoring/__init__.py
similarity index 100%
rename from gym/wrappers/monitoring/__init__.py
rename to gymnasium/wrappers/monitoring/__init__.py
diff --git a/gym/wrappers/monitoring/video_recorder.py b/gymnasium/wrappers/monitoring/video_recorder.py
similarity index 99%
rename from gym/wrappers/monitoring/video_recorder.py
rename to gymnasium/wrappers/monitoring/video_recorder.py
index 9e34102de..899a71f9d 100644
--- a/gym/wrappers/monitoring/video_recorder.py
+++ b/gymnasium/wrappers/monitoring/video_recorder.py
@@ -5,7 +5,7 @@
import tempfile
from typing import List, Optional
-from gym import error, logger
+from gymnasium import error, logger
class VideoRecorder:
diff --git a/gym/wrappers/normalize.py b/gymnasium/wrappers/normalize.py
similarity index 96%
rename from gym/wrappers/normalize.py
rename to gymnasium/wrappers/normalize.py
index e8b51675c..93a0242d6 100644
--- a/gym/wrappers/normalize.py
+++ b/gymnasium/wrappers/normalize.py
@@ -1,7 +1,7 @@
"""Set of wrappers for normalizing actions and observations."""
import numpy as np
-import gym
+import gymnasium
# taken from https://github.com/openai/baselines/blob/master/baselines/common/vec_env/vec_normalize.py
@@ -46,7 +46,7 @@ def update_mean_var_count_from_moments(
return new_mean, new_var, new_count
-class NormalizeObservation(gym.core.Wrapper):
+class NormalizeObservation(gymnasium.core.Wrapper):
"""This wrapper will normalize observations s.t. each coordinate is centered with unit variance.
Note:
@@ -54,7 +54,7 @@ class NormalizeObservation(gym.core.Wrapper):
newly instantiated or the policy was changed recently.
"""
- def __init__(self, env: gym.Env, epsilon: float = 1e-8):
+ def __init__(self, env: gymnasium.Env, epsilon: float = 1e-8):
"""This wrapper will normalize observations s.t. each coordinate is centered with unit variance.
Args:
@@ -94,7 +94,7 @@ def normalize(self, obs):
return (obs - self.obs_rms.mean) / np.sqrt(self.obs_rms.var + self.epsilon)
-class NormalizeReward(gym.core.Wrapper):
+class NormalizeReward(gymnasium.core.Wrapper):
r"""This wrapper will normalize immediate rewards s.t. their exponential moving average has a fixed variance.
The exponential moving average will have variance :math:`(1 - \gamma)^2`.
@@ -106,7 +106,7 @@ class NormalizeReward(gym.core.Wrapper):
def __init__(
self,
- env: gym.Env,
+ env: gymnasium.Env,
gamma: float = 0.99,
epsilon: float = 1e-8,
):
diff --git a/gym/wrappers/order_enforcing.py b/gymnasium/wrappers/order_enforcing.py
similarity index 88%
rename from gym/wrappers/order_enforcing.py
rename to gymnasium/wrappers/order_enforcing.py
index d9f853e72..d1b2bf3b9 100644
--- a/gym/wrappers/order_enforcing.py
+++ b/gymnasium/wrappers/order_enforcing.py
@@ -1,13 +1,13 @@
"""Wrapper to enforce the proper ordering of environment operations."""
-import gym
-from gym.error import ResetNeeded
+import gymnasium
+from gymnasium.error import ResetNeeded
-class OrderEnforcing(gym.Wrapper):
+class OrderEnforcing(gymnasium.Wrapper):
"""A wrapper that will produce an error if :meth:`step` is called before an initial :meth:`reset`.
Example:
- >>> from gym.envs.classic_control import CartPoleEnv
+ >>> from gymnasium.envs.classic_control import CartPoleEnv
>>> env = CartPoleEnv()
>>> env = OrderEnforcing(env)
>>> env.step(0)
@@ -19,7 +19,7 @@ class OrderEnforcing(gym.Wrapper):
>>> env.step(0)
"""
- def __init__(self, env: gym.Env, disable_render_order_enforcing: bool = False):
+ def __init__(self, env: gymnasium.Env, disable_render_order_enforcing: bool = False):
"""A wrapper that will produce an error if :meth:`step` is called before an initial :meth:`reset`.
Args:
diff --git a/gym/wrappers/pixel_observation.py b/gymnasium/wrappers/pixel_observation.py
similarity index 92%
rename from gym/wrappers/pixel_observation.py
rename to gymnasium/wrappers/pixel_observation.py
index 6d70d4657..47c1f97a3 100644
--- a/gym/wrappers/pixel_observation.py
+++ b/gymnasium/wrappers/pixel_observation.py
@@ -6,13 +6,13 @@
import numpy as np
-import gym
-from gym import logger, spaces
+import gymnasium
+from gymnasium import logger, spaces
STATE_KEY = "state"
-class PixelObservationWrapper(gym.ObservationWrapper):
+class PixelObservationWrapper(gymnasium.ObservationWrapper):
"""Augment observations by pixel values.
Observations of this wrapper will be dictionaries of images.
@@ -23,14 +23,14 @@ class PixelObservationWrapper(gym.ObservationWrapper):
space) will be added to the dictionary under the key "state".
Example:
- >>> import gym
- >>> env = PixelObservationWrapper(gym.make('CarRacing-v1', render_mode="rgb_array"))
+ >>> import gymnasium
+ >>> env = PixelObservationWrapper(gymnasium.make('CarRacing-v1', render_mode="rgb_array"))
>>> obs = env.reset()
>>> obs.keys()
odict_keys(['pixels'])
>>> obs['pixels'].shape
(400, 600, 3)
- >>> env = PixelObservationWrapper(gym.make('CarRacing-v1', render_mode="rgb_array"), pixels_only=False)
+ >>> env = PixelObservationWrapper(gymnasium.make('CarRacing-v1', render_mode="rgb_array"), pixels_only=False)
>>> obs = env.reset()
>>> obs.keys()
odict_keys(['state', 'pixels'])
@@ -38,7 +38,7 @@ class PixelObservationWrapper(gym.ObservationWrapper):
(96, 96, 3)
>>> obs['pixels'].shape
(400, 600, 3)
- >>> env = PixelObservationWrapper(gym.make('CarRacing-v1', render_mode="rgb_array"), pixel_keys=('obs',))
+ >>> env = PixelObservationWrapper(gymnasium.make('CarRacing-v1', render_mode="rgb_array"), pixel_keys=('obs',))
>>> obs = env.reset()
>>> obs.keys()
odict_keys(['obs'])
@@ -48,7 +48,7 @@ class PixelObservationWrapper(gym.ObservationWrapper):
def __init__(
self,
- env: gym.Env,
+ env: gymnasium.Env,
pixels_only: bool = True,
render_kwargs: Optional[Dict[str, Dict[str, Any]]] = None,
pixel_keys: Tuple[str, ...] = ("pixels",),
@@ -98,7 +98,7 @@ def __init__(
default_render_kwargs = {"mode": "rgb_array_list"}
logger.warn(
"env.render_mode must be specified to use PixelObservationWrapper:"
- "`gym.make(env_name, render_mode='rgb_array')`."
+ "`gymnasium.make(env_name, render_mode='rgb_array')`."
)
for key in pixel_keys:
diff --git a/gym/wrappers/record_episode_statistics.py b/gymnasium/wrappers/record_episode_statistics.py
similarity index 97%
rename from gym/wrappers/record_episode_statistics.py
rename to gymnasium/wrappers/record_episode_statistics.py
index 0a822cea4..6b0a030f4 100644
--- a/gym/wrappers/record_episode_statistics.py
+++ b/gymnasium/wrappers/record_episode_statistics.py
@@ -5,7 +5,7 @@
import numpy as np
-import gym
+import gymnasium
def add_vector_episode_statistics(
@@ -37,7 +37,7 @@ def add_vector_episode_statistics(
return info
-class RecordEpisodeStatistics(gym.Wrapper):
+class RecordEpisodeStatistics(gymnasium.Wrapper):
"""This wrapper will keep track of cumulative rewards and episode lengths.
At the end of an episode, the statistics of the episode will be added to ``info``
@@ -76,7 +76,7 @@ class RecordEpisodeStatistics(gym.Wrapper):
length_queue: The lengths of the last ``deque_size``-many episodes
"""
- def __init__(self, env: gym.Env, deque_size: int = 100):
+ def __init__(self, env: gymnasium.Env, deque_size: int = 100):
"""This wrapper will keep track of cumulative rewards and episode lengths.
Args:
diff --git a/gym/wrappers/record_video.py b/gymnasium/wrappers/record_video.py
similarity index 97%
rename from gym/wrappers/record_video.py
rename to gymnasium/wrappers/record_video.py
index dea254cfb..628c66a97 100644
--- a/gym/wrappers/record_video.py
+++ b/gymnasium/wrappers/record_video.py
@@ -2,9 +2,9 @@
import os
from typing import Callable, Optional
-import gym
-from gym import logger
-from gym.wrappers.monitoring import video_recorder
+import gymnasium
+from gymnasium import logger
+from gymnasium.wrappers.monitoring import video_recorder
def capped_cubic_video_schedule(episode_id: int) -> bool:
@@ -24,7 +24,7 @@ def capped_cubic_video_schedule(episode_id: int) -> bool:
return episode_id % 1000 == 0
-class RecordVideo(gym.Wrapper):
+class RecordVideo(gymnasium.Wrapper):
"""This wrapper records videos of rollouts.
Usually, you only want to record episodes intermittently, say every hundredth episode.
@@ -39,7 +39,7 @@ class RecordVideo(gym.Wrapper):
def __init__(
self,
- env: gym.Env,
+ env: gymnasium.Env,
video_folder: str,
episode_trigger: Callable[[int], bool] = None,
step_trigger: Callable[[int], bool] = None,
diff --git a/gym/wrappers/render_collection.py b/gymnasium/wrappers/render_collection.py
similarity index 91%
rename from gym/wrappers/render_collection.py
rename to gymnasium/wrappers/render_collection.py
index c79df9b0d..a5c160c0a 100644
--- a/gym/wrappers/render_collection.py
+++ b/gymnasium/wrappers/render_collection.py
@@ -1,11 +1,11 @@
"""A wrapper that adds render collection mode to an environment."""
-import gym
+import gymnasium
-class RenderCollection(gym.Wrapper):
+class RenderCollection(gymnasium.Wrapper):
"""Save collection of render frames."""
- def __init__(self, env: gym.Env, pop_frames: bool = True, reset_clean: bool = True):
+ def __init__(self, env: gymnasium.Env, pop_frames: bool = True, reset_clean: bool = True):
"""Initialize a :class:`RenderCollection` instance.
Args:
diff --git a/gym/wrappers/rescale_action.py b/gymnasium/wrappers/rescale_action.py
similarity index 91%
rename from gym/wrappers/rescale_action.py
rename to gymnasium/wrappers/rescale_action.py
index bf3cf6cd1..e0cf64538 100644
--- a/gym/wrappers/rescale_action.py
+++ b/gymnasium/wrappers/rescale_action.py
@@ -3,19 +3,19 @@
import numpy as np
-import gym
-from gym import spaces
+import gymnasium
+from gymnasium import spaces
-class RescaleAction(gym.ActionWrapper):
+class RescaleAction(gymnasium.ActionWrapper):
"""Affinely rescales the continuous action space of the environment to the range [min_action, max_action].
The base environment :attr:`env` must have an action space of type :class:`spaces.Box`. If :attr:`min_action`
or :attr:`max_action` are numpy arrays, the shape must match the shape of the environment's action space.
Example:
- >>> import gym
- >>> env = gym.make('BipedalWalker-v3')
+ >>> import gymnasium
+ >>> env = gymnasium.make('BipedalWalker-v3')
>>> env.action_space
Box(-1.0, 1.0, (4,), float32)
>>> min_action = -0.5
@@ -23,13 +23,13 @@ class RescaleAction(gym.ActionWrapper):
>>> env = RescaleAction(env, min_action=min_action, max_action=max_action)
>>> env.action_space
Box(-0.5, [0. 0.5 1. 0.75], (4,), float32)
- >>> RescaleAction(env, min_action, max_action).action_space == gym.spaces.Box(min_action, max_action)
+ >>> RescaleAction(env, min_action, max_action).action_space == gymnasium.spaces.Box(min_action, max_action)
True
"""
def __init__(
self,
- env: gym.Env,
+ env: gymnasium.Env,
min_action: Union[float, int, np.ndarray],
max_action: Union[float, int, np.ndarray],
):
diff --git a/gym/wrappers/resize_observation.py b/gymnasium/wrappers/resize_observation.py
similarity index 84%
rename from gym/wrappers/resize_observation.py
rename to gymnasium/wrappers/resize_observation.py
index 4f486a97b..f785a6602 100644
--- a/gym/wrappers/resize_observation.py
+++ b/gymnasium/wrappers/resize_observation.py
@@ -3,12 +3,12 @@
import numpy as np
-import gym
-from gym.error import DependencyNotInstalled
-from gym.spaces import Box
+import gymnasium
+from gymnasium.error import DependencyNotInstalled
+from gymnasium.spaces import Box
-class ResizeObservation(gym.ObservationWrapper):
+class ResizeObservation(gymnasium.ObservationWrapper):
"""Resize the image observation.
This wrapper works on environments with image observations (or more generally observations of shape AxBxC) and resizes
@@ -16,8 +16,8 @@ class ResizeObservation(gym.ObservationWrapper):
In that case, the observation is scaled to a square of side-length :attr:`shape`.
Example:
- >>> import gym
- >>> env = gym.make('CarRacing-v1')
+ >>> import gymnasium
+ >>> env = gymnasium.make('CarRacing-v1')
>>> env.observation_space.shape
(96, 96, 3)
>>> env = ResizeObservation(env, 64)
@@ -25,7 +25,7 @@ class ResizeObservation(gym.ObservationWrapper):
(64, 64, 3)
"""
- def __init__(self, env: gym.Env, shape: Union[tuple, int]):
+ def __init__(self, env: gymnasium.Env, shape: Union[tuple, int]):
"""Resizes image observations to shape given by :attr:`shape`.
Args:
@@ -61,7 +61,7 @@ def observation(self, observation):
import cv2
except ImportError:
raise DependencyNotInstalled(
- "opencv is not install, run `pip install gym[other]`"
+ "opencv is not install, run `pip install gymnasium[other]`"
)
observation = cv2.resize(
diff --git a/gym/wrappers/step_api_compatibility.py b/gymnasium/wrappers/step_api_compatibility.py
similarity index 85%
rename from gym/wrappers/step_api_compatibility.py
rename to gymnasium/wrappers/step_api_compatibility.py
index 358851cb3..c8cd96eb2 100644
--- a/gym/wrappers/step_api_compatibility.py
+++ b/gymnasium/wrappers/step_api_compatibility.py
@@ -1,13 +1,13 @@
"""Implementation of StepAPICompatibility wrapper class for transforming envs between new and old step API."""
-import gym
-from gym.logger import deprecation
-from gym.utils.step_api_compatibility import (
+import gymnasium
+from gymnasium.logger import deprecation
+from gymnasium.utils.step_api_compatibility import (
convert_to_done_step_api,
convert_to_terminated_truncated_step_api,
)
-class StepAPICompatibility(gym.Wrapper):
+class StepAPICompatibility(gymnasium.Wrapper):
r"""A wrapper which can transform an environment from new step API to old and vice-versa.
Old step API refers to step() method returning (observation, reward, done, info)
@@ -19,16 +19,16 @@ class StepAPICompatibility(gym.Wrapper):
apply_step_compatibility (bool): Apply to convert environment to use new step API that returns two bools. (False by default)
Examples:
- >>> env = gym.make("CartPole-v1")
+ >>> env = gymnasium.make("CartPole-v1")
>>> env # wrapper not applied by default, set to new API
>>>>
- >>> env = gym.make("CartPole-v1", apply_api_compatibility=True) # set to old API
+ >>> env = gymnasium.make("CartPole-v1", apply_api_compatibility=True) # set to old API
>>>>>
>>> env = StepAPICompatibility(CustomEnv(), apply_step_compatibility=False) # manually using wrapper on unregistered envs
"""
- def __init__(self, env: gym.Env, output_truncation_bool: bool = True):
+ def __init__(self, env: gymnasium.Env, output_truncation_bool: bool = True):
"""A wrapper which can transform an environment from new step API to old and vice-versa.
Args:
diff --git a/gym/wrappers/time_aware_observation.py b/gymnasium/wrappers/time_aware_observation.py
similarity index 90%
rename from gym/wrappers/time_aware_observation.py
rename to gymnasium/wrappers/time_aware_observation.py
index 781a77c25..4334c392e 100644
--- a/gym/wrappers/time_aware_observation.py
+++ b/gymnasium/wrappers/time_aware_observation.py
@@ -1,19 +1,19 @@
"""Wrapper for adding time aware observations to environment observation."""
import numpy as np
-import gym
-from gym.spaces import Box
+import gymnasium
+from gymnasium.spaces import Box
-class TimeAwareObservation(gym.ObservationWrapper):
+class TimeAwareObservation(gymnasium.ObservationWrapper):
"""Augment the observation with the current time step in the episode.
The observation space of the wrapped environment is assumed to be a flat :class:`Box`.
In particular, pixel observations are not supported. This wrapper will append the current timestep within the current episode to the observation.
Example:
- >>> import gym
- >>> env = gym.make('CartPole-v1')
+ >>> import gymnasium
+ >>> env = gymnasium.make('CartPole-v1')
>>> env = TimeAwareObservation(env)
>>> env.reset()
array([ 0.03810719, 0.03522411, 0.02231044, -0.01088205, 0. ])
@@ -21,7 +21,7 @@ class TimeAwareObservation(gym.ObservationWrapper):
array([ 0.03881167, -0.16021058, 0.0220928 , 0.28875574, 1. ])
"""
- def __init__(self, env: gym.Env):
+ def __init__(self, env: gymnasium.Env):
"""Initialize :class:`TimeAwareObservation` that requires an environment with a flat :class:`Box` observation space.
Args:
diff --git a/gym/wrappers/time_limit.py b/gymnasium/wrappers/time_limit.py
similarity index 92%
rename from gym/wrappers/time_limit.py
rename to gymnasium/wrappers/time_limit.py
index 854876e3a..ef27331dc 100644
--- a/gym/wrappers/time_limit.py
+++ b/gymnasium/wrappers/time_limit.py
@@ -1,25 +1,25 @@
"""Wrapper for limiting the time steps of an environment."""
from typing import Optional
-import gym
+import gymnasium
-class TimeLimit(gym.Wrapper):
+class TimeLimit(gymnasium.Wrapper):
"""This wrapper will issue a `truncated` signal if a maximum number of timesteps is exceeded.
If a truncation is not defined inside the environment itself, this is the only place that the truncation signal is issued.
Critically, this is different from the `terminated` signal that originates from the underlying environment as part of the MDP.
Example:
- >>> from gym.envs.classic_control import CartPoleEnv
- >>> from gym.wrappers import TimeLimit
+ >>> from gymnasium.envs.classic_control import CartPoleEnv
+ >>> from gymnasium.wrappers import TimeLimit
>>> env = CartPoleEnv()
>>> env = TimeLimit(env, max_episode_steps=1000)
"""
def __init__(
self,
- env: gym.Env,
+ env: gymnasium.Env,
max_episode_steps: Optional[int] = None,
):
"""Initializes the :class:`TimeLimit` wrapper with an environment and the number of steps after which truncation will occur.
diff --git a/gym/wrappers/transform_observation.py b/gymnasium/wrappers/transform_observation.py
similarity index 87%
rename from gym/wrappers/transform_observation.py
rename to gymnasium/wrappers/transform_observation.py
index 2af2e9afb..a7939d621 100644
--- a/gym/wrappers/transform_observation.py
+++ b/gymnasium/wrappers/transform_observation.py
@@ -1,10 +1,10 @@
"""Wrapper for transforming observations."""
from typing import Any, Callable
-import gym
+import gymnasium
-class TransformObservation(gym.ObservationWrapper):
+class TransformObservation(gymnasium.ObservationWrapper):
"""Transform the observation via an arbitrary function :attr:`f`.
The function :attr:`f` should be defined on the observation space of the base environment, ``env``, and should, ideally, return values in the same space.
@@ -12,15 +12,15 @@ class TransformObservation(gym.ObservationWrapper):
If the transformation you wish to apply to observations returns values in a *different* space, you should subclass :class:`ObservationWrapper`, implement the transformation, and set the new observation space accordingly. If you were to use this wrapper instead, the observation space would be set incorrectly.
Example:
- >>> import gym
+ >>> import gymnasium
>>> import numpy as np
- >>> env = gym.make('CartPole-v1')
+ >>> env = gymnasium.make('CartPole-v1')
>>> env = TransformObservation(env, lambda obs: obs + 0.1*np.random.randn(*obs.shape))
>>> env.reset()
array([-0.08319338, 0.04635121, -0.07394746, 0.20877492])
"""
- def __init__(self, env: gym.Env, f: Callable[[Any], Any]):
+ def __init__(self, env: gymnasium.Env, f: Callable[[Any], Any]):
"""Initialize the :class:`TransformObservation` wrapper with an environment and a transform function :param:`f`.
Args:
diff --git a/gym/wrappers/transform_reward.py b/gymnasium/wrappers/transform_reward.py
similarity index 85%
rename from gym/wrappers/transform_reward.py
rename to gymnasium/wrappers/transform_reward.py
index a17a8ef1b..39c8ca316 100644
--- a/gym/wrappers/transform_reward.py
+++ b/gymnasium/wrappers/transform_reward.py
@@ -1,8 +1,8 @@
"""Wrapper for transforming the reward."""
from typing import Callable
-import gym
-from gym import RewardWrapper
+import gymnasium
+from gymnasium import RewardWrapper
class TransformReward(RewardWrapper):
@@ -12,8 +12,8 @@ class TransformReward(RewardWrapper):
If the base environment specifies a reward range which is not invariant under :attr:`f`, the :attr:`reward_range` of the wrapped environment will be incorrect.
Example:
- >>> import gym
- >>> env = gym.make('CartPole-v1')
+ >>> import gymnasium
+ >>> env = gymnasium.make('CartPole-v1')
>>> env = TransformReward(env, lambda r: 0.01*r)
>>> env.reset()
>>> observation, reward, terminated, truncated, info = env.step(env.action_space.sample())
@@ -21,7 +21,7 @@ class TransformReward(RewardWrapper):
0.01
"""
- def __init__(self, env: gym.Env, f: Callable[[float], float]):
+ def __init__(self, env: gymnasium.Env, f: Callable[[float], float]):
"""Initialize the :class:`TransformReward` wrapper with an environment and reward transform function :param:`f`.
Args:
diff --git a/gym/wrappers/vector_list_info.py b/gymnasium/wrappers/vector_list_info.py
similarity index 98%
rename from gym/wrappers/vector_list_info.py
rename to gymnasium/wrappers/vector_list_info.py
index 8ab933e95..5fca110fd 100644
--- a/gym/wrappers/vector_list_info.py
+++ b/gymnasium/wrappers/vector_list_info.py
@@ -2,10 +2,10 @@
from typing import List
-import gym
+import gymnasium
-class VectorListInfo(gym.Wrapper):
+class VectorListInfo(gymnasium.Wrapper):
"""Converts infos of vectorized environments from dict to List[dict].
This wrapper converts the info format of a
diff --git a/pyproject.toml b/pyproject.toml
index 2b3970451..7f3335be0 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,7 +1,7 @@
[tool.pyright]
include = [
- "gym/**",
+ "gymnasium/**",
"tests/**"
]
@@ -39,4 +39,4 @@ reportPrivateUsage = "warning"
reportUnboundVariable = "warning"
[tool.pytest.ini_options]
-filterwarnings = ['ignore:.*step API.*:DeprecationWarning'] # TODO: to be removed when old step API is removed
+# filterwarnings = ['ignore:.*step API.*:DeprecationWarning']
diff --git a/setup.py b/setup.py
index fc4d9f947..86d9cd816 100644
--- a/setup.py
+++ b/setup.py
@@ -4,7 +4,7 @@
from setuptools import find_packages, setup
-with open("gym/version.py") as file:
+with open("gymnasium/version.py") as file:
full_version = file.read()
assert (
re.match(r'VERSION = "\d\.\d+\.\d+"\n', full_version).group(0) == full_version
@@ -51,7 +51,7 @@
author="Gym Community",
author_email="jkterry@umd.edu",
classifiers=[
- # Python 3.6 is minimally supported (only with basic gym environments and API)
+ # Python 3.6 is minimally supported (only with basic gymnasium environments and API)
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
@@ -71,10 +71,10 @@
license="MIT",
long_description=long_description,
long_description_content_type="text/markdown",
- name="gym",
- packages=[package for package in find_packages() if package.startswith("gym")],
+ name="gymnasium",
+ packages=[package for package in find_packages() if package.startswith("gymnasium")],
package_data={
- "gym": [
+ "gymnasium": [
"envs/mujoco/assets/*.xml",
"envs/classic_control/assets/*.png",
"envs/toy_text/font/*.ttf",
diff --git a/tests/envs/test_action_dim_check.py b/tests/envs/test_action_dim_check.py
index 1643f6e34..7fafedc04 100644
--- a/tests/envs/test_action_dim_check.py
+++ b/tests/envs/test_action_dim_check.py
@@ -1,9 +1,9 @@
import numpy as np
import pytest
-import gym
-from gym import spaces
-from gym.envs.registration import EnvSpec
+import gymnasium
+from gymnasium import spaces
+from gymnasium.envs.registration import EnvSpec
from tests.envs.utils import all_testing_initialised_envs, mujoco_testing_env_specs
@@ -59,14 +59,14 @@ def test_mujoco_action_dimensions(env_spec: EnvSpec):
@pytest.mark.parametrize(
"env", DISCRETE_ENVS, ids=[env.spec.id for env in DISCRETE_ENVS]
)
-def test_discrete_actions_out_of_bound(env: gym.Env):
+def test_discrete_actions_out_of_bound(env: gymnasium.Env):
"""Test out of bound actions in Discrete action_space.
In discrete action_space environments, `out-of-bound`
actions are not allowed and should raise an exception.
Args:
- env (gym.Env): the gym environment
+ env (gym.Env): the gymnasium environment
"""
assert isinstance(env.action_space, spaces.Discrete)
upper_bound = env.action_space.start + env.action_space.n - 1
@@ -88,7 +88,7 @@ def test_discrete_actions_out_of_bound(env: gym.Env):
@pytest.mark.parametrize("env", BOX_ENVS, ids=[env.spec.id for env in BOX_ENVS])
-def test_box_actions_out_of_bound(env: gym.Env):
+def test_box_actions_out_of_bound(env: gymnasium.Env):
"""Test out of bound actions in Box action_space.
Environments with Box actions spaces perform clipping inside `step`.
@@ -96,11 +96,11 @@ def test_box_actions_out_of_bound(env: gym.Env):
of an action with value exactly at the upper (or lower) bound.
Args:
- env (gym.Env): the gym environment
+ env (gym.Env): the gymnasium environment
"""
env.reset(seed=42)
- oob_env = gym.make(env.spec.id, disable_env_checker=True)
+ oob_env = gymnasium.make(env.spec.id, disable_env_checker=True)
oob_env.reset(seed=42)
assert isinstance(env.action_space, spaces.Box)
diff --git a/tests/envs/test_compatibility.py b/tests/envs/test_compatibility.py
index c719ec841..d651579ac 100644
--- a/tests/envs/test_compatibility.py
+++ b/tests/envs/test_compatibility.py
@@ -3,12 +3,12 @@
import numpy as np
-import gym
-from gym.spaces import Discrete
-from gym.wrappers.compatibility import EnvCompatibility, LegacyEnv
+import gymnasium
+from gymnasium.spaces import Discrete
+from gymnasium.wrappers.compatibility import EnvCompatibility, LegacyEnv
-class LegacyEnvExplicit(LegacyEnv, gym.Env):
+class LegacyEnvExplicit(LegacyEnv, gymnasium.Env):
"""Legacy env that explicitly implements the old API."""
observation_space = Discrete(1)
@@ -37,7 +37,7 @@ def seed(self, seed=None):
pass
-class LegacyEnvImplicit(gym.Env):
+class LegacyEnvImplicit(gymnasium.Env):
"""Legacy env that implicitly implements the old API as a protocol."""
observation_space = Discrete(1)
@@ -95,12 +95,12 @@ def test_implicit():
def test_make_compatibility_in_spec():
- gym.register(
+ gymnasium.register(
id="LegacyTestEnv-v0",
entry_point=LegacyEnvExplicit,
apply_api_compatibility=True,
)
- env = gym.make("LegacyTestEnv-v0", render_mode="rgb_array")
+ env = gymnasium.make("LegacyTestEnv-v0", render_mode="rgb_array")
assert env.observation_space == Discrete(1)
assert env.action_space == Discrete(1)
assert env.reset() == (0, {})
@@ -110,12 +110,12 @@ def test_make_compatibility_in_spec():
assert isinstance(img, np.ndarray)
assert img.shape == (1, 1, 3) # type: ignore
env.close()
- del gym.envs.registration.registry["LegacyTestEnv-v0"]
+ del gymnasium.envs.registration.registry["LegacyTestEnv-v0"]
def test_make_compatibility_in_make():
- gym.register(id="LegacyTestEnv-v0", entry_point=LegacyEnvExplicit)
- env = gym.make(
+ gymnasium.register(id="LegacyTestEnv-v0", entry_point=LegacyEnvExplicit)
+ env = gymnasium.make(
"LegacyTestEnv-v0", apply_api_compatibility=True, render_mode="rgb_array"
)
assert env.observation_space == Discrete(1)
@@ -127,4 +127,4 @@ def test_make_compatibility_in_make():
assert isinstance(img, np.ndarray)
assert img.shape == (1, 1, 3) # type: ignore
env.close()
- del gym.envs.registration.registry["LegacyTestEnv-v0"]
+ del gymnasium.envs.registration.registry["LegacyTestEnv-v0"]
diff --git a/tests/envs/test_env_implementation.py b/tests/envs/test_env_implementation.py
index 33c29124a..5965c5de1 100644
--- a/tests/envs/test_env_implementation.py
+++ b/tests/envs/test_env_implementation.py
@@ -3,16 +3,16 @@
import numpy as np
import pytest
-import gym
-from gym.envs.box2d import BipedalWalker
-from gym.envs.box2d.lunar_lander import demo_heuristic_lander
-from gym.envs.toy_text import TaxiEnv
-from gym.envs.toy_text.frozen_lake import generate_random_map
+import gymnasium
+from gymnasium.envs.box2d import BipedalWalker
+from gymnasium.envs.box2d.lunar_lander import demo_heuristic_lander
+from gymnasium.envs.toy_text import TaxiEnv
+from gymnasium.envs.toy_text.frozen_lake import generate_random_map
def test_lunar_lander_heuristics():
"""Tests the LunarLander environment by checking if the heuristic lander works."""
- lunar_lander = gym.make("LunarLander-v2", disable_env_checker=True)
+ lunar_lander = gymnasium.make("LunarLander-v2", disable_env_checker=True)
total_reward = demo_heuristic_lander(lunar_lander, seed=1)
assert total_reward > 100
@@ -23,7 +23,7 @@ def test_carracing_domain_randomize():
CarRacing DomainRandomize should have different colours at every reset.
However, it should have same colours when `options={"randomize": False}` is given to reset.
"""
- env = gym.make("CarRacing-v2", domain_randomize=True)
+ env = gymnasium.make("CarRacing-v2", domain_randomize=True)
road_color = env.road_color
bg_color = env.bg_color
@@ -71,8 +71,8 @@ def test_bipedal_walker_hardcore_creation(seed: int):
HC_TERRAINS_COLOR1 = (255, 255, 255)
HC_TERRAINS_COLOR2 = (153, 153, 153)
- env = gym.make("BipedalWalker-v3", disable_env_checker=True).unwrapped
- hc_env = gym.make("BipedalWalkerHardcore-v3", disable_env_checker=True).unwrapped
+ env = gymnasium.make("BipedalWalker-v3", disable_env_checker=True).unwrapped
+ hc_env = gymnasium.make("BipedalWalkerHardcore-v3", disable_env_checker=True).unwrapped
assert isinstance(env, BipedalWalker) and isinstance(hc_env, BipedalWalker)
assert env.hardcore is False and hc_env.hardcore is True
@@ -155,7 +155,7 @@ def test_taxi_encode_decode():
"low_high", [None, (-0.4, 0.4), (np.array(-0.4), np.array(0.4))]
)
def test_customizable_resets(env_name: str, low_high: Optional[list]):
- env = gym.make(env_name)
+ env = gymnasium.make(env_name)
env.action_space.seed(0)
# First ensure we can do a reset.
if low_high is None:
@@ -178,7 +178,7 @@ def test_customizable_resets(env_name: str, low_high: Optional[list]):
],
)
def test_customizable_pendulum_resets(low_high: Optional[list]):
- env = gym.make("Pendulum-v1")
+ env = gymnasium.make("Pendulum-v1")
env.action_space.seed(0)
# First ensure we can do a reset and the values are within expected ranges.
if low_high is None:
@@ -207,7 +207,7 @@ def test_customizable_pendulum_resets(low_high: Optional[list]):
],
)
def test_invalid_customizable_resets(env_name: str, low_high: list):
- env = gym.make(env_name)
+ env = gymnasium.make(env_name)
low, high = low_high
with pytest.raises(ValueError):
# match=re.escape(f"Lower bound ({low}) must be lower than higher bound ({high}).")
diff --git a/tests/envs/test_envs.py b/tests/envs/test_envs.py
index 6657e1dea..3deb62f8b 100644
--- a/tests/envs/test_envs.py
+++ b/tests/envs/test_envs.py
@@ -4,10 +4,10 @@
import numpy as np
import pytest
-import gym
-from gym.envs.registration import EnvSpec
-from gym.logger import warn
-from gym.utils.env_checker import check_env, data_equivalence
+import gymnasium
+from gymnasium.envs.registration import EnvSpec
+from gymnasium.logger import warn
+from gymnasium.utils.env_checker import check_env, data_equivalence
from tests.envs.utils import (
all_testing_env_specs,
all_testing_initialised_envs,
@@ -48,7 +48,7 @@ def test_envs_pass_env_checker(spec):
for warning in caught_warnings:
if warning.message.args[0] not in CHECK_ENV_IGNORE_WARNINGS:
- raise gym.error.Error(f"Unexpected warning: {warning.message}")
+ raise gymnasium.error.Error(f"Unexpected warning: {warning.message}")
# Note that this precludes running this test in multiple threads.
@@ -189,7 +189,7 @@ def test_render_modes(spec):
all_testing_initialised_envs,
ids=[env.spec.id for env in all_testing_initialised_envs],
)
-def test_pickle_env(env: gym.Env):
+def test_pickle_env(env: gymnasium.Env):
pickled_env = pickle.loads(pickle.dumps(env))
data_equivalence(env.reset(), pickled_env.reset())
diff --git a/tests/envs/test_make.py b/tests/envs/test_make.py
index cf336fb18..55c584a40 100644
--- a/tests/envs/test_make.py
+++ b/tests/envs/test_make.py
@@ -1,4 +1,4 @@
-"""Tests that gym.make works as expected."""
+"""Tests that gymnasium.make works as expected."""
import re
import warnings
@@ -7,22 +7,22 @@
import numpy as np
import pytest
-import gym
-from gym.envs.classic_control import cartpole
-from gym.wrappers import AutoResetWrapper, HumanRendering, OrderEnforcing, TimeLimit
-from gym.wrappers.env_checker import PassiveEnvChecker
+import gymnasium
+from gymnasium.envs.classic_control import cartpole
+from gymnasium.wrappers import AutoResetWrapper, HumanRendering, OrderEnforcing, TimeLimit
+from gymnasium.wrappers.env_checker import PassiveEnvChecker
from tests.envs.test_envs import PASSIVE_CHECK_IGNORE_WARNING
from tests.envs.utils import all_testing_env_specs
from tests.envs.utils_envs import ArgumentEnv, RegisterDuringMakeEnv
from tests.testing_env import GenericTestEnv, old_step_fn
from tests.wrappers.utils import has_wrapper
-gym.register(
+gymnasium.register(
"RegisterDuringMakeEnv-v0",
entry_point="tests.envs.utils_envs:RegisterDuringMakeEnv",
)
-gym.register(
+gymnasium.register(
id="test.ArgumentEnv-v0",
entry_point="tests.envs.utils_envs:ArgumentEnv",
kwargs={
@@ -31,23 +31,23 @@
},
)
-gym.register(
+gymnasium.register(
id="test/NoHuman-v0",
entry_point="tests.envs.utils_envs:NoHuman",
)
-gym.register(
+gymnasium.register(
id="test/NoHumanOldAPI-v0",
entry_point="tests.envs.utils_envs:NoHumanOldAPI",
)
-gym.register(
+gymnasium.register(
id="test/NoHumanNoRGB-v0",
entry_point="tests.envs.utils_envs:NoHumanNoRGB",
)
def test_make():
- env = gym.make("CartPole-v1", disable_env_checker=True)
+ env = gymnasium.make("CartPole-v1", disable_env_checker=True)
assert env.spec.id == "CartPole-v1"
assert isinstance(env.unwrapped, cartpole.CartPoleEnv)
env.close()
@@ -56,32 +56,32 @@ def test_make():
def test_make_deprecated():
with warnings.catch_warnings(record=True):
with pytest.raises(
- gym.error.Error,
+ gymnasium.error.Error,
match=re.escape(
"Environment version v0 for `Humanoid` is deprecated. Please use `Humanoid-v4` instead."
),
):
- gym.make("Humanoid-v0", disable_env_checker=True)
+ gymnasium.make("Humanoid-v0", disable_env_checker=True)
def test_make_max_episode_steps():
# Default, uses the spec's
- env = gym.make("CartPole-v1", disable_env_checker=True)
+ env = gymnasium.make("CartPole-v1", disable_env_checker=True)
assert has_wrapper(env, TimeLimit)
assert (
- env.spec.max_episode_steps == gym.envs.registry["CartPole-v1"].max_episode_steps
+ env.spec.max_episode_steps == gymnasium.envs.registry["CartPole-v1"].max_episode_steps
)
env.close()
# Custom max episode steps
- env = gym.make("CartPole-v1", max_episode_steps=100, disable_env_checker=True)
+ env = gymnasium.make("CartPole-v1", max_episode_steps=100, disable_env_checker=True)
assert has_wrapper(env, TimeLimit)
assert env.spec.max_episode_steps == 100
env.close()
# Env spec has no max episode steps
- assert gym.spec("test.ArgumentEnv-v0").max_episode_steps is None
- env = gym.make(
+ assert gymnasium.spec("test.ArgumentEnv-v0").max_episode_steps is None
+ env = gymnasium.make(
"test.ArgumentEnv-v0", arg1=None, arg2=None, arg3=None, disable_env_checker=True
)
assert has_wrapper(env, TimeLimit) is False
@@ -89,57 +89,57 @@ def test_make_max_episode_steps():
def test_gym_make_autoreset():
- """Tests that `gym.make` autoreset wrapper is applied only when `gym.make(..., autoreset=True)`."""
- env = gym.make("CartPole-v1", disable_env_checker=True)
+ """Tests that `gymnasium.make` autoreset wrapper is applied only when `gymnasium.make(..., autoreset=True)`."""
+ env = gymnasium.make("CartPole-v1", disable_env_checker=True)
assert has_wrapper(env, AutoResetWrapper) is False
env.close()
- env = gym.make("CartPole-v1", autoreset=False, disable_env_checker=True)
+ env = gymnasium.make("CartPole-v1", autoreset=False, disable_env_checker=True)
assert has_wrapper(env, AutoResetWrapper) is False
env.close()
- env = gym.make("CartPole-v1", autoreset=True)
+ env = gymnasium.make("CartPole-v1", autoreset=True)
assert has_wrapper(env, AutoResetWrapper)
env.close()
def test_make_disable_env_checker():
- """Tests that `gym.make` disable env checker is applied only when `gym.make(..., disable_env_checker=False)`."""
- spec = deepcopy(gym.spec("CartPole-v1"))
+ """Tests that `gymnasium.make` disable env checker is applied only when `gymnasium.make(..., disable_env_checker=False)`."""
+ spec = deepcopy(gymnasium.spec("CartPole-v1"))
# Test with spec disable env checker
spec.disable_env_checker = False
- env = gym.make(spec)
+ env = gymnasium.make(spec)
assert has_wrapper(env, PassiveEnvChecker)
env.close()
# Test with overwritten spec using make disable env checker
assert spec.disable_env_checker is False
- env = gym.make(spec, disable_env_checker=True)
+ env = gymnasium.make(spec, disable_env_checker=True)
assert has_wrapper(env, PassiveEnvChecker) is False
env.close()
# Test with spec enabled disable env checker
spec.disable_env_checker = True
- env = gym.make(spec)
+ env = gymnasium.make(spec)
assert has_wrapper(env, PassiveEnvChecker) is False
env.close()
# Test with overwritten spec using make disable env checker
assert spec.disable_env_checker is True
- env = gym.make(spec, disable_env_checker=False)
+ env = gymnasium.make(spec, disable_env_checker=False)
assert has_wrapper(env, PassiveEnvChecker)
env.close()
def test_apply_api_compatibility():
- gym.register(
+ gymnasium.register(
"testing-old-env",
lambda: GenericTestEnv(step_fn=old_step_fn),
apply_api_compatibility=True,
max_episode_steps=3,
)
- env = gym.make("testing-old-env")
+ env = gymnasium.make("testing-old-env")
env.reset()
assert len(env.step(env.action_space.sample())) == 5
@@ -147,11 +147,11 @@ def test_apply_api_compatibility():
_, _, termination, truncation, _ = env.step(env.action_space.sample())
assert termination is False and truncation is True
- gym.spec("testing-old-env").apply_api_compatibility = False
- env = gym.make("testing-old-env")
+ gymnasium.spec("testing-old-env").apply_api_compatibility = False
+ env = gymnasium.make("testing-old-env")
# Cannot run reset and step as will not work
- env = gym.make("testing-old-env", apply_api_compatibility=True)
+ env = gymnasium.make("testing-old-env", apply_api_compatibility=True)
env.reset()
assert len(env.step(env.action_space.sample())) == 5
@@ -159,7 +159,7 @@ def test_apply_api_compatibility():
_, _, termination, truncation, _ = env.step(env.action_space.sample())
assert termination is False and truncation is True
- gym.envs.registry.pop("testing-old-env")
+ gymnasium.envs.registry.pop("testing-old-env")
@pytest.mark.parametrize(
@@ -167,7 +167,7 @@ def test_apply_api_compatibility():
)
def test_passive_checker_wrapper_warnings(spec):
with warnings.catch_warnings(record=True) as caught_warnings:
- env = gym.make(spec) # disable_env_checker=False
+ env = gymnasium.make(spec) # disable_env_checker=False
env.reset()
env.step(env.action_space.sample())
# todo, add check for render, bugged due to mujoco v2/3 and v4 envs
@@ -176,37 +176,37 @@ def test_passive_checker_wrapper_warnings(spec):
for warning in caught_warnings:
if warning.message.args[0] not in PASSIVE_CHECK_IGNORE_WARNING:
- raise gym.error.Error(f"Unexpected warning: {warning.message}")
+ raise gymnasium.error.Error(f"Unexpected warning: {warning.message}")
def test_make_order_enforcing():
- """Checks that gym.make wrappers the environment with the OrderEnforcing wrapper."""
+ """Checks that gymnasium.make wrappers the environment with the OrderEnforcing wrapper."""
assert all(spec.order_enforce is True for spec in all_testing_env_specs)
- env = gym.make("CartPole-v1", disable_env_checker=True)
+ env = gymnasium.make("CartPole-v1", disable_env_checker=True)
assert has_wrapper(env, OrderEnforcing)
# We can assume that there all other specs will also have the order enforcing
env.close()
- gym.register(
+ gymnasium.register(
id="test.OrderlessArgumentEnv-v0",
entry_point="tests.envs.utils_envs:ArgumentEnv",
order_enforce=False,
kwargs={"arg1": None, "arg2": None, "arg3": None},
)
- env = gym.make("test.OrderlessArgumentEnv-v0", disable_env_checker=True)
+ env = gymnasium.make("test.OrderlessArgumentEnv-v0", disable_env_checker=True)
assert has_wrapper(env, OrderEnforcing) is False
env.close()
def test_make_render_mode():
- env = gym.make("CartPole-v1", disable_env_checker=True)
+ env = gymnasium.make("CartPole-v1", disable_env_checker=True)
assert env.render_mode is None
env.close()
# Make sure that render_mode is applied correctly
- env = gym.make(
+ env = gymnasium.make(
"CartPole-v1", render_mode="rgb_array_list", disable_env_checker=True
)
assert env.render_mode == "rgb_array_list"
@@ -218,24 +218,24 @@ def test_make_render_mode():
assert isinstance(renders[0], np.ndarray)
env.close()
- env = gym.make("CartPole-v1", render_mode=None, disable_env_checker=True)
+ env = gymnasium.make("CartPole-v1", render_mode=None, disable_env_checker=True)
assert env.render_mode is None
valid_render_modes = env.metadata["render_modes"]
env.close()
assert len(valid_render_modes) > 0
with warnings.catch_warnings(record=True) as caught_warnings:
- env = gym.make(
+ env = gymnasium.make(
"CartPole-v1", render_mode=valid_render_modes[0], disable_env_checker=True
)
assert env.render_mode == valid_render_modes[0]
env.close()
for warning in caught_warnings:
- raise gym.error.Error(f"Unexpected warning: {warning.message}")
+ raise gymnasium.error.Error(f"Unexpected warning: {warning.message}")
# Make sure that native rendering is used when possible
- env = gym.make("CartPole-v1", render_mode="human", disable_env_checker=True)
+ env = gymnasium.make("CartPole-v1", render_mode="human", disable_env_checker=True)
assert not has_wrapper(env, HumanRendering) # Should use native human-rendering
assert env.render_mode == "human"
env.close()
@@ -247,7 +247,7 @@ def test_make_render_mode():
),
):
# Make sure that `HumanRendering` is applied here
- env = gym.make(
+ env = gymnasium.make(
"test/NoHuman-v0", render_mode="human", disable_env_checker=True
) # This environment doesn't use native rendering
assert has_wrapper(env, HumanRendering)
@@ -257,7 +257,7 @@ def test_make_render_mode():
with pytest.raises(
TypeError, match=re.escape("got an unexpected keyword argument 'render_mode'")
):
- gym.make(
+ gymnasium.make(
"test/NoHumanOldAPI-v0",
render_mode="rgb_array_list",
disable_env_checker=True,
@@ -266,12 +266,12 @@ def test_make_render_mode():
# Make sure that an additional error is thrown a user tries to use the wrapper on an environment with old API
with warnings.catch_warnings(record=True):
with pytest.raises(
- gym.error.Error,
+ gymnasium.error.Error,
match=re.escape(
"You passed render_mode='human' although test/NoHumanOldAPI-v0 doesn't implement human-rendering natively."
),
):
- gym.make(
+ gymnasium.make(
"test/NoHumanOldAPI-v0", render_mode="human", disable_env_checker=True
)
@@ -282,11 +282,11 @@ def test_make_render_mode():
TypeError,
match=re.escape("got an unexpected keyword argument 'render'"),
):
- gym.make("CarRacing-v2", render="human")
+ gymnasium.make("CarRacing-v2", render="human")
def test_make_kwargs():
- env = gym.make(
+ env = gymnasium.make(
"test.ArgumentEnv-v0",
arg2="override_arg2",
arg3="override_arg3",
@@ -302,7 +302,7 @@ def test_make_kwargs():
def test_import_module_during_make():
# Test custom environment which is registered at make
- env = gym.make(
+ env = gymnasium.make(
"tests.envs.utils:RegisterDuringMakeEnv-v0",
disable_env_checker=True,
)
diff --git a/tests/envs/test_mujoco.py b/tests/envs/test_mujoco.py
index a10c258d9..e9888413a 100644
--- a/tests/envs/test_mujoco.py
+++ b/tests/envs/test_mujoco.py
@@ -1,9 +1,9 @@
import numpy as np
import pytest
-import gym
-from gym import envs
-from gym.envs.registration import EnvSpec
+import gymnasium
+from gymnasium import envs
+from gymnasium.envs.registration import EnvSpec
from tests.envs.utils import mujoco_testing_env_specs
EPS = 1e-6
@@ -105,7 +105,7 @@ def test_obs_space_mujoco_environments(env_spec: EnvSpec):
MUJOCO_V2_V3_ENVS = [
spec.name
for spec in mujoco_testing_env_specs
- if spec.version == 2 and f"{spec.name}-v3" in gym.envs.registry
+ if spec.version == 2 and f"{spec.name}-v3" in gymnasium.envs.registry
]
diff --git a/tests/envs/test_register.py b/tests/envs/test_register.py
index ef96c6eba..8e33e2162 100644
--- a/tests/envs/test_register.py
+++ b/tests/envs/test_register.py
@@ -1,10 +1,10 @@
-"""Tests that `gym.register` works as expected."""
+"""Tests that `gymnasium.register` works as expected."""
import re
from typing import Optional
import pytest
-import gym
+import gymnasium
@pytest.fixture(scope="function")
@@ -16,7 +16,7 @@ def register_testing_envs():
versions = [1, 3, 5]
for version in versions:
env_id = f"{namespace}/{versioned_name}-v{version}"
- gym.register(
+ gymnasium.register(
id=env_id,
entry_point="tests.envs.utils_envs:ArgumentEnv",
kwargs={
@@ -25,7 +25,7 @@ def register_testing_envs():
"arg3": "arg3",
},
)
- gym.register(
+ gymnasium.register(
id=f"{namespace}/{unversioned_name}",
entry_point="tests.env.utils_envs:ArgumentEnv",
kwargs={
@@ -39,8 +39,8 @@ def register_testing_envs():
for version in versions:
env_id = f"{namespace}/{versioned_name}-v{version}"
- del gym.envs.registry[env_id]
- del gym.envs.registry[f"{namespace}/{unversioned_name}"]
+ del gymnasium.envs.registry[env_id]
+ del gymnasium.envs.registry[f"{namespace}/{unversioned_name}"]
@pytest.mark.parametrize(
@@ -63,8 +63,8 @@ def register_testing_envs():
def test_register(
env_id: str, namespace: Optional[str], name: str, version: Optional[int]
):
- gym.register(env_id, "no-entry-point")
- assert gym.spec(env_id).id == env_id
+ gymnasium.register(env_id, "no-entry-point")
+ assert gymnasium.spec(env_id).id == env_id
full_name = f"{name}"
if namespace:
@@ -72,9 +72,9 @@ def test_register(
if version is not None:
full_name = f"{full_name}-v{version}"
- assert full_name in gym.envs.registry.keys()
+ assert full_name in gymnasium.envs.registry.keys()
- del gym.envs.registry[env_id]
+ del gymnasium.envs.registry[env_id]
@pytest.mark.parametrize(
@@ -86,8 +86,8 @@ def test_register(
],
)
def test_register_error(env_id):
- with pytest.raises(gym.error.Error, match=f"^Malformed environment ID: {env_id}"):
- gym.register(env_id, "no-entry-point")
+ with pytest.raises(gymnasium.error.Error, match=f"^Malformed environment ID: {env_id}"):
+ gymnasium.register(env_id, "no-entry-point")
@pytest.mark.parametrize(
@@ -107,9 +107,9 @@ def test_register_error(env_id):
)
def test_env_suggestions(register_testing_envs, env_id_input, env_id_suggested):
with pytest.raises(
- gym.error.UnregisteredEnv, match=f"Did you mean: `{env_id_suggested}`?"
+ gymnasium.error.UnregisteredEnv, match=f"Did you mean: `{env_id_suggested}`?"
):
- gym.make(env_id_input, disable_env_checker=True)
+ gymnasium.make(env_id_input, disable_env_checker=True)
@pytest.mark.parametrize(
@@ -128,49 +128,49 @@ def test_env_version_suggestions(
):
if default_version:
with pytest.raises(
- gym.error.DeprecatedEnv,
+ gymnasium.error.DeprecatedEnv,
match="It provides the default version", # env name,
):
- gym.make(env_id_input, disable_env_checker=True)
+ gymnasium.make(env_id_input, disable_env_checker=True)
else:
with pytest.raises(
- gym.error.UnregisteredEnv,
+ gymnasium.error.UnregisteredEnv,
match=f"It provides versioned environments: \\[ {suggested_versions} \\]",
):
- gym.make(env_id_input, disable_env_checker=True)
+ gymnasium.make(env_id_input, disable_env_checker=True)
def test_register_versioned_unversioned():
# Register versioned then unversioned
versioned_env = "Test/MyEnv-v0"
- gym.register(versioned_env, "no-entry-point")
- assert gym.envs.spec(versioned_env).id == versioned_env
+ gymnasium.register(versioned_env, "no-entry-point")
+ assert gymnasium.envs.spec(versioned_env).id == versioned_env
unversioned_env = "Test/MyEnv"
with pytest.raises(
- gym.error.RegistrationError,
+ gymnasium.error.RegistrationError,
match=re.escape(
"Can't register the unversioned environment `Test/MyEnv` when the versioned environment `Test/MyEnv-v0` of the same name already exists"
),
):
- gym.register(unversioned_env, "no-entry-point")
+ gymnasium.register(unversioned_env, "no-entry-point")
# Clean everything
- del gym.envs.registry[versioned_env]
+ del gymnasium.envs.registry[versioned_env]
# Register unversioned then versioned
- gym.register(unversioned_env, "no-entry-point")
- assert gym.envs.spec(unversioned_env).id == unversioned_env
+ gymnasium.register(unversioned_env, "no-entry-point")
+ assert gymnasium.envs.spec(unversioned_env).id == unversioned_env
with pytest.raises(
- gym.error.RegistrationError,
+ gymnasium.error.RegistrationError,
match=re.escape(
"Can't register the versioned environment `Test/MyEnv-v0` when the unversioned environment `Test/MyEnv` of the same name already exists."
),
):
- gym.register(versioned_env, "no-entry-point")
+ gymnasium.register(versioned_env, "no-entry-point")
# Clean everything
- del gym.envs.registry[unversioned_env]
+ del gymnasium.envs.registry[unversioned_env]
def test_make_latest_versioned_env(register_testing_envs):
@@ -180,7 +180,7 @@ def test_make_latest_versioned_env(register_testing_envs):
"Using the latest versioned environment `MyAwesomeNamespace/MyAwesomeVersionedEnv-v5` instead of the unversioned environment `MyAwesomeNamespace/MyAwesomeVersionedEnv`."
),
):
- env = gym.make(
+ env = gymnasium.make(
"MyAwesomeNamespace/MyAwesomeVersionedEnv", disable_env_checker=True
)
assert env.spec.id == "MyAwesomeNamespace/MyAwesomeVersionedEnv-v5"
@@ -188,11 +188,11 @@ def test_make_latest_versioned_env(register_testing_envs):
def test_namespace():
# Check if the namespace context manager works
- with gym.envs.registration.namespace("MyDefaultNamespace"):
- gym.register("MyDefaultEnvironment-v0", "no-entry-point")
- gym.register("MyDefaultEnvironment-v1", "no-entry-point")
- assert "MyDefaultNamespace/MyDefaultEnvironment-v0" in gym.envs.registry
- assert "MyDefaultEnvironment-v1" in gym.envs.registry
-
- del gym.envs.registry["MyDefaultNamespace/MyDefaultEnvironment-v0"]
- del gym.envs.registry["MyDefaultEnvironment-v1"]
+ with gymnasium.envs.registration.namespace("MyDefaultNamespace"):
+ gymnasium.register("MyDefaultEnvironment-v0", "no-entry-point")
+ gymnasium.register("MyDefaultEnvironment-v1", "no-entry-point")
+ assert "MyDefaultNamespace/MyDefaultEnvironment-v0" in gymnasium.envs.registry
+ assert "MyDefaultEnvironment-v1" in gymnasium.envs.registry
+
+ del gymnasium.envs.registry["MyDefaultNamespace/MyDefaultEnvironment-v0"]
+ del gymnasium.envs.registry["MyDefaultEnvironment-v1"]
diff --git a/tests/envs/test_spec.py b/tests/envs/test_spec.py
index 78e7d801e..1eec91ef4 100644
--- a/tests/envs/test_spec.py
+++ b/tests/envs/test_spec.py
@@ -1,92 +1,92 @@
-"""Tests that gym.spec works as expected."""
+"""Tests that gymnasium.spec works as expected."""
import re
import pytest
-import gym
+import gymnasium
def test_spec():
- spec = gym.spec("CartPole-v1")
+ spec = gymnasium.spec("CartPole-v1")
assert spec.id == "CartPole-v1"
- assert spec is gym.envs.registry["CartPole-v1"]
+ assert spec is gymnasium.envs.registry["CartPole-v1"]
def test_spec_kwargs():
map_name_value = "8x8"
- env = gym.make("FrozenLake-v1", map_name=map_name_value)
+ env = gymnasium.make("FrozenLake-v1", map_name=map_name_value)
assert env.spec.kwargs["map_name"] == map_name_value
def test_spec_missing_lookup():
- gym.register(id="Test1-v0", entry_point="no-entry-point")
- gym.register(id="Test1-v15", entry_point="no-entry-point")
- gym.register(id="Test1-v9", entry_point="no-entry-point")
- gym.register(id="Other1-v100", entry_point="no-entry-point")
+ gymnasium.register(id="Test1-v0", entry_point="no-entry-point")
+ gymnasium.register(id="Test1-v15", entry_point="no-entry-point")
+ gymnasium.register(id="Test1-v9", entry_point="no-entry-point")
+ gymnasium.register(id="Other1-v100", entry_point="no-entry-point")
with pytest.raises(
- gym.error.DeprecatedEnv,
+ gymnasium.error.DeprecatedEnv,
match=re.escape(
"Environment version v1 for `Test1` is deprecated. Please use `Test1-v15` instead."
),
):
- gym.spec("Test1-v1")
+ gymnasium.spec("Test1-v1")
with pytest.raises(
- gym.error.UnregisteredEnv,
+ gymnasium.error.UnregisteredEnv,
match=re.escape(
"Environment version `v1000` for environment `Test1` doesn't exist. It provides versioned environments: [ `v0`, `v9`, `v15` ]."
),
):
- gym.spec("Test1-v1000")
+ gymnasium.spec("Test1-v1000")
with pytest.raises(
- gym.error.UnregisteredEnv,
+ gymnasium.error.UnregisteredEnv,
match=re.escape("Environment Unknown1 doesn't exist. "),
):
- gym.spec("Unknown1-v1")
+ gymnasium.spec("Unknown1-v1")
def test_spec_malformed_lookup():
with pytest.raises(
- gym.error.Error,
+ gymnasium.error.Error,
match=f'^{re.escape("Malformed environment ID: “Breakout-v0”.(Currently all IDs must be of the form [namespace/](env-name)-v(version). (namespace is optional))")}$',
):
- gym.spec("“Breakout-v0”")
+ gymnasium.spec("“Breakout-v0”")
def test_spec_versioned_lookups():
- gym.register("test/Test2-v5", "no-entry-point")
+ gymnasium.register("test/Test2-v5", "no-entry-point")
with pytest.raises(
- gym.error.VersionNotFound,
+ gymnasium.error.VersionNotFound,
match=re.escape(
"Environment version `v9` for environment `test/Test2` doesn't exist. It provides versioned environments: [ `v5` ]."
),
):
- gym.spec("test/Test2-v9")
+ gymnasium.spec("test/Test2-v9")
with pytest.raises(
- gym.error.DeprecatedEnv,
+ gymnasium.error.DeprecatedEnv,
match=re.escape(
"Environment version v4 for `test/Test2` is deprecated. Please use `test/Test2-v5` instead."
),
):
- gym.spec("test/Test2-v4")
+ gymnasium.spec("test/Test2-v4")
- assert gym.spec("test/Test2-v5") is not None
+ assert gymnasium.spec("test/Test2-v5") is not None
def test_spec_default_lookups():
- gym.register("test/Test3", "no-entry-point")
+ gymnasium.register("test/Test3", "no-entry-point")
with pytest.raises(
- gym.error.DeprecatedEnv,
+ gymnasium.error.DeprecatedEnv,
match=re.escape(
"Environment version `v0` for environment `test/Test3` doesn't exist. It provides the default version test/Test3`."
),
):
- gym.spec("test/Test3-v0")
+ gymnasium.spec("test/Test3-v0")
- assert gym.spec("test/Test3") is not None
+ assert gymnasium.spec("test/Test3") is not None
diff --git a/tests/envs/utils.py b/tests/envs/utils.py
index 2790fe1d0..c6354a258 100644
--- a/tests/envs/utils.py
+++ b/tests/envs/utils.py
@@ -3,18 +3,18 @@
import numpy as np
-import gym
-from gym import logger
-from gym.envs.registration import EnvSpec
+import gymnasium
+from gymnasium import logger
+from gymnasium.envs.registration import EnvSpec
-def try_make_env(env_spec: EnvSpec) -> Optional[gym.Env]:
+def try_make_env(env_spec: EnvSpec) -> Optional[gymnasium.Env]:
"""Tries to make the environment showing if it is possible.
Warning the environments have no wrappers, including time limit and order enforcing.
"""
- # To avoid issues with registered environments during testing, we check that the spec entry points are from gym.envs.
- if "gym.envs." in env_spec.entry_point:
+ # To avoid issues with registered environments during testing, we check that the spec entry points are from gymnasium.envs.
+ if "gymnasium.envs." in env_spec.entry_point:
try:
return env_spec.make(disable_env_checker=True).unwrapped
except ImportError as e:
@@ -23,27 +23,27 @@ def try_make_env(env_spec: EnvSpec) -> Optional[gym.Env]:
# Tries to make all environment to test with
-all_testing_initialised_envs: List[Optional[gym.Env]] = [
- try_make_env(env_spec) for env_spec in gym.envs.registry.values()
+all_testing_initialised_envs: List[Optional[gymnasium.Env]] = [
+ try_make_env(env_spec) for env_spec in gymnasium.envs.registry.values()
]
-all_testing_initialised_envs: List[gym.Env] = [
+all_testing_initialised_envs: List[gymnasium.Env] = [
env for env in all_testing_initialised_envs if env is not None
]
-# All testing, mujoco and gym environment specs
+# All testing, mujoco and gymnasium environment specs
all_testing_env_specs: List[EnvSpec] = [
env.spec for env in all_testing_initialised_envs
]
mujoco_testing_env_specs: List[EnvSpec] = [
env_spec
for env_spec in all_testing_env_specs
- if "gym.envs.mujoco" in env_spec.entry_point
+ if "gymnasium.envs.mujoco" in env_spec.entry_point
]
gym_testing_env_specs: List[EnvSpec] = [
env_spec
for env_spec in all_testing_env_specs
if any(
- f"gym.envs.{ep}" in env_spec.entry_point
+ f"gymnasium.envs.{ep}" in env_spec.entry_point
for ep in ["box2d", "classic_control", "toy_text"]
)
]
diff --git a/tests/envs/utils_envs.py b/tests/envs/utils_envs.py
index 8282f9216..a1b319889 100644
--- a/tests/envs/utils_envs.py
+++ b/tests/envs/utils_envs.py
@@ -1,17 +1,17 @@
-import gym
+import gymnasium
-class RegisterDuringMakeEnv(gym.Env):
+class RegisterDuringMakeEnv(gymnasium.Env):
"""Used in `test_registration.py` to check if `env.make` can import and register an env"""
def __init__(self):
- self.action_space = gym.spaces.Discrete(1)
- self.observation_space = gym.spaces.Discrete(1)
+ self.action_space = gymnasium.spaces.Discrete(1)
+ self.observation_space = gymnasium.spaces.Discrete(1)
-class ArgumentEnv(gym.Env):
- observation_space = gym.spaces.Box(low=-1, high=1, shape=(1,))
- action_space = gym.spaces.Box(low=-1, high=1, shape=(1,))
+class ArgumentEnv(gymnasium.Env):
+ observation_space = gymnasium.spaces.Box(low=-1, high=1, shape=(1,))
+ action_space = gymnasium.spaces.Box(low=-1, high=1, shape=(1,))
def __init__(self, arg1, arg2, arg3):
self.arg1 = arg1
@@ -20,7 +20,7 @@ def __init__(self, arg1, arg2, arg3):
# Environments to test render_mode
-class NoHuman(gym.Env):
+class NoHuman(gymnasium.Env):
"""Environment that does not have human-rendering."""
metadata = {"render_modes": ["rgb_array_list"], "render_fps": 4}
@@ -30,7 +30,7 @@ def __init__(self, render_mode=None):
self.render_mode = render_mode
-class NoHumanOldAPI(gym.Env):
+class NoHumanOldAPI(gymnasium.Env):
"""Environment that does not have human-rendering."""
metadata = {"render_modes": ["rgb_array_list"], "render_fps": 4}
@@ -39,7 +39,7 @@ def __init__(self):
pass
-class NoHumanNoRGB(gym.Env):
+class NoHumanNoRGB(gymnasium.Env):
"""Environment that has neither human- nor rgb-rendering"""
metadata = {"render_modes": ["ascii"], "render_fps": 4}
diff --git a/tests/spaces/test_box.py b/tests/spaces/test_box.py
index f7dc47f8d..132b6f8b4 100644
--- a/tests/spaces/test_box.py
+++ b/tests/spaces/test_box.py
@@ -4,9 +4,9 @@
import numpy as np
import pytest
-import gym.error
-from gym.spaces import Box
-from gym.spaces.box import get_inf
+import gymnasium.error
+from gymnasium.spaces import Box
+from gymnasium.spaces.box import get_inf
@pytest.mark.parametrize(
@@ -310,7 +310,7 @@ def test_sample_mask():
"""Box cannot have a mask applied."""
space = Box(0, 1)
with pytest.raises(
- gym.error.Error,
+ gymnasium.error.Error,
match=re.escape("Box.sample cannot be provided a mask, actual value: "),
):
space.sample(mask=np.array([0, 1, 0], dtype=np.int8))
diff --git a/tests/spaces/test_dict.py b/tests/spaces/test_dict.py
index aab2c7f39..c97b1c955 100644
--- a/tests/spaces/test_dict.py
+++ b/tests/spaces/test_dict.py
@@ -3,7 +3,7 @@
import numpy as np
import pytest
-from gym.spaces import Box, Dict, Discrete
+from gymnasium.spaces import Box, Dict, Discrete
def test_dict_init():
@@ -125,7 +125,7 @@ def test_mapping():
with pytest.raises(
AssertionError,
- match="Trying to set a to Dict space with value that is not a gym space, actual type: ",
+ match="Trying to set a to Dict space with value that is not a gymnasium space, actual type: ",
):
DICT_SPACE["a"] = 5
diff --git a/tests/spaces/test_discrete.py b/tests/spaces/test_discrete.py
index 19639f433..13bb20e94 100644
--- a/tests/spaces/test_discrete.py
+++ b/tests/spaces/test_discrete.py
@@ -1,6 +1,6 @@
import numpy as np
-from gym.spaces import Discrete
+from gymnasium.spaces import Discrete
def test_space_legacy_pickling():
diff --git a/tests/spaces/test_graph.py b/tests/spaces/test_graph.py
index e964a0a0c..f35d7c54e 100644
--- a/tests/spaces/test_graph.py
+++ b/tests/spaces/test_graph.py
@@ -3,7 +3,7 @@
import numpy as np
import pytest
-from gym.spaces import Discrete, Graph, GraphInstance
+from gymnasium.spaces import Discrete, Graph, GraphInstance
def test_node_space_sample():
diff --git a/tests/spaces/test_multibinary.py b/tests/spaces/test_multibinary.py
index 113b16929..a3b1f9e3e 100644
--- a/tests/spaces/test_multibinary.py
+++ b/tests/spaces/test_multibinary.py
@@ -1,6 +1,6 @@
import numpy as np
-from gym.spaces import MultiBinary
+from gymnasium.spaces import MultiBinary
def test_sample():
diff --git a/tests/spaces/test_multidiscrete.py b/tests/spaces/test_multidiscrete.py
index 2ba098474..f7ac862f1 100644
--- a/tests/spaces/test_multidiscrete.py
+++ b/tests/spaces/test_multidiscrete.py
@@ -1,7 +1,7 @@
import pytest
-from gym.spaces import Discrete, MultiDiscrete
-from gym.utils.env_checker import data_equivalence
+from gymnasium.spaces import Discrete, MultiDiscrete
+from gymnasium.utils.env_checker import data_equivalence
def test_multidiscrete_as_tuple():
diff --git a/tests/spaces/test_sequence.py b/tests/spaces/test_sequence.py
index 33ae33ca2..77fc235ac 100644
--- a/tests/spaces/test_sequence.py
+++ b/tests/spaces/test_sequence.py
@@ -3,12 +3,12 @@
import numpy as np
import pytest
-import gym.spaces
+import gymnasium.spaces
def test_sample():
"""Tests the sequence sampling works as expects and the errors are correctly raised."""
- space = gym.spaces.Sequence(gym.spaces.Box(0, 1))
+ space = gymnasium.spaces.Sequence(gymnasium.spaces.Box(0, 1))
# Test integer mask length
for length in range(4):
diff --git a/tests/spaces/test_space.py b/tests/spaces/test_space.py
index 1436ea72a..5e8583c40 100644
--- a/tests/spaces/test_space.py
+++ b/tests/spaces/test_space.py
@@ -2,8 +2,8 @@
import pytest
-from gym import Space
-from gym.spaces import utils
+from gymnasium import Space
+from gymnasium.spaces import utils
TESTING_SPACE = Space()
diff --git a/tests/spaces/test_spaces.py b/tests/spaces/test_spaces.py
index fac48ebb4..35bed34b2 100644
--- a/tests/spaces/test_spaces.py
+++ b/tests/spaces/test_spaces.py
@@ -8,9 +8,9 @@
import numpy as np
import pytest
-from gym.spaces import Box, Discrete, MultiBinary, MultiDiscrete, Space, Text
-from gym.utils import seeding
-from gym.utils.env_checker import data_equivalence
+from gymnasium.spaces import Box, Discrete, MultiBinary, MultiDiscrete, Space, Text
+from gymnasium.utils import seeding
+from gymnasium.utils.env_checker import data_equivalence
from tests.spaces.utils import (
TESTING_FUNDAMENTAL_SPACES,
TESTING_FUNDAMENTAL_SPACES_IDS,
diff --git a/tests/spaces/test_text.py b/tests/spaces/test_text.py
index bb21a2521..7b22a5f9e 100644
--- a/tests/spaces/test_text.py
+++ b/tests/spaces/test_text.py
@@ -3,7 +3,7 @@
import numpy as np
import pytest
-from gym.spaces import Text
+from gymnasium.spaces import Text
def test_sample_mask():
diff --git a/tests/spaces/test_tuple.py b/tests/spaces/test_tuple.py
index e56a7b443..6283d353b 100644
--- a/tests/spaces/test_tuple.py
+++ b/tests/spaces/test_tuple.py
@@ -1,13 +1,13 @@
import numpy as np
import pytest
-import gym.spaces
-from gym.spaces import Box, Dict, Discrete, MultiBinary, Tuple
-from gym.utils.env_checker import data_equivalence
+import gymnasium.spaces
+from gymnasium.spaces import Box, Dict, Discrete, MultiBinary, Tuple
+from gymnasium.utils.env_checker import data_equivalence
def test_sequence_inheritance():
- """The gym Tuple space inherits from abc.Sequences, this test checks all functions work"""
+ """The gymnasium Tuple space inherits from abc.Sequences, this test checks all functions work"""
spaces = [Discrete(5), Discrete(10), Discrete(5)]
tuple_space = Tuple(spaces)
@@ -79,7 +79,7 @@ def test_seeds(space, seed, expected_len):
"space_fn",
[
lambda: Tuple(["abc"]),
- lambda: Tuple([gym.spaces.Box(0, 1), "abc"]),
+ lambda: Tuple([gymnasium.spaces.Box(0, 1), "abc"]),
lambda: Tuple("abc"),
],
)
@@ -89,19 +89,19 @@ def test_bad_space_calls(space_fn):
def test_contains_promotion():
- space = gym.spaces.Tuple((gym.spaces.Box(0, 1), gym.spaces.Box(-1, 0, (2,))))
+ space = gymnasium.spaces.Tuple((gymnasium.spaces.Box(0, 1), gymnasium.spaces.Box(-1, 0, (2,))))
assert (
np.array([0.0], dtype=np.float32),
np.array([0.0, 0.0], dtype=np.float32),
) in space
- space = gym.spaces.Tuple((gym.spaces.Box(0, 1), gym.spaces.Box(-1, 0, (1,))))
+ space = gymnasium.spaces.Tuple((gymnasium.spaces.Box(0, 1), gymnasium.spaces.Box(-1, 0, (1,))))
assert np.array([[0.0], [0.0]], dtype=np.float32) in space
def test_bad_seed():
- space = gym.spaces.Tuple((gym.spaces.Box(0, 1), gym.spaces.Box(0, 1)))
+ space = gymnasium.spaces.Tuple((gymnasium.spaces.Box(0, 1), gymnasium.spaces.Box(0, 1)))
with pytest.raises(
TypeError,
match="Expected seed type: list, tuple, int or None, actual type: ",
diff --git a/tests/spaces/test_utils.py b/tests/spaces/test_utils.py
index 1ef689350..ca61dcc34 100644
--- a/tests/spaces/test_utils.py
+++ b/tests/spaces/test_utils.py
@@ -4,9 +4,9 @@
import numpy as np
import pytest
-import gym
-from gym.spaces import Box, Graph, utils
-from gym.utils.env_checker import data_equivalence
+import gymnasium
+from gymnasium.spaces import Box, Graph, utils
+from gymnasium.utils.env_checker import data_equivalence
from tests.spaces.utils import TESTING_SPACES, TESTING_SPACES_IDS
TESTING_SPACES_EXPECTED_FLATDIMS = [
@@ -56,7 +56,7 @@
zip_longest(TESTING_SPACES, TESTING_SPACES_EXPECTED_FLATDIMS),
ids=TESTING_SPACES_IDS,
)
-def test_flatdim(space: gym.spaces.Space, flatdim: Optional[int]):
+def test_flatdim(space: gymnasium.spaces.Space, flatdim: Optional[int]):
"""Checks that the flattened dims of the space is equal to an expected value."""
if space.is_np_flattenable:
dim = utils.flatdim(space)
@@ -92,7 +92,7 @@ def test_flatten_space(space):
assert edge_single_dim == edge_flatdim
else:
assert isinstance(
- space, (gym.spaces.Tuple, gym.spaces.Dict, gym.spaces.Sequence)
+ space, (gymnasium.spaces.Tuple, gymnasium.spaces.Dict, gymnasium.spaces.Sequence)
)
diff --git a/tests/spaces/utils.py b/tests/spaces/utils.py
index d93a88d6f..79c7148ca 100644
--- a/tests/spaces/utils.py
+++ b/tests/spaces/utils.py
@@ -2,7 +2,7 @@
import numpy as np
-from gym.spaces import (
+from gymnasium.spaces import (
Box,
Dict,
Discrete,
diff --git a/tests/test_core.py b/tests/test_core.py
index 439f4e151..cc56049bb 100644
--- a/tests/test_core.py
+++ b/tests/test_core.py
@@ -3,8 +3,8 @@
import numpy as np
import pytest
-from gym import core, spaces
-from gym.wrappers import OrderEnforcing, TimeLimit
+from gymnasium import core, spaces
+from gymnasium.wrappers import OrderEnforcing, TimeLimit
class ArgumentEnv(core.Env):
diff --git a/tests/testing_env.py b/tests/testing_env.py
index 64ab691ed..9281d74e4 100644
--- a/tests/testing_env.py
+++ b/tests/testing_env.py
@@ -2,10 +2,10 @@
import types
from typing import Any, Dict, Optional, Tuple, Union
-import gym
-from gym import spaces
-from gym.core import ActType, ObsType
-from gym.envs.registration import EnvSpec
+import gymnasium
+from gymnasium import spaces
+from gymnasium.core import ActType, ObsType
+from gymnasium.envs.registration import EnvSpec
def basic_reset_fn(
@@ -36,7 +36,7 @@ def basic_render_fn(self):
# todo: change all testing environment to this generic class
-class GenericTestEnv(gym.Env):
+class GenericTestEnv(gymnasium.Env):
"""A generic testing environment for use in testing with modified environments are required."""
def __init__(
diff --git a/tests/utils/test_env_checker.py b/tests/utils/test_env_checker.py
index 210af5244..8ae2d490c 100644
--- a/tests/utils/test_env_checker.py
+++ b/tests/utils/test_env_checker.py
@@ -6,10 +6,10 @@
import numpy as np
import pytest
-import gym
-from gym import spaces
-from gym.core import ObsType
-from gym.utils.env_checker import (
+import gymnasium
+from gymnasium import spaces
+from gymnasium.core import ObsType
+from gymnasium.utils.env_checker import (
check_env,
check_reset_options,
check_reset_return_info_deprecation,
@@ -23,8 +23,8 @@
@pytest.mark.parametrize(
"env",
[
- gym.make("CartPole-v1", disable_env_checker=True).unwrapped,
- gym.make("MountainCar-v0", disable_env_checker=True).unwrapped,
+ gymnasium.make("CartPole-v1", disable_env_checker=True).unwrapped,
+ gymnasium.make("MountainCar-v0", disable_env_checker=True).unwrapped,
GenericTestEnv(
observation_space=spaces.Dict(
a=spaces.Discrete(10), b=spaces.Box(np.zeros(2), np.ones(2))
@@ -46,7 +46,7 @@
],
)
def test_no_error_warnings(env):
- """A full version of this test with all gym envs is run in tests/envs/test_envs.py."""
+ """A full version of this test with all gymnasium envs is run in tests/envs/test_envs.py."""
with warnings.catch_warnings(record=True) as caught_warnings:
check_env(env)
@@ -80,7 +80,7 @@ def _reset_default_seed(self: GenericTestEnv, seed="Error", options=None):
"test,func,message",
[
[
- gym.error.Error,
+ gymnasium.error.Error,
lambda self: (self.observation_space.sample(), {}),
"The `reset` method does not provide a `seed` or `**kwargs` keyword argument.",
],
@@ -204,7 +204,7 @@ def test_check_reset_return_info_deprecation(test, func: callable, message: str)
def test_check_seed_deprecation():
"""Tests that `check_seed_deprecation()` throws a warning if `env.seed()` has not been removed."""
- message = """Official support for the `seed` function is dropped. Standard practice is to reset gym environments using `env.reset(seed=)`"""
+ message = """Official support for the `seed` function is dropped. Standard practice is to reset gymnasium environments using `env.reset(seed=)`"""
env = GenericTestEnv()
@@ -231,7 +231,7 @@ def seed(seed):
def test_check_reset_options():
"""Tests the check_reset_options function."""
with pytest.raises(
- gym.error.Error,
+ gymnasium.error.Error,
match=re.escape(
"The `reset` method does not provide an `options` or `**kwargs` keyword argument"
),
@@ -244,7 +244,7 @@ def test_check_reset_options():
[
[
"Error",
- "The environment must inherit from the gym.Env class. See https://www.gymlibrary.dev/content/environment_creation/ for more info.",
+ "The environment must inherit from the gymnasium.Env class. See https://www.gymlibrary.dev/content/environment_creation/ for more info.",
],
[
GenericTestEnv(action_space=None),
@@ -256,7 +256,7 @@ def test_check_reset_options():
],
],
)
-def test_check_env(env: gym.Env, message: str):
+def test_check_env(env: gymnasium.Env, message: str):
"""Tests the check_env function works as expected."""
with pytest.raises(AssertionError, match=f"^{re.escape(message)}$"):
check_env(env)
diff --git a/tests/utils/test_passive_env_checker.py b/tests/utils/test_passive_env_checker.py
index c6cdc7d89..9749e5703 100644
--- a/tests/utils/test_passive_env_checker.py
+++ b/tests/utils/test_passive_env_checker.py
@@ -5,9 +5,9 @@
import numpy as np
import pytest
-import gym
-from gym import spaces
-from gym.utils.passive_env_checker import (
+import gymnasium
+from gymnasium import spaces
+from gymnasium.utils.passive_env_checker import (
check_action_space,
check_obs,
check_observation_space,
@@ -29,7 +29,7 @@ def _modify_space(space: spaces.Space, attribute: str, value):
[
AssertionError,
"error",
- "observation space does not inherit from `gym.spaces.Space`, actual type: ",
+ "observation space does not inherit from `gymnasium.spaces.Space`, actual type: ",
],
# ===== Check box observation space ====
[
@@ -125,7 +125,7 @@ def test_check_observation_space(test, space, message: str):
[
AssertionError,
"error",
- "action space does not inherit from `gym.spaces.Space`, actual type: ",
+ "action space does not inherit from `gymnasium.spaces.Space`, actual type: ",
],
# ===== Check box observation space ====
[
@@ -268,7 +268,7 @@ def _reset_result(self, seed=None, options=None):
[
UserWarning,
_reset_no_seed,
- "Future gym versions will require that `Env.reset` can be passed a `seed` instead of using `Env.seed` for resetting the environment random number generator.",
+ "Future gymnasium versions will require that `Env.reset` can be passed a `seed` instead of using `Env.seed` for resetting the environment random number generator.",
{},
],
[
@@ -280,7 +280,7 @@ def _reset_result(self, seed=None, options=None):
[
UserWarning,
_reset_no_option,
- "Future gym versions will require that `Env.reset` can be passed `options` to allow the environment initialisation to be passed additional information.",
+ "Future gymnasium versions will require that `Env.reset` can be passed `options` to allow the environment initialisation to be passed additional information.",
{},
],
[
@@ -349,7 +349,7 @@ def _modified_step(
"Expects `truncated` signal to be a boolean, actual type: ",
],
[
- gym.error.Error,
+ gymnasium.error.Error,
lambda self, _: (1, 2, 3),
"Expected `Env.step` to return a four or five element tuple, actual number of elements returned: 3.",
],
diff --git a/tests/utils/test_play.py b/tests/utils/test_play.py
index 671625090..dbe08abbb 100644
--- a/tests/utils/test_play.py
+++ b/tests/utils/test_play.py
@@ -8,8 +8,8 @@
from pygame import KEYDOWN, KEYUP, QUIT, event
from pygame.event import Event
-import gym
-from gym.utils.play import MissingKeysToAction, PlayableGame, play
+import gymnasium
+from gymnasium.utils.play import MissingKeysToAction, PlayableGame, play
from tests.testing_env import GenericTestEnv
RELEVANT_KEY_1 = ord("a") # 97
@@ -24,7 +24,7 @@
)
-class KeysToActionWrapper(gym.Wrapper):
+class KeysToActionWrapper(gymnasium.Wrapper):
def __init__(self, env, keys_to_action):
super().__init__(env)
self.keys_to_action = keys_to_action
@@ -175,7 +175,7 @@ def callback(obs_t, obs_tp1, action, rew, terminated, truncated, info):
return obs_t, obs_tp1, action, rew, terminated, truncated, info
- env = gym.make(ENV, render_mode="rgb_array", disable_env_checker=True)
+ env = gymnasium.make(ENV, render_mode="rgb_array", disable_env_checker=True)
env.reset(seed=SEED)
keys_to_action = (
dummy_keys_to_action_str() if str_keys else dummy_keys_to_action()
@@ -188,7 +188,7 @@ def callback(obs_t, obs_tp1, action, rew, terminated, truncated, info):
action = keys_to_action[chr(e.key) if str_keys else (e.key,)]
obs, _, _, _, _ = env.step(action)
- env_play = gym.make(ENV, render_mode="rgb_array", disable_env_checker=True)
+ env_play = gymnasium.make(ENV, render_mode="rgb_array", disable_env_checker=True)
if apply_wrapper:
env_play = KeysToActionWrapper(env, keys_to_action=keys_to_action)
assert hasattr(env_play, "get_keys_to_action")
@@ -206,4 +206,4 @@ def callback(obs_t, obs_tp1, action, rew, terminated, truncated, info):
def test_play_no_keys():
with pytest.raises(MissingKeysToAction):
- play(gym.make("CartPole-v1"))
+ play(gymnasium.make("CartPole-v1"))
diff --git a/tests/utils/test_save_video.py b/tests/utils/test_save_video.py
index 2af374840..1852b008f 100644
--- a/tests/utils/test_save_video.py
+++ b/tests/utils/test_save_video.py
@@ -3,12 +3,12 @@
import numpy as np
-import gym
-from gym.utils.save_video import capped_cubic_video_schedule, save_video
+import gymnasium
+from gymnasium.utils.save_video import capped_cubic_video_schedule, save_video
def test_record_video_using_default_trigger():
- env = gym.make(
+ env = gymnasium.make(
"CartPole-v1", render_mode="rgb_array_list", disable_env_checker=True
)
@@ -47,7 +47,7 @@ def step_trigger(step_index):
def test_record_video_step_trigger():
- env = gym.make("CartPole-v1", render_mode="rgb_array_list")
+ env = gymnasium.make("CartPole-v1", render_mode="rgb_array_list")
env._max_episode_steps = 20
env.reset()
@@ -81,7 +81,7 @@ def test_record_video_within_vector():
n_steps = 199
expected_video = 2
- envs = gym.vector.make(
+ envs = gymnasium.vector.make(
"CartPole-v1", num_envs=2, asynchronous=True, render_mode="rgb_array_list"
)
envs.reset()
diff --git a/tests/utils/test_seeding.py b/tests/utils/test_seeding.py
index 0aa59fdf8..c7155e3a3 100644
--- a/tests/utils/test_seeding.py
+++ b/tests/utils/test_seeding.py
@@ -1,7 +1,7 @@
import pickle
-from gym import error
-from gym.utils import seeding
+from gymnasium import error
+from gymnasium.utils import seeding
def test_invalid_seeds():
diff --git a/tests/utils/test_step_api_compatibility.py b/tests/utils/test_step_api_compatibility.py
index a3b4ea343..145b71243 100644
--- a/tests/utils/test_step_api_compatibility.py
+++ b/tests/utils/test_step_api_compatibility.py
@@ -1,8 +1,8 @@
import numpy as np
import pytest
-from gym.utils.env_checker import data_equivalence
-from gym.utils.step_api_compatibility import (
+from gymnasium.utils.env_checker import data_equivalence
+from gymnasium.utils.step_api_compatibility import (
convert_to_done_step_api,
convert_to_terminated_truncated_step_api,
)
diff --git a/tests/vector/test_async_vector_env.py b/tests/vector/test_async_vector_env.py
index efe9be3f0..01cff05d8 100644
--- a/tests/vector/test_async_vector_env.py
+++ b/tests/vector/test_async_vector_env.py
@@ -4,9 +4,9 @@
import numpy as np
import pytest
-from gym.error import AlreadyPendingCallError, ClosedEnvironmentError, NoAsyncCallError
-from gym.spaces import Box, Discrete, MultiDiscrete, Tuple
-from gym.vector.async_vector_env import AsyncVectorEnv
+from gymnasium.error import AlreadyPendingCallError, ClosedEnvironmentError, NoAsyncCallError
+from gymnasium.spaces import Box, Discrete, MultiDiscrete, Tuple
+from gymnasium.vector.async_vector_env import AsyncVectorEnv
from tests.vector.utils import (
CustomSpace,
make_custom_space_env,
diff --git a/tests/vector/test_numpy_utils.py b/tests/vector/test_numpy_utils.py
index f8bdf8512..26e6ad232 100644
--- a/tests/vector/test_numpy_utils.py
+++ b/tests/vector/test_numpy_utils.py
@@ -3,9 +3,9 @@
import numpy as np
import pytest
-from gym.spaces import Dict, Tuple
-from gym.vector.utils.numpy_utils import concatenate, create_empty_array
-from gym.vector.utils.spaces import BaseGymSpaces
+from gymnasium.spaces import Dict, Tuple
+from gymnasium.vector.utils.numpy_utils import concatenate, create_empty_array
+from gymnasium.vector.utils.spaces import BaseGymSpaces
from tests.vector.utils import spaces
diff --git a/tests/vector/test_shared_memory.py b/tests/vector/test_shared_memory.py
index 7395b5905..039e33166 100644
--- a/tests/vector/test_shared_memory.py
+++ b/tests/vector/test_shared_memory.py
@@ -6,14 +6,14 @@
import numpy as np
import pytest
-from gym.error import CustomSpaceError
-from gym.spaces import Dict, Tuple
-from gym.vector.utils.shared_memory import (
+from gymnasium.error import CustomSpaceError
+from gymnasium.spaces import Dict, Tuple
+from gymnasium.vector.utils.shared_memory import (
create_shared_memory,
read_from_shared_memory,
write_to_shared_memory,
)
-from gym.vector.utils.spaces import BaseGymSpaces
+from gymnasium.vector.utils.spaces import BaseGymSpaces
from tests.vector.utils import custom_spaces, spaces
expected_types = [
diff --git a/tests/vector/test_spaces.py b/tests/vector/test_spaces.py
index ac18dbb0f..f74435164 100644
--- a/tests/vector/test_spaces.py
+++ b/tests/vector/test_spaces.py
@@ -4,8 +4,8 @@
import pytest
from numpy.testing import assert_array_equal
-from gym.spaces import Box, Dict, MultiDiscrete, Space, Tuple
-from gym.vector.utils.spaces import batch_space, iterate
+from gymnasium.spaces import Box, Dict, MultiDiscrete, Space, Tuple
+from gymnasium.vector.utils.spaces import batch_space, iterate
from tests.vector.utils import CustomSpace, assert_rng_equal, custom_spaces, spaces
expected_batch_spaces_4 = [
diff --git a/tests/vector/test_sync_vector_env.py b/tests/vector/test_sync_vector_env.py
index d18faf97b..881f42722 100644
--- a/tests/vector/test_sync_vector_env.py
+++ b/tests/vector/test_sync_vector_env.py
@@ -1,9 +1,9 @@
import numpy as np
import pytest
-from gym.envs.registration import EnvSpec
-from gym.spaces import Box, Discrete, MultiDiscrete, Tuple
-from gym.vector.sync_vector_env import SyncVectorEnv
+from gymnasium.envs.registration import EnvSpec
+from gymnasium.spaces import Box, Discrete, MultiDiscrete, Tuple
+from gymnasium.vector.sync_vector_env import SyncVectorEnv
from tests.envs.utils import all_testing_env_specs
from tests.vector.utils import (
CustomSpace,
diff --git a/tests/vector/test_vector_env.py b/tests/vector/test_vector_env.py
index 92c2233bf..ac3ef2d2c 100644
--- a/tests/vector/test_vector_env.py
+++ b/tests/vector/test_vector_env.py
@@ -1,10 +1,10 @@
import numpy as np
import pytest
-from gym.spaces import Tuple
-from gym.vector.async_vector_env import AsyncVectorEnv
-from gym.vector.sync_vector_env import SyncVectorEnv
-from gym.vector.vector_env import VectorEnv
+from gymnasium.spaces import Tuple
+from gymnasium.vector.async_vector_env import AsyncVectorEnv
+from gymnasium.vector.sync_vector_env import SyncVectorEnv
+from gymnasium.vector.vector_env import VectorEnv
from tests.vector.utils import CustomSpace, make_env
diff --git a/tests/vector/test_vector_env_info.py b/tests/vector/test_vector_env_info.py
index 989673e5a..73a0401f9 100644
--- a/tests/vector/test_vector_env_info.py
+++ b/tests/vector/test_vector_env_info.py
@@ -1,8 +1,8 @@
import numpy as np
import pytest
-import gym
-from gym.vector.sync_vector_env import SyncVectorEnv
+import gymnasium
+from gymnasium.vector.sync_vector_env import SyncVectorEnv
from tests.vector.utils import make_env
ENV_ID = "CartPole-v1"
@@ -13,7 +13,7 @@
@pytest.mark.parametrize("asynchronous", [True, False])
def test_vector_env_info(asynchronous):
- env = gym.vector.make(
+ env = gymnasium.vector.make(
ENV_ID, num_envs=NUM_ENVS, asynchronous=asynchronous, disable_env_checker=True
)
env.reset(seed=SEED)
diff --git a/tests/vector/test_vector_env_wrapper.py b/tests/vector/test_vector_env_wrapper.py
index 21b4bd4a6..33c240e8c 100644
--- a/tests/vector/test_vector_env_wrapper.py
+++ b/tests/vector/test_vector_env_wrapper.py
@@ -1,6 +1,6 @@
import numpy as np
-from gym.vector import VectorEnvWrapper, make
+from gymnasium.vector import VectorEnvWrapper, make
class DummyWrapper(VectorEnvWrapper):
diff --git a/tests/vector/test_vector_make.py b/tests/vector/test_vector_make.py
index 35c432f83..dcbf98f43 100644
--- a/tests/vector/test_vector_make.py
+++ b/tests/vector/test_vector_make.py
@@ -1,14 +1,14 @@
import pytest
-import gym
-from gym.vector import AsyncVectorEnv, SyncVectorEnv
-from gym.wrappers import OrderEnforcing, TimeLimit, TransformObservation
-from gym.wrappers.env_checker import PassiveEnvChecker
+import gymnasium
+from gymnasium.vector import AsyncVectorEnv, SyncVectorEnv
+from gymnasium.wrappers import OrderEnforcing, TimeLimit, TransformObservation
+from gymnasium.wrappers.env_checker import PassiveEnvChecker
from tests.wrappers.utils import has_wrapper
def test_vector_make_id():
- env = gym.vector.make("CartPole-v1")
+ env = gymnasium.vector.make("CartPole-v1")
assert isinstance(env, AsyncVectorEnv)
assert env.num_envs == 1
env.close()
@@ -16,28 +16,28 @@ def test_vector_make_id():
@pytest.mark.parametrize("num_envs", [1, 3, 10])
def test_vector_make_num_envs(num_envs):
- env = gym.vector.make("CartPole-v1", num_envs=num_envs)
+ env = gymnasium.vector.make("CartPole-v1", num_envs=num_envs)
assert env.num_envs == num_envs
env.close()
def test_vector_make_asynchronous():
- env = gym.vector.make("CartPole-v1", asynchronous=True)
+ env = gymnasium.vector.make("CartPole-v1", asynchronous=True)
assert isinstance(env, AsyncVectorEnv)
env.close()
- env = gym.vector.make("CartPole-v1", asynchronous=False)
+ env = gymnasium.vector.make("CartPole-v1", asynchronous=False)
assert isinstance(env, SyncVectorEnv)
env.close()
def test_vector_make_wrappers():
- env = gym.vector.make("CartPole-v1", num_envs=2, asynchronous=False)
+ env = gymnasium.vector.make("CartPole-v1", num_envs=2, asynchronous=False)
assert isinstance(env, SyncVectorEnv)
assert len(env.envs) == 2
sub_env = env.envs[0]
- assert isinstance(sub_env, gym.Env)
+ assert isinstance(sub_env, gymnasium.Env)
if sub_env.spec.order_enforce:
assert has_wrapper(sub_env, OrderEnforcing)
if sub_env.spec.max_episode_steps is not None:
@@ -48,7 +48,7 @@ def test_vector_make_wrappers():
)
env.close()
- env = gym.vector.make(
+ env = gymnasium.vector.make(
"CartPole-v1",
num_envs=2,
asynchronous=False,
@@ -63,12 +63,12 @@ def test_vector_make_wrappers():
def test_vector_make_disable_env_checker():
# As asynchronous environment are inaccessible, synchronous vector must be used
- env = gym.vector.make("CartPole-v1", num_envs=1, asynchronous=False)
+ env = gymnasium.vector.make("CartPole-v1", num_envs=1, asynchronous=False)
assert isinstance(env, SyncVectorEnv)
assert has_wrapper(env.envs[0], PassiveEnvChecker)
env.close()
- env = gym.vector.make("CartPole-v1", num_envs=5, asynchronous=False)
+ env = gymnasium.vector.make("CartPole-v1", num_envs=5, asynchronous=False)
assert isinstance(env, SyncVectorEnv)
assert has_wrapper(env.envs[0], PassiveEnvChecker)
assert all(
@@ -76,7 +76,7 @@ def test_vector_make_disable_env_checker():
)
env.close()
- env = gym.vector.make(
+ env = gymnasium.vector.make(
"CartPole-v1", num_envs=3, asynchronous=False, disable_env_checker=True
)
assert isinstance(env, SyncVectorEnv)
diff --git a/tests/vector/utils.py b/tests/vector/utils.py
index d41ff23f4..2bee21a0c 100644
--- a/tests/vector/utils.py
+++ b/tests/vector/utils.py
@@ -3,9 +3,9 @@
import numpy as np
-import gym
-from gym.spaces import Box, Dict, Discrete, MultiBinary, MultiDiscrete, Tuple
-from gym.utils.seeding import RandomNumberGenerator
+import gymnasium
+from gymnasium.spaces import Box, Dict, Discrete, MultiBinary, MultiDiscrete, Tuple
+from gymnasium.utils.seeding import RandomNumberGenerator
spaces = [
Box(low=np.array(-1.0), high=np.array(1.0), dtype=np.float64),
@@ -50,7 +50,7 @@
HEIGHT, WIDTH = 64, 64
-class UnittestSlowEnv(gym.Env):
+class UnittestSlowEnv(gymnasium.Env):
def __init__(self, slow_reset=0.3):
super().__init__()
self.slow_reset = slow_reset
@@ -72,7 +72,7 @@ def step(self, action):
return observation, reward, terminated, truncated, {}
-class CustomSpace(gym.Space):
+class CustomSpace(gymnasium.Space):
"""Minimal custom observation space."""
def sample(self):
@@ -91,7 +91,7 @@ def __eq__(self, other):
]
-class CustomSpaceEnv(gym.Env):
+class CustomSpaceEnv(gymnasium.Env):
def __init__(self):
super().__init__()
self.observation_space = CustomSpace()
@@ -109,7 +109,7 @@ def step(self, action):
def make_env(env_name, seed, **kwargs):
def _make():
- env = gym.make(env_name, disable_env_checker=True, **kwargs)
+ env = gymnasium.make(env_name, disable_env_checker=True, **kwargs)
env.action_space.seed(seed)
env.reset(seed=seed)
return env
diff --git a/tests/wrappers/test_atari_preprocessing.py b/tests/wrappers/test_atari_preprocessing.py
index 10b37b95e..b451f528f 100644
--- a/tests/wrappers/test_atari_preprocessing.py
+++ b/tests/wrappers/test_atari_preprocessing.py
@@ -1,8 +1,8 @@
import numpy as np
import pytest
-from gym.spaces import Box, Discrete
-from gym.wrappers import AtariPreprocessing, StepAPICompatibility
+from gymnasium.spaces import Box, Discrete
+from gymnasium.wrappers import AtariPreprocessing, StepAPICompatibility
from tests.testing_env import GenericTestEnv, old_step_fn
diff --git a/tests/wrappers/test_autoreset.py b/tests/wrappers/test_autoreset.py
index 9b5c1eb1a..5d82c4fc9 100644
--- a/tests/wrappers/test_autoreset.py
+++ b/tests/wrappers/test_autoreset.py
@@ -1,16 +1,16 @@
-"""Tests the gym.wrapper.AutoResetWrapper operates as expected."""
+"""Tests the gymnasium.wrapper.AutoResetWrapper operates as expected."""
from typing import Generator, Optional
from unittest.mock import MagicMock
import numpy as np
import pytest
-import gym
-from gym.wrappers import AutoResetWrapper
+import gymnasium
+from gymnasium.wrappers import AutoResetWrapper
from tests.envs.utils import all_testing_env_specs
-class DummyResetEnv(gym.Env):
+class DummyResetEnv(gymnasium.Env):
"""A dummy environment which returns ascending numbers starting at `0` when :meth:`self.step()` is called.
After the second call to :meth:`self.step()` terminated is true.
@@ -22,10 +22,10 @@ class DummyResetEnv(gym.Env):
def __init__(self):
"""Initialise the DummyResetEnv."""
- self.action_space = gym.spaces.Box(
+ self.action_space = gymnasium.spaces.Box(
low=np.array([0]), high=np.array([2]), dtype=np.int64
)
- self.observation_space = gym.spaces.Discrete(2)
+ self.observation_space = gymnasium.spaces.Discrete(2)
self.count = 0
def step(self, action: int):
@@ -45,9 +45,9 @@ def reset(self, *, seed: Optional[int] = None, options: Optional[dict] = None):
return np.array([self.count]), {"count": self.count}
-def unwrap_env(env) -> Generator[gym.Wrapper, None, None]:
+def unwrap_env(env) -> Generator[gymnasium.Wrapper, None, None]:
"""Unwraps an environment yielding all wrappers around environment."""
- while isinstance(env, gym.Wrapper):
+ while isinstance(env, gymnasium.Wrapper):
yield type(env)
env = env.env
@@ -56,14 +56,14 @@ def unwrap_env(env) -> Generator[gym.Wrapper, None, None]:
"spec", all_testing_env_specs, ids=[spec.id for spec in all_testing_env_specs]
)
def test_make_autoreset_true(spec):
- """Tests gym.make with `autoreset=True`, and check that the reset actually happens.
+ """Tests gymnasium.make with `autoreset=True`, and check that the reset actually happens.
Note: This test assumes that the outermost wrapper is AutoResetWrapper so if that
is being changed in the future, this test will break and need to be updated.
Note: This test assumes that all first-party environments will terminate in a finite
amount of time with random actions, which is true as of the time of adding this test.
"""
- env = gym.make(spec.id, autoreset=True, disable_env_checker=True)
+ env = gymnasium.make(spec.id, autoreset=True, disable_env_checker=True)
assert AutoResetWrapper in unwrap_env(env)
env.reset(seed=0)
@@ -81,16 +81,16 @@ def test_make_autoreset_true(spec):
"spec", all_testing_env_specs, ids=[spec.id for spec in all_testing_env_specs]
)
def test_gym_make_autoreset(spec):
- """Tests that `gym.make` autoreset wrapper is applied only when `gym.make(..., autoreset=True)`."""
- env = gym.make(spec.id, disable_env_checker=True)
+ """Tests that `gymnasium.make` autoreset wrapper is applied only when `gymnasium.make(..., autoreset=True)`."""
+ env = gymnasium.make(spec.id, disable_env_checker=True)
assert AutoResetWrapper not in unwrap_env(env)
env.close()
- env = gym.make(spec.id, autoreset=False, disable_env_checker=True)
+ env = gymnasium.make(spec.id, autoreset=False, disable_env_checker=True)
assert AutoResetWrapper not in unwrap_env(env)
env.close()
- env = gym.make(spec.id, autoreset=True, disable_env_checker=True)
+ env = gymnasium.make(spec.id, autoreset=True, disable_env_checker=True)
assert AutoResetWrapper in unwrap_env(env)
env.close()
diff --git a/tests/wrappers/test_clip_action.py b/tests/wrappers/test_clip_action.py
index 1696034dd..f70ed3844 100644
--- a/tests/wrappers/test_clip_action.py
+++ b/tests/wrappers/test_clip_action.py
@@ -1,14 +1,14 @@
import numpy as np
-import gym
-from gym.wrappers import ClipAction
+import gymnasium
+from gymnasium.wrappers import ClipAction
def test_clip_action():
# mountaincar: action-based rewards
- env = gym.make("MountainCarContinuous-v0", disable_env_checker=True)
+ env = gymnasium.make("MountainCarContinuous-v0", disable_env_checker=True)
wrapped_env = ClipAction(
- gym.make("MountainCarContinuous-v0", disable_env_checker=True)
+ gymnasium.make("MountainCarContinuous-v0", disable_env_checker=True)
)
seed = 0
diff --git a/tests/wrappers/test_filter_observation.py b/tests/wrappers/test_filter_observation.py
index c5880fb24..be21325f3 100644
--- a/tests/wrappers/test_filter_observation.py
+++ b/tests/wrappers/test_filter_observation.py
@@ -3,12 +3,12 @@
import numpy as np
import pytest
-import gym
-from gym import spaces
-from gym.wrappers.filter_observation import FilterObservation
+import gymnasium
+from gymnasium import spaces
+from gymnasium.wrappers.filter_observation import FilterObservation
-class FakeEnvironment(gym.Env):
+class FakeEnvironment(gymnasium.Env):
def __init__(
self, render_mode=None, observation_keys: Tuple[str, ...] = ("state",)
):
diff --git a/tests/wrappers/test_flatten.py b/tests/wrappers/test_flatten.py
index d6ffa4e07..44db6df3d 100644
--- a/tests/wrappers/test_flatten.py
+++ b/tests/wrappers/test_flatten.py
@@ -6,12 +6,12 @@
import numpy as np
import pytest
-import gym
-from gym.spaces import Box, Dict, flatten, unflatten
-from gym.wrappers import FlattenObservation
+import gymnasium
+from gymnasium.spaces import Box, Dict, flatten, unflatten
+from gymnasium.wrappers import FlattenObservation
-class FakeEnvironment(gym.Env):
+class FakeEnvironment(gymnasium.Env):
def __init__(self, observation_space):
self.observation_space = observation_space
diff --git a/tests/wrappers/test_flatten_observation.py b/tests/wrappers/test_flatten_observation.py
index d613c6c5a..1864e80bc 100644
--- a/tests/wrappers/test_flatten_observation.py
+++ b/tests/wrappers/test_flatten_observation.py
@@ -1,14 +1,14 @@
import numpy as np
import pytest
-import gym
-from gym import spaces
-from gym.wrappers import FlattenObservation
+import gymnasium
+from gymnasium import spaces
+from gymnasium.wrappers import FlattenObservation
@pytest.mark.parametrize("env_id", ["Blackjack-v1"])
def test_flatten_observation(env_id):
- env = gym.make(env_id, disable_env_checker=True)
+ env = gymnasium.make(env_id, disable_env_checker=True)
wrapped_env = FlattenObservation(env)
obs, info = env.reset()
diff --git a/tests/wrappers/test_frame_stack.py b/tests/wrappers/test_frame_stack.py
index 58d90b178..7d3af1f94 100644
--- a/tests/wrappers/test_frame_stack.py
+++ b/tests/wrappers/test_frame_stack.py
@@ -1,8 +1,8 @@
import numpy as np
import pytest
-import gym
-from gym.wrappers import FrameStack
+import gymnasium
+from gymnasium.wrappers import FrameStack
try:
import lz4
@@ -25,13 +25,13 @@
],
)
def test_frame_stack(env_id, num_stack, lz4_compress):
- env = gym.make(env_id, disable_env_checker=True)
+ env = gymnasium.make(env_id, disable_env_checker=True)
shape = env.observation_space.shape
env = FrameStack(env, num_stack, lz4_compress)
assert env.observation_space.shape == (num_stack,) + shape
assert env.observation_space.dtype == env.env.observation_space.dtype
- dup = gym.make(env_id, disable_env_checker=True)
+ dup = gymnasium.make(env_id, disable_env_checker=True)
obs, _ = env.reset(seed=0)
dup_obs, _ = dup.reset(seed=0)
diff --git a/tests/wrappers/test_gray_scale_observation.py b/tests/wrappers/test_gray_scale_observation.py
index 8d7a8abb9..ce0f0629a 100644
--- a/tests/wrappers/test_gray_scale_observation.py
+++ b/tests/wrappers/test_gray_scale_observation.py
@@ -1,14 +1,14 @@
import pytest
-import gym
-from gym import spaces
-from gym.wrappers import GrayScaleObservation
+import gymnasium
+from gymnasium import spaces
+from gymnasium.wrappers import GrayScaleObservation
@pytest.mark.parametrize("env_id", ["CarRacing-v2"])
@pytest.mark.parametrize("keep_dim", [True, False])
def test_gray_scale_observation(env_id, keep_dim):
- rgb_env = gym.make(env_id, disable_env_checker=True)
+ rgb_env = gymnasium.make(env_id, disable_env_checker=True)
assert isinstance(rgb_env.observation_space, spaces.Box)
assert len(rgb_env.observation_space.shape) == 3
diff --git a/tests/wrappers/test_human_rendering.py b/tests/wrappers/test_human_rendering.py
index 4af806158..74d6eb0e9 100644
--- a/tests/wrappers/test_human_rendering.py
+++ b/tests/wrappers/test_human_rendering.py
@@ -2,14 +2,14 @@
import pytest
-import gym
-from gym.wrappers import HumanRendering
+import gymnasium
+from gymnasium.wrappers import HumanRendering
def test_human_rendering():
for mode in ["rgb_array", "rgb_array_list"]:
env = HumanRendering(
- gym.make("CartPole-v1", render_mode=mode, disable_env_checker=True)
+ gymnasium.make("CartPole-v1", render_mode=mode, disable_env_checker=True)
)
assert env.render_mode == "human"
env.reset()
@@ -21,7 +21,7 @@ def test_human_rendering():
env.close()
- env = gym.make("CartPole-v1", render_mode="human")
+ env = gymnasium.make("CartPole-v1", render_mode="human")
with pytest.raises(
AssertionError,
match=re.escape(
diff --git a/tests/wrappers/test_nested_dict.py b/tests/wrappers/test_nested_dict.py
index f4d9bdd15..7a785f4c0 100644
--- a/tests/wrappers/test_nested_dict.py
+++ b/tests/wrappers/test_nested_dict.py
@@ -4,12 +4,12 @@
import numpy as np
import pytest
-import gym
-from gym.spaces import Box, Dict, Tuple
-from gym.wrappers import FilterObservation, FlattenObservation
+import gymnasium
+from gymnasium.spaces import Box, Dict, Tuple
+from gymnasium.wrappers import FilterObservation, FlattenObservation
-class FakeEnvironment(gym.Env):
+class FakeEnvironment(gymnasium.Env):
def __init__(self, observation_space, render_mode=None):
self.observation_space = observation_space
self.obs_keys = self.observation_space.spaces.keys()
diff --git a/tests/wrappers/test_normalize.py b/tests/wrappers/test_normalize.py
index b88b016a6..338468564 100644
--- a/tests/wrappers/test_normalize.py
+++ b/tests/wrappers/test_normalize.py
@@ -3,16 +3,16 @@
import numpy as np
from numpy.testing import assert_almost_equal
-import gym
-from gym.wrappers.normalize import NormalizeObservation, NormalizeReward
+import gymnasium
+from gymnasium.wrappers.normalize import NormalizeObservation, NormalizeReward
-class DummyRewardEnv(gym.Env):
+class DummyRewardEnv(gymnasium.Env):
metadata = {}
def __init__(self, return_reward_idx=0):
- self.action_space = gym.spaces.Discrete(2)
- self.observation_space = gym.spaces.Box(
+ self.action_space = gymnasium.spaces.Discrete(2)
+ self.observation_space = gymnasium.spaces.Box(
low=np.array([-1.0]), high=np.array([1.0]), dtype=np.float64
)
self.returned_rewards = [0, 1, 2, 3, 4]
@@ -81,14 +81,14 @@ def test_normalize_return():
def test_normalize_observation_vector_env():
env_fns = [make_env(0), make_env(1)]
- envs = gym.vector.SyncVectorEnv(env_fns)
+ envs = gymnasium.vector.SyncVectorEnv(env_fns)
envs.reset()
obs, reward, _, _, _ = envs.step(envs.action_space.sample())
np.testing.assert_almost_equal(obs, np.array([[1], [2]]), decimal=4)
np.testing.assert_almost_equal(reward, np.array([1, 2]), decimal=4)
env_fns = [make_env(0), make_env(1)]
- envs = gym.vector.SyncVectorEnv(env_fns)
+ envs = gymnasium.vector.SyncVectorEnv(env_fns)
envs = NormalizeObservation(envs)
envs.reset()
assert_almost_equal(
@@ -106,7 +106,7 @@ def test_normalize_observation_vector_env():
def test_normalize_return_vector_env():
env_fns = [make_env(0), make_env(1)]
- envs = gym.vector.SyncVectorEnv(env_fns)
+ envs = gymnasium.vector.SyncVectorEnv(env_fns)
envs = NormalizeReward(envs)
obs = envs.reset()
obs, reward, _, _, _ = envs.step(envs.action_space.sample())
diff --git a/tests/wrappers/test_order_enforcing.py b/tests/wrappers/test_order_enforcing.py
index d1aee9ea9..8cc9db23f 100644
--- a/tests/wrappers/test_order_enforcing.py
+++ b/tests/wrappers/test_order_enforcing.py
@@ -1,9 +1,9 @@
import pytest
-import gym
-from gym.envs.classic_control import CartPoleEnv
-from gym.error import ResetNeeded
-from gym.wrappers import OrderEnforcing
+import gymnasium
+from gymnasium.envs.classic_control import CartPoleEnv
+from gymnasium.error import ResetNeeded
+from gymnasium.wrappers import OrderEnforcing
from tests.envs.utils import all_testing_env_specs
from tests.wrappers.utils import has_wrapper
@@ -12,15 +12,15 @@
"spec", all_testing_env_specs, ids=[spec.id for spec in all_testing_env_specs]
)
def test_gym_make_order_enforcing(spec):
- """Checks that gym.make wrappers the environment with the OrderEnforcing wrapper."""
- env = gym.make(spec.id, disable_env_checker=True)
+ """Checks that gymnasium.make wrappers the environment with the OrderEnforcing wrapper."""
+ env = gymnasium.make(spec.id, disable_env_checker=True)
assert has_wrapper(env, OrderEnforcing)
def test_order_enforcing():
"""Checks that the order enforcing works as expected, raising an error before reset is called and not after."""
- # The reason for not using gym.make is that all environments are by default wrapped in the order enforcing wrapper
+ # The reason for not using gymnasium.make is that all environments are by default wrapped in the order enforcing wrapper
env = CartPoleEnv(render_mode="rgb_array_list")
assert not has_wrapper(env, OrderEnforcing)
diff --git a/tests/wrappers/test_passive_env_checker.py b/tests/wrappers/test_passive_env_checker.py
index 26554081b..6d6284685 100644
--- a/tests/wrappers/test_passive_env_checker.py
+++ b/tests/wrappers/test_passive_env_checker.py
@@ -4,8 +4,8 @@
import numpy as np
import pytest
-import gym
-from gym.wrappers.env_checker import PassiveEnvChecker
+import gymnasium
+from gymnasium.wrappers.env_checker import PassiveEnvChecker
from tests.envs.test_envs import PASSIVE_CHECK_IGNORE_WARNING
from tests.envs.utils import all_testing_initialised_envs
from tests.testing_env import GenericTestEnv
@@ -27,7 +27,7 @@ def test_passive_checker_wrapper_warnings(env):
for warning in caught_warnings:
if warning.message.args[0] not in PASSIVE_CHECK_IGNORE_WARNING:
- raise gym.error.Error(f"Unexpected warning: {warning.message}")
+ raise gymnasium.error.Error(f"Unexpected warning: {warning.message}")
@pytest.mark.parametrize(
@@ -39,7 +39,7 @@ def test_passive_checker_wrapper_warnings(env):
),
(
GenericTestEnv(action_space="error"),
- "action space does not inherit from `gym.spaces.Space`, actual type: ",
+ "action space does not inherit from `gymnasium.spaces.Space`, actual type: ",
),
(
GenericTestEnv(observation_space=None),
@@ -47,7 +47,7 @@ def test_passive_checker_wrapper_warnings(env):
),
(
GenericTestEnv(observation_space="error"),
- "observation space does not inherit from `gym.spaces.Space`, actual type: ",
+ "observation space does not inherit from `gymnasium.spaces.Space`, actual type: ",
),
],
)
diff --git a/tests/wrappers/test_pixel_observation.py b/tests/wrappers/test_pixel_observation.py
index 42bb99d46..ed31aae4f 100644
--- a/tests/wrappers/test_pixel_observation.py
+++ b/tests/wrappers/test_pixel_observation.py
@@ -4,12 +4,12 @@
import numpy as np
import pytest
-import gym
-from gym import spaces
-from gym.wrappers.pixel_observation import STATE_KEY, PixelObservationWrapper
+import gymnasium
+from gymnasium import spaces
+from gymnasium.wrappers.pixel_observation import STATE_KEY, PixelObservationWrapper
-class FakeEnvironment(gym.Env):
+class FakeEnvironment(gymnasium.Env):
def __init__(self, render_mode="single_rgb_array"):
self.action_space = spaces.Box(shape=(1,), low=-1, high=1, dtype=np.float32)
self.render_mode = render_mode
diff --git a/tests/wrappers/test_record_episode_statistics.py b/tests/wrappers/test_record_episode_statistics.py
index ca69a82b1..613d0eef2 100644
--- a/tests/wrappers/test_record_episode_statistics.py
+++ b/tests/wrappers/test_record_episode_statistics.py
@@ -1,15 +1,15 @@
import numpy as np
import pytest
-import gym
-from gym.wrappers import RecordEpisodeStatistics, VectorListInfo
-from gym.wrappers.record_episode_statistics import add_vector_episode_statistics
+import gymnasium
+from gymnasium.wrappers import RecordEpisodeStatistics, VectorListInfo
+from gymnasium.wrappers.record_episode_statistics import add_vector_episode_statistics
@pytest.mark.parametrize("env_id", ["CartPole-v1", "Pendulum-v1"])
@pytest.mark.parametrize("deque_size", [2, 5])
def test_record_episode_statistics(env_id, deque_size):
- env = gym.make(env_id, disable_env_checker=True)
+ env = gymnasium.make(env_id, disable_env_checker=True)
env = RecordEpisodeStatistics(env, deque_size)
for n in range(5):
@@ -28,7 +28,7 @@ def test_record_episode_statistics(env_id, deque_size):
def test_record_episode_statistics_reset_info():
- env = gym.make("CartPole-v1", disable_env_checker=True)
+ env = gymnasium.make("CartPole-v1", disable_env_checker=True)
env = RecordEpisodeStatistics(env)
ob_space = env.observation_space
obs, info = env.reset()
@@ -40,7 +40,7 @@ def test_record_episode_statistics_reset_info():
("num_envs", "asynchronous"), [(1, False), (1, True), (4, False), (4, True)]
)
def test_record_episode_statistics_with_vectorenv(num_envs, asynchronous):
- envs = gym.vector.make(
+ envs = gymnasium.vector.make(
"CartPole-v1",
render_mode=None,
num_envs=num_envs,
@@ -68,7 +68,7 @@ def test_record_episode_statistics_with_vectorenv(num_envs, asynchronous):
def test_wrong_wrapping_order():
- envs = gym.vector.make("CartPole-v1", num_envs=3, disable_env_checker=True)
+ envs = gymnasium.vector.make("CartPole-v1", num_envs=3, disable_env_checker=True)
wrapped_env = RecordEpisodeStatistics(VectorListInfo(envs))
wrapped_env.reset()
diff --git a/tests/wrappers/test_record_video.py b/tests/wrappers/test_record_video.py
index c865c199b..2e22b241a 100644
--- a/tests/wrappers/test_record_video.py
+++ b/tests/wrappers/test_record_video.py
@@ -1,15 +1,15 @@
import os
import shutil
-import gym
-from gym.wrappers import capped_cubic_video_schedule
+import gymnasium
+from gymnasium.wrappers import capped_cubic_video_schedule
def test_record_video_using_default_trigger():
- env = gym.make(
+ env = gymnasium.make(
"CartPole-v1", render_mode="rgb_array_list", disable_env_checker=True
)
- env = gym.wrappers.RecordVideo(env, "videos")
+ env = gymnasium.wrappers.RecordVideo(env, "videos")
env.reset()
for _ in range(199):
action = env.action_space.sample()
@@ -26,8 +26,8 @@ def test_record_video_using_default_trigger():
def test_record_video_reset():
- env = gym.make("CartPole-v1", render_mode="rgb_array", disable_env_checker=True)
- env = gym.wrappers.RecordVideo(env, "videos", step_trigger=lambda x: x % 100 == 0)
+ env = gymnasium.make("CartPole-v1", render_mode="rgb_array", disable_env_checker=True)
+ env = gymnasium.wrappers.RecordVideo(env, "videos", step_trigger=lambda x: x % 100 == 0)
ob_space = env.observation_space
obs, info = env.reset()
env.close()
@@ -38,9 +38,9 @@ def test_record_video_reset():
def test_record_video_step_trigger():
- env = gym.make("CartPole-v1", render_mode="rgb_array", disable_env_checker=True)
+ env = gymnasium.make("CartPole-v1", render_mode="rgb_array", disable_env_checker=True)
env._max_episode_steps = 20
- env = gym.wrappers.RecordVideo(env, "videos", step_trigger=lambda x: x % 100 == 0)
+ env = gymnasium.wrappers.RecordVideo(env, "videos", step_trigger=lambda x: x % 100 == 0)
env.reset()
for _ in range(199):
action = env.action_space.sample()
@@ -56,10 +56,10 @@ def test_record_video_step_trigger():
def make_env(gym_id, seed, **kwargs):
def thunk():
- env = gym.make(gym_id, disable_env_checker=True, **kwargs)
+ env = gymnasium.make(gym_id, disable_env_checker=True, **kwargs)
env._max_episode_steps = 20
if seed == 1:
- env = gym.wrappers.RecordVideo(
+ env = gymnasium.wrappers.RecordVideo(
env, "videos", step_trigger=lambda x: x % 100 == 0
)
return env
@@ -68,10 +68,10 @@ def thunk():
def test_record_video_within_vector():
- envs = gym.vector.SyncVectorEnv(
+ envs = gymnasium.vector.SyncVectorEnv(
[make_env("CartPole-v1", 1 + i, render_mode="rgb_array") for i in range(2)]
)
- envs = gym.wrappers.RecordEpisodeStatistics(envs)
+ envs = gymnasium.wrappers.RecordEpisodeStatistics(envs)
envs.reset()
for i in range(199):
_, _, _, _, infos = envs.step(envs.action_space.sample())
diff --git a/tests/wrappers/test_rescale_action.py b/tests/wrappers/test_rescale_action.py
index 6b2cbf0fa..0f39fcb3a 100644
--- a/tests/wrappers/test_rescale_action.py
+++ b/tests/wrappers/test_rescale_action.py
@@ -1,19 +1,19 @@
import numpy as np
import pytest
-import gym
-from gym.wrappers import RescaleAction
+import gymnasium
+from gymnasium.wrappers import RescaleAction
def test_rescale_action():
- env = gym.make("CartPole-v1", disable_env_checker=True)
+ env = gymnasium.make("CartPole-v1", disable_env_checker=True)
with pytest.raises(AssertionError):
env = RescaleAction(env, -1, 1)
del env
- env = gym.make("Pendulum-v1", disable_env_checker=True)
+ env = gymnasium.make("Pendulum-v1", disable_env_checker=True)
wrapped_env = RescaleAction(
- gym.make("Pendulum-v1", disable_env_checker=True), -1, 1
+ gymnasium.make("Pendulum-v1", disable_env_checker=True), -1, 1
)
seed = 0
diff --git a/tests/wrappers/test_resize_observation.py b/tests/wrappers/test_resize_observation.py
index 330be8a09..e94ba7127 100644
--- a/tests/wrappers/test_resize_observation.py
+++ b/tests/wrappers/test_resize_observation.py
@@ -1,14 +1,14 @@
import pytest
-import gym
-from gym import spaces
-from gym.wrappers import ResizeObservation
+import gymnasium
+from gymnasium import spaces
+from gymnasium.wrappers import ResizeObservation
@pytest.mark.parametrize("env_id", ["CarRacing-v2"])
@pytest.mark.parametrize("shape", [16, 32, (8, 5), [10, 7]])
def test_resize_observation(env_id, shape):
- env = gym.make(env_id, disable_env_checker=True)
+ env = gymnasium.make(env_id, disable_env_checker=True)
env = ResizeObservation(env, shape)
assert isinstance(env.observation_space, spaces.Box)
diff --git a/tests/wrappers/test_step_compatibility.py b/tests/wrappers/test_step_compatibility.py
index 5a9fc4708..0e5570d82 100644
--- a/tests/wrappers/test_step_compatibility.py
+++ b/tests/wrappers/test_step_compatibility.py
@@ -1,11 +1,11 @@
import pytest
-import gym
-from gym.spaces import Discrete
-from gym.wrappers import StepAPICompatibility
+import gymnasium
+from gymnasium.spaces import Discrete
+from gymnasium.wrappers import StepAPICompatibility
-class OldStepEnv(gym.Env):
+class OldStepEnv(gymnasium.Env):
def __init__(self):
self.action_space = Discrete(2)
self.observation_space = Discrete(2)
@@ -18,7 +18,7 @@ def step(self, action):
return obs, rew, done, info
-class NewStepEnv(gym.Env):
+class NewStepEnv(gymnasium.Env):
def __init__(self):
self.action_space = Discrete(2)
self.observation_space = Discrete(2)
@@ -56,16 +56,16 @@ def test_step_compatibility_to_old_api(env):
@pytest.mark.parametrize("apply_api_compatibility", [None, True, False])
def test_step_compatibility_in_make(apply_api_compatibility):
- gym.register("OldStepEnv-v0", entry_point=OldStepEnv)
+ gymnasium.register("OldStepEnv-v0", entry_point=OldStepEnv)
if apply_api_compatibility is not None:
- env = gym.make(
+ env = gymnasium.make(
"OldStepEnv-v0",
apply_api_compatibility=apply_api_compatibility,
disable_env_checker=True,
)
else:
- env = gym.make("OldStepEnv-v0", disable_env_checker=True)
+ env = gymnasium.make("OldStepEnv-v0", disable_env_checker=True)
env.reset()
step_returns = env.step(0)
@@ -79,4 +79,4 @@ def test_step_compatibility_in_make(apply_api_compatibility):
_, _, done, _ = step_returns
assert isinstance(done, bool)
- gym.envs.registry.pop("OldStepEnv-v0")
+ gymnasium.envs.registry.pop("OldStepEnv-v0")
diff --git a/tests/wrappers/test_time_aware_observation.py b/tests/wrappers/test_time_aware_observation.py
index e25d32fba..3398a4784 100644
--- a/tests/wrappers/test_time_aware_observation.py
+++ b/tests/wrappers/test_time_aware_observation.py
@@ -1,13 +1,13 @@
import pytest
-import gym
-from gym import spaces
-from gym.wrappers import TimeAwareObservation
+import gymnasium
+from gymnasium import spaces
+from gymnasium.wrappers import TimeAwareObservation
@pytest.mark.parametrize("env_id", ["CartPole-v1", "Pendulum-v1"])
def test_time_aware_observation(env_id):
- env = gym.make(env_id, disable_env_checker=True)
+ env = gymnasium.make(env_id, disable_env_checker=True)
wrapped_env = TimeAwareObservation(env)
assert isinstance(env.observation_space, spaces.Box)
diff --git a/tests/wrappers/test_time_limit.py b/tests/wrappers/test_time_limit.py
index 76a5ae503..59d5e5612 100644
--- a/tests/wrappers/test_time_limit.py
+++ b/tests/wrappers/test_time_limit.py
@@ -1,12 +1,12 @@
import pytest
-import gym
-from gym.envs.classic_control.pendulum import PendulumEnv
-from gym.wrappers import TimeLimit
+import gymnasium
+from gymnasium.envs.classic_control.pendulum import PendulumEnv
+from gymnasium.wrappers import TimeLimit
def test_time_limit_reset_info():
- env = gym.make("CartPole-v1", disable_env_checker=True)
+ env = gymnasium.make("CartPole-v1", disable_env_checker=True)
env = TimeLimit(env)
ob_space = env.observation_space
obs, info = env.reset()
diff --git a/tests/wrappers/test_transform_observation.py b/tests/wrappers/test_transform_observation.py
index 0cb295811..8e5dd25da 100644
--- a/tests/wrappers/test_transform_observation.py
+++ b/tests/wrappers/test_transform_observation.py
@@ -1,8 +1,8 @@
import numpy as np
import pytest
-import gym
-from gym.wrappers import TransformObservation
+import gymnasium
+from gymnasium.wrappers import TransformObservation
@pytest.mark.parametrize("env_id", ["CartPole-v1", "Pendulum-v1"])
@@ -10,9 +10,9 @@ def test_transform_observation(env_id):
def affine_transform(x):
return 3 * x + 2
- env = gym.make(env_id, disable_env_checker=True)
+ env = gymnasium.make(env_id, disable_env_checker=True)
wrapped_env = TransformObservation(
- gym.make(env_id, disable_env_checker=True), lambda obs: affine_transform(obs)
+ gymnasium.make(env_id, disable_env_checker=True), lambda obs: affine_transform(obs)
)
obs, info = env.reset(seed=0)
diff --git a/tests/wrappers/test_transform_reward.py b/tests/wrappers/test_transform_reward.py
index 457c98e40..8d51eefec 100644
--- a/tests/wrappers/test_transform_reward.py
+++ b/tests/wrappers/test_transform_reward.py
@@ -1,8 +1,8 @@
import numpy as np
import pytest
-import gym
-from gym.wrappers import TransformReward
+import gymnasium
+from gymnasium.wrappers import TransformReward
@pytest.mark.parametrize("env_id", ["CartPole-v1", "Pendulum-v1"])
@@ -10,9 +10,9 @@ def test_transform_reward(env_id):
# use case #1: scale
scales = [0.1, 200]
for scale in scales:
- env = gym.make(env_id, disable_env_checker=True)
+ env = gymnasium.make(env_id, disable_env_checker=True)
wrapped_env = TransformReward(
- gym.make(env_id, disable_env_checker=True), lambda r: scale * r
+ gymnasium.make(env_id, disable_env_checker=True), lambda r: scale * r
)
action = env.action_space.sample()
@@ -28,9 +28,9 @@ def test_transform_reward(env_id):
# use case #2: clip
min_r = -0.0005
max_r = 0.0002
- env = gym.make(env_id, disable_env_checker=True)
+ env = gymnasium.make(env_id, disable_env_checker=True)
wrapped_env = TransformReward(
- gym.make(env_id, disable_env_checker=True), lambda r: np.clip(r, min_r, max_r)
+ gymnasium.make(env_id, disable_env_checker=True), lambda r: np.clip(r, min_r, max_r)
)
action = env.action_space.sample()
@@ -45,9 +45,9 @@ def test_transform_reward(env_id):
del env, wrapped_env
# use case #3: sign
- env = gym.make(env_id, disable_env_checker=True)
+ env = gymnasium.make(env_id, disable_env_checker=True)
wrapped_env = TransformReward(
- gym.make(env_id, disable_env_checker=True), lambda r: np.sign(r)
+ gymnasium.make(env_id, disable_env_checker=True), lambda r: np.sign(r)
)
env.reset(seed=0)
diff --git a/tests/wrappers/test_vector_list_info.py b/tests/wrappers/test_vector_list_info.py
index 93d5c4588..62830a152 100644
--- a/tests/wrappers/test_vector_list_info.py
+++ b/tests/wrappers/test_vector_list_info.py
@@ -1,7 +1,7 @@
import pytest
-import gym
-from gym.wrappers import RecordEpisodeStatistics, VectorListInfo
+import gymnasium
+from gymnasium.wrappers import RecordEpisodeStatistics, VectorListInfo
ENV_ID = "CartPole-v1"
NUM_ENVS = 3
@@ -10,8 +10,8 @@
def test_usage_in_vector_env():
- env = gym.make(ENV_ID, disable_env_checker=True)
- vector_env = gym.vector.make(ENV_ID, num_envs=NUM_ENVS, disable_env_checker=True)
+ env = gymnasium.make(ENV_ID, disable_env_checker=True)
+ vector_env = gymnasium.vector.make(ENV_ID, num_envs=NUM_ENVS, disable_env_checker=True)
VectorListInfo(vector_env)
@@ -20,7 +20,7 @@ def test_usage_in_vector_env():
def test_info_to_list():
- env_to_wrap = gym.vector.make(ENV_ID, num_envs=NUM_ENVS, disable_env_checker=True)
+ env_to_wrap = gymnasium.vector.make(ENV_ID, num_envs=NUM_ENVS, disable_env_checker=True)
wrapped_env = VectorListInfo(env_to_wrap)
wrapped_env.action_space.seed(SEED)
_, info = wrapped_env.reset(seed=SEED)
@@ -38,7 +38,7 @@ def test_info_to_list():
def test_info_to_list_statistics():
- env_to_wrap = gym.vector.make(ENV_ID, num_envs=NUM_ENVS, disable_env_checker=True)
+ env_to_wrap = gymnasium.vector.make(ENV_ID, num_envs=NUM_ENVS, disable_env_checker=True)
wrapped_env = VectorListInfo(RecordEpisodeStatistics(env_to_wrap))
_, info = wrapped_env.reset(seed=SEED)
wrapped_env.action_space.seed(SEED)
diff --git a/tests/wrappers/test_video_recorder.py b/tests/wrappers/test_video_recorder.py
index db36f61cf..1a0bf2950 100644
--- a/tests/wrappers/test_video_recorder.py
+++ b/tests/wrappers/test_video_recorder.py
@@ -5,11 +5,11 @@
import pytest
-import gym
-from gym.wrappers.monitoring.video_recorder import VideoRecorder
+import gymnasium
+from gymnasium.wrappers.monitoring.video_recorder import VideoRecorder
-class BrokenRecordableEnv(gym.Env):
+class BrokenRecordableEnv(gymnasium.Env):
metadata = {"render_modes": ["rgb_array_list"]}
def __init__(self, render_mode="rgb_array_list"):
@@ -19,7 +19,7 @@ def render(self):
pass
-class UnrecordableEnv(gym.Env):
+class UnrecordableEnv(gymnasium.Env):
metadata = {"render_modes": [None]}
def __init__(self, render_mode=None):
@@ -30,7 +30,7 @@ def render(self):
def test_record_simple():
- env = gym.make(
+ env = gymnasium.make(
"CartPole-v1", render_mode="rgb_array_list", disable_env_checker=True
)
rec = VideoRecorder(env)
@@ -47,7 +47,7 @@ def test_record_simple():
def test_autoclose():
def record():
- env = gym.make(
+ env = gymnasium.make(
"CartPole-v1", render_mode="rgb_array_list", disable_env_checker=True
)
rec = VideoRecorder(env)
@@ -107,7 +107,7 @@ def test_record_breaking_render_method():
def test_text_envs():
- env = gym.make(
+ env = gymnasium.make(
"FrozenLake-v1", render_mode="rgb_array_list", disable_env_checker=True
)
video = VideoRecorder(env)
diff --git a/tests/wrappers/utils.py b/tests/wrappers/utils.py
index 55db8873a..8f411be1e 100644
--- a/tests/wrappers/utils.py
+++ b/tests/wrappers/utils.py
@@ -1,8 +1,8 @@
-import gym
+import gymnasium
-def has_wrapper(wrapped_env: gym.Env, wrapper_type: type) -> bool:
- while isinstance(wrapped_env, gym.Wrapper):
+def has_wrapper(wrapped_env: gymnasium.Env, wrapper_type: type) -> bool:
+ while isinstance(wrapped_env, gymnasium.Wrapper):
if isinstance(wrapped_env, wrapper_type):
return True
wrapped_env = wrapped_env.env