mirror of
https://github.com/Farama-Foundation/Gymnasium.git
synced 2025-08-18 21:06:59 +00:00
Update env_checker.py (#708)
This commit is contained in:
@@ -63,7 +63,7 @@ def data_equivalence(data_1, data_2) -> bool:
|
||||
return False
|
||||
|
||||
|
||||
def check_reset_seed(env: gym.Env):
|
||||
def check_reset_seed(env: gym.Env) -> None:
|
||||
"""Check that the environment can be reset with a seed.
|
||||
|
||||
Args:
|
||||
@@ -132,7 +132,7 @@ def check_reset_seed(env: gym.Env):
|
||||
)
|
||||
|
||||
|
||||
def check_reset_options(env: gym.Env):
|
||||
def check_reset_options(env: gym.Env) -> None:
|
||||
"""Check that the environment can be reset with options.
|
||||
|
||||
Args:
|
||||
@@ -160,7 +160,7 @@ def check_reset_options(env: gym.Env):
|
||||
)
|
||||
|
||||
|
||||
def check_reset_return_info_deprecation(env: gym.Env):
|
||||
def check_reset_return_info_deprecation(env: gym.Env) -> None:
|
||||
"""Makes sure support for deprecated `return_info` argument is dropped.
|
||||
|
||||
Args:
|
||||
@@ -177,7 +177,7 @@ def check_reset_return_info_deprecation(env: gym.Env):
|
||||
)
|
||||
|
||||
|
||||
def check_seed_deprecation(env: gym.Env):
|
||||
def check_seed_deprecation(env: gym.Env) -> None:
|
||||
"""Makes sure support for deprecated function `seed` is dropped.
|
||||
|
||||
Args:
|
||||
@@ -193,7 +193,7 @@ def check_seed_deprecation(env: gym.Env):
|
||||
)
|
||||
|
||||
|
||||
def check_reset_return_type(env: gym.Env):
|
||||
def check_reset_return_type(env: gym.Env) -> None:
|
||||
"""Checks that :meth:`reset` correctly returns a tuple of the form `(obs , info)`.
|
||||
|
||||
Args:
|
||||
@@ -218,7 +218,7 @@ def check_reset_return_type(env: gym.Env):
|
||||
), f"The second element returned by `env.reset()` was not a dictionary, actual type: {type(info)}"
|
||||
|
||||
|
||||
def check_space_limit(space, space_type: str):
|
||||
def check_space_limit(space: spaces.Space, space_type: str) -> None:
|
||||
"""Check the space limit for only the Box space as a test that only runs as part of `check_env`."""
|
||||
if isinstance(space, spaces.Box):
|
||||
if np.any(np.equal(space.low, -np.inf)):
|
||||
@@ -227,7 +227,7 @@ def check_space_limit(space, space_type: str):
|
||||
)
|
||||
if np.any(np.equal(space.high, np.inf)):
|
||||
logger.warn(
|
||||
f"A Box {space_type} space maximum value is -infinity. This is probably too high."
|
||||
f"A Box {space_type} space maximum value is infinity. This is probably too high."
|
||||
)
|
||||
|
||||
# Check that the Box space is normalized
|
||||
@@ -256,7 +256,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: gym.Env, warn: bool = None, skip_render_check: bool = False) -> None:
|
||||
"""Check that an environment follows Gym API.
|
||||
|
||||
This is an invasive function that calls the environment's reset and step.
|
||||
|
@@ -88,7 +88,7 @@ CHECK_ENV_IGNORE_WARNINGS = [
|
||||
f"\x1b[33mWARN: {message}\x1b[0m"
|
||||
for message in [
|
||||
"A Box observation space minimum value is -infinity. This is probably too low.",
|
||||
"A Box observation space maximum value is -infinity. This is probably too high.",
|
||||
"A Box observation space maximum value is infinity. This is probably too high.",
|
||||
"For Box action spaces, we recommend using a symmetric and normalized space (range=[-1, 1] or [0, 1]). See https://stable-baselines3.readthedocs.io/en/master/guide/rl_tips.html for more information.",
|
||||
]
|
||||
]
|
||||
|
@@ -199,7 +199,7 @@ CHECK_ENV_IGNORE_WARNINGS = [
|
||||
f"\x1b[33mWARN: {message}\x1b[0m"
|
||||
for message in [
|
||||
"A Box observation space minimum value is -infinity. This is probably too low.",
|
||||
"A Box observation space maximum value is -infinity. This is probably too high.",
|
||||
"A Box observation space maximum value is infinity. This is probably too high.",
|
||||
"For Box action spaces, we recommend using a symmetric and normalized space (range=[-1, 1] or [0, 1]). See https://stable-baselines3.readthedocs.io/en/master/guide/rl_tips.html for more information.",
|
||||
]
|
||||
]
|
||||
|
@@ -27,7 +27,7 @@ CHECK_ENV_IGNORE_WARNINGS = [
|
||||
for message in [
|
||||
"This version of the mujoco environments depends on the mujoco-py bindings, which are no longer maintained and may stop working. Please upgrade to the v4 versions of the environments (which depend on the mujoco python bindings instead), unless you are trying to precisely replicate previous works).",
|
||||
"A Box observation space minimum value is -infinity. This is probably too low.",
|
||||
"A Box observation space maximum value is -infinity. This is probably too high.",
|
||||
"A Box observation space maximum value is infinity. This is probably too high.",
|
||||
"For Box action spaces, we recommend using a symmetric and normalized space (range=[-1, 1] or [0, 1]). See https://stable-baselines3.readthedocs.io/en/master/guide/rl_tips.html for more information.",
|
||||
]
|
||||
]
|
||||
|
Reference in New Issue
Block a user