Skip to content

Commit

Permalink
Update env_checker.py (#708)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisyeh96 authored Sep 8, 2023
1 parent 0237faa commit d9a8d66
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
16 changes: 8 additions & 8 deletions gymnasium/utils/env_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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)):
Expand All @@ -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
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion tests/envs/mujoco/test_mujoco_custom_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def _get_reset_info(self):
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.",
]
]
Expand Down
2 changes: 1 addition & 1 deletion tests/envs/mujoco/test_mujoco_v5.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def test_verify_reward_survive(env_name: str, version: str):
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.",
]
]
Expand Down
2 changes: 1 addition & 1 deletion tests/envs/test_envs.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
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.",
]
]
Expand Down

0 comments on commit d9a8d66

Please sign in to comment.