mirror of
https://github.com/Farama-Foundation/Gymnasium.git
synced 2025-07-31 05:44:31 +00:00
Remove warnings (#435)
Co-authored-by: Aaron Walsman <aaronwalsman@gmail.com>
This commit is contained in:
@@ -21,30 +21,6 @@ def _check_box_observation_space(observation_space: spaces.Box):
|
||||
Args:
|
||||
observation_space: A box observation space
|
||||
"""
|
||||
# Check if the box is an image
|
||||
if (len(observation_space.shape) == 3 and observation_space.shape[0] != 1) or (
|
||||
len(observation_space.shape) == 4 and observation_space.shape[0] == 1
|
||||
):
|
||||
if observation_space.dtype != np.uint8:
|
||||
logger.warn(
|
||||
f"It seems a Box observation space is an image but the `dtype` is not `np.uint8`, actual type: {observation_space.dtype}. "
|
||||
"If the Box observation space is not an image, we recommend flattening the observation to have only a 1D vector."
|
||||
)
|
||||
if np.any(observation_space.low != 0) or np.any(observation_space.high != 255):
|
||||
logger.warn(
|
||||
"It seems a Box observation space is an image but the lower and upper bounds are not [0, 255]. "
|
||||
f"Actual lower bound: {np.min(observation_space.low)}, upper bound: {np.max(observation_space.high)}. "
|
||||
"Generally, CNN policies assume observations are within that range, so you may encounter an issue if the observation values are not."
|
||||
)
|
||||
|
||||
if len(observation_space.shape) not in [1, 3]:
|
||||
if not (len(observation_space.shape) == 2 and observation_space.shape[0] == 1):
|
||||
logger.warn(
|
||||
"A Box observation space has an unconventional shape (neither an image, nor a 1D vector). "
|
||||
"We recommend flattening the observation to have only a 1D vector or use a custom policy to properly process the data. "
|
||||
f"Actual observation shape: {observation_space.shape}"
|
||||
)
|
||||
|
||||
assert (
|
||||
observation_space.low.shape == observation_space.shape
|
||||
), f"The Box observation space shape and low shape have different shapes, low shape: {observation_space.low.shape}, box shape: {observation_space.shape}"
|
||||
|
@@ -18,7 +18,6 @@ from tests.envs.utils import (
|
||||
# to try also running environments which are not officially registered envs.
|
||||
PASSIVE_CHECK_IGNORE_WARNING = [
|
||||
r"\x1b\[33mWARN: 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\)\.\x1b\[0m",
|
||||
r"\x1b\[33mWARN: Initializing environment in done \(old\) step API which returns one bool instead of two\.\x1b\[0m",
|
||||
r"\x1b\[33mWARN: The environment (.*?) is out of date\. You should consider upgrading to version `v(\d)`\.\x1b\[0m",
|
||||
]
|
||||
|
||||
|
@@ -32,26 +32,6 @@ def _modify_space(space: spaces.Space, attribute: str, value):
|
||||
"observation space does not inherit from `gymnasium.spaces.Space`, actual type: <class 'str'>",
|
||||
],
|
||||
# ===== Check box observation space ====
|
||||
[
|
||||
UserWarning,
|
||||
spaces.Box(np.zeros((5, 5, 1)), 255 * np.ones((5, 5, 1)), dtype=np.int32),
|
||||
"It seems a Box observation space is an image but the `dtype` is not `np.uint8`, actual type: int32. If the Box observation space is not an image, we recommend flattening the observation to have only a 1D vector.",
|
||||
],
|
||||
[
|
||||
UserWarning,
|
||||
spaces.Box(np.ones((2, 2, 1)), 255 * np.ones((2, 2, 1)), dtype=np.uint8),
|
||||
"It seems a Box observation space is an image but the lower and upper bounds are not [0, 255]. Actual lower bound: 1, upper bound: 255. Generally, CNN policies assume observations are within that range, so you may encounter an issue if the observation values are not.",
|
||||
],
|
||||
[
|
||||
UserWarning,
|
||||
spaces.Box(np.zeros((5, 5, 1)), np.ones((5, 5, 1)), dtype=np.uint8),
|
||||
"It seems a Box observation space is an image but the lower and upper bounds are not [0, 255]. Actual lower bound: 0, upper bound: 1. Generally, CNN policies assume observations are within that range, so you may encounter an issue if the observation values are not.",
|
||||
],
|
||||
[
|
||||
UserWarning,
|
||||
spaces.Box(np.zeros((5, 5)), np.ones((5, 5))),
|
||||
"A Box observation space has an unconventional shape (neither an image, nor a 1D vector). We recommend flattening the observation to have only a 1D vector or use a custom policy to properly process the data. Actual observation shape: (5, 5)",
|
||||
],
|
||||
[
|
||||
UserWarning,
|
||||
spaces.Box(np.zeros(5), np.zeros(5)),
|
||||
|
Reference in New Issue
Block a user